org.eclipse.xtext.resource.EObjectDescription Java Examples
The following examples show how to use
org.eclipse.xtext.resource.EObjectDescription.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XtendImportedNamespaceScopeProvider.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
private void doGetAllDescriptions(JvmDeclaredType type, List<IEObjectDescription> descriptions) { descriptions.add(EObjectDescription.create(getQualifiedNameConverter().toQualifiedName(type.getIdentifier()), type)); EList<JvmMember> members = null; if (type instanceof JvmDeclaredTypeImplCustom) { members = ((JvmDeclaredTypeImplCustom)type).basicGetMembers(); } else { members = type.getMembers(); } for(JvmMember member: members) { if (member instanceof JvmDeclaredType) { // add nested types also with the dot delimiter descriptions.add(EObjectDescription.create(getQualifiedNameConverter().toQualifiedName(member.getQualifiedName('.')), member)); doGetAllDescriptions((JvmDeclaredType) member, descriptions); } } }
Example #2
Source File: EcoreResourceDescriptionStrategy.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected boolean createEObjectDescriptions(IQualifiedNameProvider qualifiedNameProvider, boolean isNsURI, EObject eObject, IAcceptor<IEObjectDescription> acceptor) { try { QualifiedName qualifiedName = qualifiedNameProvider.getFullyQualifiedName(eObject); if (qualifiedName != null) { Map<String, String> userData = Maps.newHashMapWithExpectedSize(1); userData.put(NS_URI_INDEX_ENTRY, Boolean.toString(isNsURI)); IEObjectDescription description = EObjectDescription.create(qualifiedName, eObject, userData); acceptor.accept(description); return true; } } catch (Exception exc) { LOG.error(exc.getMessage(), exc); } return false; }
Example #3
Source File: Indexer.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
public ResolvedResourceDescription(IResourceDescription original) { uri = original.getURI(); exported = FluentIterable.from(original.getExportedObjects()).transform(from -> { if (from instanceof SerializableEObjectDescriptionProvider) { return ((SerializableEObjectDescriptionProvider) from).toSerializableEObjectDescription(); } if (from.getEObjectOrProxy().eIsProxy()) { return from; } InternalEObject result = (InternalEObject) EcoreUtil.create(from.getEClass()); result.eSetProxyURI(from.getEObjectURI()); Map<String, String> userData = null; String[] userDataKeys = from.getUserDataKeys(); for (String key : userDataKeys) { if (userData == null) { userData = Maps.newHashMapWithExpectedSize(userDataKeys.length); } userData.put(key, from.getUserData(key)); } return EObjectDescription.create(from.getName(), result, userData); }).toList(); }
Example #4
Source File: SerializerScopeProvider.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected IScope getExecutableScope(XAbstractFeatureCall call, JvmIdentifiableElement feature) { final String simpleName = feature.getSimpleName(); QualifiedName name = QualifiedName.create(simpleName); if (call.isOperation()) { QualifiedName operator = getOperator(call, name); if (operator == null) { return IScope.NULLSCOPE; } return new SingletonScope(EObjectDescription.create(operator, feature), IScope.NULLSCOPE); } if (call instanceof XAssignment) { return getAccessorScope(simpleName, name, feature); } if (call.isExplicitOperationCallOrBuilderSyntax() || ((JvmExecutable) feature).getParameters().size() > 1 || (!call.isExtension() && ((JvmExecutable) feature).getParameters().size() == 1)) { return new SingletonScope(EObjectDescription.create(name, feature), IScope.NULLSCOPE); } return getAccessorScope(simpleName, name, feature); }
Example #5
Source File: SerializerScopeProvider.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
public IScope createFeatureCallSerializationScope(EObject context) { if (!(context instanceof XAbstractFeatureCall)) { return IScope.NULLSCOPE; } XAbstractFeatureCall call = (XAbstractFeatureCall) context; JvmIdentifiableElement feature = call.getFeature(); // this and super - logical container aware FeatureScopes if (feature instanceof JvmType) { return getTypeScope(call, (JvmType) feature); } if (feature instanceof JvmConstructor) { return getThisOrSuperScope(call, (JvmConstructor) feature); } if (feature instanceof JvmExecutable) { return getExecutableScope(call, feature); } if (feature instanceof JvmFormalParameter || feature instanceof JvmField || feature instanceof XVariableDeclaration || feature instanceof XSwitchExpression) { return new SingletonScope(EObjectDescription.create(feature.getSimpleName(), feature), IScope.NULLSCOPE); } return IScope.NULLSCOPE; }
Example #6
Source File: UnionMemberScope.java From n4js with Eclipse Public License 1.0 | 6 votes |
@Override protected IEObjectDescription getCheckedDescription(String name, TMember member) { IEObjectDescription description = EObjectDescription.create(member.getName(), member); QualifiedName qn = QualifiedName.create(name); for (IScope currSubScope : subScopes) { IEObjectDescription subDescription = currSubScope.getSingleElement(qn); boolean descrWithError = subDescription == null || IEObjectDescriptionWithError.isErrorDescription(subDescription); if (descrWithError) { return createComposedMemberDescriptionWithErrors(description); } } return description; }
Example #7
Source File: IntersectionMemberScope.java From n4js with Eclipse Public License 1.0 | 6 votes |
@Override protected IEObjectDescription getCheckedDescription(String name, TMember member) { IEObjectDescription description = EObjectDescription.create(member.getName(), member); QualifiedName qn = QualifiedName.create(name); boolean allDescrWithError = true; for (IScope currSubScope : subScopes) { IEObjectDescription subDescription = currSubScope.getSingleElement(qn); boolean descrWithError = subDescription == null || IEObjectDescriptionWithError.isErrorDescription(subDescription); allDescrWithError &= descrWithError; } if (allDescrWithError) { return createComposedMemberDescriptionWithErrors(description); } return description; }
Example #8
Source File: ScopeResourceDescriptionStrategy.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
@Override public boolean createEObjectDescriptions(final EObject eObject, final IAcceptor<IEObjectDescription> acceptor) { if (getQualifiedNameProvider() == null || !(eObject instanceof ScopeModel)) { return false; } ScopeModel model = (ScopeModel) eObject; try { QualifiedName qualifiedName = getQualifiedNameProvider().getFullyQualifiedName(model); if (qualifiedName != null) { Hasher hasher = Hashing.murmur3_32().newHasher(HASHER_CAPACITY); hasher.putUnencodedChars(getSourceText(model)); for (ScopeModel include : model.getIncludedScopes()) { hasher.putUnencodedChars(getSourceText(include)); } acceptor.accept(EObjectDescription.create(qualifiedName, model, Collections.singletonMap("fingerprint", hasher.hash().toString()))); } // CHECKSTYLE:CHECK-OFF IllegalCatch } catch (RuntimeException e) { // CHECKSTYLE:CHECK-ON LOG.error(e.getMessage(), e); } return false; }
Example #9
Source File: XIndexer.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Constructor */ public XResolvedResourceDescription(IResourceDescription original) { this.URI = original.getURI(); this.exported = ImmutableList.copyOf(IterableExtensions.map(original.getExportedObjects(), (from) -> { if (from instanceof SerializableEObjectDescriptionProvider) { return ((SerializableEObjectDescriptionProvider) from).toSerializableEObjectDescription(); } if (from.getEObjectOrProxy().eIsProxy()) { return from; } InternalEObject result = ((InternalEObject) EcoreUtil.create(from.getEClass())); result.eSetProxyURI(from.getEObjectURI()); Map<String, String> userData = null; String[] userDataKeys = from.getUserDataKeys(); for (String key : userDataKeys) { if (userData == null) { userData = Maps.newHashMapWithExpectedSize(userDataKeys.length); } userData.put(key, from.getUserData(key)); } return EObjectDescription.create(from.getName(), result, userData); })); }
Example #10
Source File: EObjectDescriptions.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * Returns scoped elements for all given objects by applying all given name functions. The result is first ordered by function * then by object. If a function returns null for a given object no corresponding scoped element will be included in the result. * * @param <T> * type of model objects * @param objects * model objects iterable * @param nameFunctions * list of name functions * @return scoped element iterable */ public static <T extends EObject> Iterable<IEObjectDescription> all(final Iterable<T> objects, final Iterable<INameFunction> nameFunctions) { return Iterables.concat(Iterables.transform(nameFunctions, new Function<INameFunction, Iterable<IEObjectDescription>>() { @Override public Iterable<IEObjectDescription> apply(final INameFunction param) { return Iterables.filter(Iterables.transform(objects, new Function<T, IEObjectDescription>() { @Override public IEObjectDescription apply(final T from) { if (from == null) { return null; } final QualifiedName name = param.apply(from); return (name == null) ? null : EObjectDescription.create(name, from); // NOPMD } }), Predicates.notNull()); } })); }
Example #11
Source File: DefaultResourceDescriptionDeltaTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Test public void testHasChanges_DifferentURIs() throws Exception { TestResDesc resourceDesc = new TestResDesc(); resourceDesc.imported.add(FOO); resourceDesc.exported.add(EObjectDescription.create(BAR, EcorePackage.Literals.EANNOTATION, Collections.singletonMap("foo", "bar"))); TestResDesc resourceDesc2 = new TestResDesc(); resourceDesc2.imported.add(FOO); resourceDesc2.exported.add(new EObjectDescription(BAR, EcorePackage.Literals.EANNOTATION, Collections.singletonMap("foo", "bar")){ @Override public URI getEObjectURI() { return super.getEObjectURI().appendFragment("foo"); } } ); assertTrue(new DefaultResourceDescriptionDelta(resourceDesc, resourceDesc2).haveEObjectDescriptionsChanged()); }
Example #12
Source File: FixedCopiedResourceDescription.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
public FixedCopiedResourceDescription(final IResourceDescription original) { super(); this.uri = original.getURI(); this.exported = ImmutableList.copyOf(Iterables.transform(original.getExportedObjects(), new Function<IEObjectDescription, IEObjectDescription>() { @Override @SuppressWarnings("unchecked") public IEObjectDescription apply(final IEObjectDescription from) { if (from.getEObjectOrProxy().eIsProxy()) { return from; } else if (from instanceof IDetachableDescription) { return ((IDetachableDescription<IEObjectDescription>) from).detach(); } InternalEObject result = (InternalEObject) EcoreUtil.create(from.getEClass()); result.eSetProxyURI(from.getEObjectURI()); ImmutableMap.Builder<String, String> userData = ImmutableMap.builder(); for (final String key : from.getUserDataKeys()) { userData.put(key, from.getUserData(key)); } return EObjectDescription.create(from.getName(), result, userData.build()); } })); }
Example #13
Source File: XtextScopeProvider.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected IScope createScope(final Grammar grammar, EClass type, IScope current) { if (EcorePackage.Literals.EPACKAGE == type) { return createEPackageScope(grammar); } else if (AbstractMetamodelDeclaration.class.isAssignableFrom(type.getInstanceClass())) { return new SimpleScope(IScope.NULLSCOPE,Iterables.transform(grammar.getMetamodelDeclarations(), new Function<AbstractMetamodelDeclaration,IEObjectDescription>(){ @Override public IEObjectDescription apply(AbstractMetamodelDeclaration from) { String name = from.getAlias() != null ? from.getAlias() : ""; return EObjectDescription.create(QualifiedName.create(name), from); } })); } final List<Grammar> allGrammars = getAllGrammars(grammar); for (int i = allGrammars.size() - 1; i >= 0; i--) { current = doCreateScope(allGrammars.get(i), type, current); } return current; }
Example #14
Source File: TypeScopes.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
public IScope createTypeScope(EObject context, EReference reference) { if (context.eClass() == TypesPackage.Literals.JVM_INNER_TYPE_REFERENCE) { JvmInnerTypeReference casted = (JvmInnerTypeReference) context; JvmParameterizedTypeReference outerType = casted.getOuter(); JvmType outerRawType = outerType.getType(); if (outerRawType instanceof JvmDeclaredType) { Iterable<JvmDeclaredType> nestedTypes = ((JvmDeclaredType) outerRawType).getAllNestedTypes(); List<IEObjectDescription> descriptions = Lists.newArrayList(); for(JvmDeclaredType nestedType: nestedTypes) { descriptions.add(EObjectDescription.create(nestedType.getSimpleName(), nestedType)); } return new SimpleScope(descriptions); } return IScope.NULLSCOPE; } else { final IScope delegateScope = getDelegate().getScope(context, reference); return delegateScope; } }
Example #15
Source File: XbaseWithAnnotationsBatchScopeProvider.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override public IScope getScope(EObject context, EReference reference) { if (reference == XAnnotationsPackage.Literals.XANNOTATION_ELEMENT_VALUE_PAIR__ELEMENT) { XAnnotation annotation = EcoreUtil2.getContainerOfType(context, XAnnotation.class); JvmType annotationType = annotation.getAnnotationType(); if (annotationType == null || annotationType.eIsProxy() || !(annotationType instanceof JvmAnnotationType)) { return IScope.NULLSCOPE; } Iterable<JvmOperation> operations = ((JvmAnnotationType) annotationType).getDeclaredOperations(); Iterable<IEObjectDescription> descriptions = transform(operations, new Function<JvmOperation, IEObjectDescription>() { @Override public IEObjectDescription apply(JvmOperation from) { return EObjectDescription.create(QualifiedName.create(from.getSimpleName()), from); } }); return MapBasedScope.createScope(IScope.NULLSCOPE, descriptions); } return super.getScope(context, reference); }
Example #16
Source File: ImportScopeTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Test public void testRelativeImports_01() throws Exception { final IEObjectDescription desc1 = EObjectDescription.create(QualifiedName.create("com","foo","bar"), EcorePackage.Literals.EANNOTATION); final IEObjectDescription desc2 = EObjectDescription.create(QualifiedName.create("de","foo"), EcorePackage.Literals.EATTRIBUTE); IScope outer = new SimpleScope(newArrayList(desc1,desc2), false); ImportNormalizer n1 = new ImportNormalizer(QualifiedName.create("com"), true, false); ImportNormalizer n2 = new ImportNormalizer(QualifiedName.create("de"), true, false); outer = new TestableImportScope(newArrayList(n1,n2), outer, new ScopeBasedSelectable(outer), EcorePackage.Literals.EOBJECT, false); n1 = new ImportNormalizer(QualifiedName.create("foo"), true, false); n2 = new ImportNormalizer(QualifiedName.create("foo"), false, false); TestableImportScope scope = new TestableImportScope(newArrayList(n1,n2), outer, new ScopeBasedSelectable(outer), EcorePackage.Literals.EOBJECT, false); final Iterable<IEObjectDescription> elements = scope.getAllElements(); Iterator<IEObjectDescription> iterator = elements.iterator(); assertEquals("bar", iterator.next().getName().toString()); assertEquals("foo", iterator.next().getName().toString()); assertEquals("foo.bar", iterator.next().getName().toString()); assertSame(desc1,iterator.next()); assertSame(desc2,iterator.next()); assertFalse(iterator.hasNext()); }
Example #17
Source File: AbstractConstructorScope.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override public Iterable<IEObjectDescription> getElements(EObject object) { if (object instanceof JvmConstructor) { JvmConstructor constructor = ((JvmConstructor) object); String qualifiedNameWithDots = constructor.getQualifiedName('.'); String qualifiedNameWithDollar = constructor.getQualifiedName(); if (qualifiedNameWithDollar.equals(qualifiedNameWithDots)) { final Set<IEObjectDescription> result = singleton( EObjectDescription.create(getQualifiedNameConverter().toQualifiedName(qualifiedNameWithDots), object)); return result; } else { return Arrays.asList( EObjectDescription.create(getQualifiedNameConverter().toQualifiedName(qualifiedNameWithDots), object), EObjectDescription.create(getQualifiedNameConverter().toQualifiedName(qualifiedNameWithDollar), object)); } } return emptySet(); }
Example #18
Source File: AbstractConstructorScope.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override public Iterable<IEObjectDescription> getElements(final QualifiedName name) { IEObjectDescription typeDescription = typeScope.getSingleElement(name); if (typeDescription == null) return emptySet(); JvmType type = (JvmType) typeDescription.getEObjectOrProxy(); if (type.eIsProxy() || !(type instanceof JvmGenericType)) { return emptySet(); } final JvmGenericType castedType = (JvmGenericType) type; if (castedType.isInterface()) { return emptySet(); } Iterable<JvmConstructor> constructors = new Iterable<JvmConstructor>() { @Override public Iterator<JvmConstructor> iterator() { return castedType.getDeclaredConstructors().iterator(); } }; return transform(constructors, new Function<JvmConstructor,IEObjectDescription>(){ @Override public IEObjectDescription apply(JvmConstructor from) { return EObjectDescription.create(name, from); } }); }
Example #19
Source File: AbstractTypeScope.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override public Iterable<IEObjectDescription> getElements(EObject object) { if (object instanceof JvmIdentifiableElement) { JvmIdentifiableElement identifiable = ((JvmIdentifiableElement) object); String qualifiedNameWithDots = identifiable.getQualifiedName('.'); String qualifiedNameWithDollar = identifiable.getQualifiedName(); if (qualifiedNameWithDollar.equals(qualifiedNameWithDots)) { final Set<IEObjectDescription> result = singleton( EObjectDescription.create(qualifiedNameConverter.toQualifiedName(qualifiedNameWithDots), object)); return filterResult(result); } else { return filterResult(Arrays.asList( EObjectDescription.create(qualifiedNameConverter.toQualifiedName(qualifiedNameWithDots), object), EObjectDescription.create(qualifiedNameConverter.toQualifiedName(qualifiedNameWithDollar), object))); } } return emptySet(); }
Example #20
Source File: SuperCallScope.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override public Iterable<IEObjectDescription> getElements(EObject object) { if (object instanceof AbstractRule) { Grammar grammar = GrammarUtil.getGrammar(context); AbstractRule rule = (AbstractRule) object; if (GrammarUtil.getGrammar(rule) == grammar) { return Lists.newArrayList( EObjectDescription.create(GrammarUtil.getSimpleName(grammar) + "." + rule.getName(), rule), EObjectDescription.create(grammar.getName() + "." + rule.getName(), rule)); } List<IEObjectDescription> result = Lists.newArrayList( EObjectDescription.create(SUPER + "." + rule.getName(), rule), EObjectDescription.create(GrammarUtil.getSimpleName(grammar) + "." + rule.getName(), rule), EObjectDescription.create(grammar.getName() + "." + rule.getName(), rule)); AbstractRule contextRule = GrammarUtil.containingRule(context); if (contextRule != null && contextRule.getName().equals(rule.getName())) { result.add(0, EObjectDescription.create(SUPER, rule)); } return result; } return Collections.emptyList(); }
Example #21
Source File: ValidationJobSchedulerTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Override public IResourceDescription getResourceDescription(final URI uri) { return new AbstractResourceDescription() { @Override public Iterable<QualifiedName> getImportedNames() { return Collections.emptyList(); } @Override public Iterable<IReferenceDescription> getReferenceDescriptions() { return Collections.emptyList(); } @Override public URI getURI() { return uri; } @Override protected List<IEObjectDescription> computeExportedObjects() { return Collections.singletonList(EObjectDescription.create(exportedName, EcoreFactory.eINSTANCE.createEObject())); } }; }
Example #22
Source File: FormatResourceDescriptionStrategy.java From dsl-devkit with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ @Override public boolean createEObjectDescriptions(final EObject eObject, final IAcceptor<IEObjectDescription> acceptor) { if (eObject instanceof XBlockExpression || isXbaseLocalVariableName(eObject)) { return false; } boolean indexObject = false; boolean indexDefault = false; String objectFingerprint = null; if (fingerprintComputer != null && eObject.eContainer() instanceof FormatConfiguration && NodeModelUtils.getNode(eObject) != null) { objectFingerprint = fingerprintComputer.computeFingerprint(eObject); } if (objectFingerprint != null && !"".equals(objectFingerprint) && eObject.eContainer() instanceof FormatConfiguration) { acceptor.accept(EObjectDescription.create(objectFingerprint, eObject)); indexObject = true; } indexDefault = createDescriptionsForNonXbaseFormalParameters(eObject, acceptor); return indexDefault || indexObject; }
Example #23
Source File: RuleOverrideUtil.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
public List<IEObjectDescription> getOverriddenRules(final AbstractRule originalRule) { Grammar grammar = GrammarUtil.getGrammar(originalRule); final List<IEObjectDescription> overriddenRules = newArrayList(); IAcceptor<AbstractRule> acceptor = new IAcceptor<AbstractRule>() { @Override public void accept(AbstractRule overriddenRule) { if (overriddenRule != null) { IEObjectDescription description = EObjectDescription.create( qualifiedNameProvider.getFullyQualifiedName(overriddenRule), overriddenRule); overriddenRules.add(description); } } }; findOverriddenRule(originalRule, grammar.getUsedGrammars(), acceptor); return overriddenRules; }
Example #24
Source File: EObjectDescriptionBasedStubGeneratorTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
@Test public void testStubGenerator() throws Exception { EObjectDescription _class = new EObjectDescription(QualifiedName.create("foo","Bar"), TypesFactory.eINSTANCE.createJvmGenericType(), Collections.<String,String>emptyMap()); EObjectDescription _class_with_typeParam = new EObjectDescription(QualifiedName.create("foo","Bar"), TypesFactory.eINSTANCE.createJvmGenericType(), Collections.singletonMap(JvmTypesResourceDescriptionStrategy.TYPE_PARAMETERS, "<A,B>")); EObjectDescription _nested_class = new EObjectDescription(QualifiedName.create("foo","Bar$Baz"), TypesFactory.eINSTANCE.createJvmGenericType(), Collections.singletonMap(JvmTypesResourceDescriptionStrategy.IS_NESTED_TYPE, Boolean.TRUE.toString())); EObjectDescription _interface = new EObjectDescription(QualifiedName.create("foo","Bar"), TypesFactory.eINSTANCE.createJvmGenericType(), Collections.singletonMap(JvmTypesResourceDescriptionStrategy.IS_INTERFACE, Boolean.TRUE.toString())); EObjectDescription _enum = new EObjectDescription(QualifiedName.create("foo","Bar"), TypesFactory.eINSTANCE.createJvmEnumerationType(), Collections.<String,String>emptyMap()); EObjectDescription _annotation = new EObjectDescription(QualifiedName.create("foo","Bar"), TypesFactory.eINSTANCE.createJvmAnnotationType(), Collections.<String,String>emptyMap()); IResourceDescription emptyResource = BuilderStateFactory.eINSTANCE.createResourceDescription(); assertEquals("package foo;\npublic class Bar{\n}",gen.getJavaStubSource(_class, emptyResource)); assertEquals("package foo;\npublic class Bar<A,B>{\n}",gen.getJavaStubSource(_class_with_typeParam, emptyResource)); assertNull(gen.getJavaStubSource(_nested_class, emptyResource)); assertEquals("package foo;\npublic interface Bar{\n}",gen.getJavaStubSource(_interface, emptyResource)); assertEquals("package foo;\npublic enum Bar{\n}",gen.getJavaStubSource(_enum, emptyResource)); assertEquals("package foo;\npublic @interface Bar{\n}",gen.getJavaStubSource(_annotation, emptyResource)); }
Example #25
Source File: StatefulResourceDescription.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
protected ImmutableList<IEObjectDescription> copyExportedObjects(IResourceDescription original) { return ImmutableList.copyOf(Iterables.filter(Iterables.transform(original.getExportedObjects(), new Function<IEObjectDescription, IEObjectDescription>() { @Override public IEObjectDescription apply(IEObjectDescription from) { if (from == null) return null; EObject proxy = from.getEObjectOrProxy(); if (proxy == null) return null; if (proxy.eIsProxy()) return from; InternalEObject result = (InternalEObject) EcoreUtil.create(from.getEClass()); result.eSetProxyURI(EcoreUtil.getURI(from.getEObjectOrProxy())); Map<String, String> userData = null; for(String key: from.getUserDataKeys()) { if (userData == null) { userData = Maps.newHashMapWithExpectedSize(2); } userData.put(key, from.getUserData(key)); } return EObjectDescription.create(from.getName(), result, userData); } }), Predicates.notNull())); }
Example #26
Source File: CopiedResourceDescription.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
public CopiedResourceDescription(IResourceDescription original) { this.uri = original.getURI(); this.exported = ImmutableList.copyOf(Iterables.transform(original.getExportedObjects(), new Function<IEObjectDescription, IEObjectDescription>() { @Override public IEObjectDescription apply(IEObjectDescription from) { if (from.getEObjectOrProxy().eIsProxy()) { return from; } InternalEObject result = (InternalEObject) EcoreUtil.create(from.getEClass()); result.eSetProxyURI(from.getEObjectURI()); Map<String, String> userData = null; for (final String key : from.getUserDataKeys()) { if (userData == null) { userData = Maps.newHashMapWithExpectedSize(2); } userData.put(key, from.getUserData(key)); } return EObjectDescription.create(from.getName(), result, userData); } })); }
Example #27
Source File: ScopeTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override protected Iterable<IEObjectDescription> getAllLocalElements() { return new Iterable<IEObjectDescription>() { @Override public Iterator<IEObjectDescription> iterator() { numberOfCalls++; return singleton( (IEObjectDescription) new EObjectDescription(QualifiedName.create(name), EcorePackage.Literals.EATTRIBUTE, null)).iterator(); } @Override public String toString() { try { return Iterables.toString(this); } finally { numberOfCalls--; } } }; }
Example #28
Source File: KnownTypesScope.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
@Override protected IEObjectDescription doGetSingleElement(QualifiedName name, String firstSegment, int dollarIndex) { int index = -1; JvmType result = null; for(int i = 0; i < types.size(); i++) { JvmType type = types.get(i); JvmType exactMatch = getExactMatch(type, index, name); if (exactMatch != null) return EObjectDescription.create(name, exactMatch); if (isMatch(i, type, firstSegment, name)) { JvmType resolved = getUnambiguousResult(result, index, type, i, name); if (resolved == null) { return null; } if (resolved != result) { result = resolved; index = i; } } } return toDescription(name, result, dollarIndex, index); }
Example #29
Source File: NestedTypeLiteralScope.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override protected List<IEObjectDescription> getLocalElementsByName(QualifiedName name) { XAbstractFeatureCall featureCall = getFeatureCall(); if (featureCall.isExplicitOperationCallOrBuilderSyntax()) return Collections.emptyList(); if (rawEnclosingType instanceof JvmDeclaredType && name.getSegmentCount() == 1) { String singleSegment = name.getFirstSegment(); List<String> lookup = Collections.singletonList(singleSegment); if (singleSegment.indexOf('$') != -1) { lookup = Strings.split(singleSegment, '$'); } JvmType result = findNestedType((JvmDeclaredType)rawEnclosingType, lookup.iterator()); if (result != null) { IEObjectDescription description = EObjectDescription.create(name, result); return Collections.<IEObjectDescription>singletonList(new TypeLiteralDescription(description, enclosingType, isVisible(result))); } } return Collections.emptyList(); }
Example #30
Source File: KnownTypesScope.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override protected IEObjectDescription toDescription(QualifiedName name, JvmType result, int dollarIndex, int index) { if (result != null) { JvmType actualResult = dollarIndex > 0 || name.getSegmentCount() > 0 ? findNestedType(result, index, name) : result; if (actualResult != null) { return EObjectDescription.create(name, actualResult); } } return null; }