org.eclipse.xtext.resource.ISelectable Java Examples
The following examples show how to use
org.eclipse.xtext.resource.ISelectable.
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: UserDataAwareScope.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Factory method to produce a scope. The factory pattern allows to bypass the explicit object creation if the * produced scope would be empty. * * @param canLoadFromDescriptionHelper * utility to decide if a resource must be loaded from source or may be loaded from the index. */ public static IScope createScope( IScope outer, ISelectable selectable, Predicate<IEObjectDescription> filter, EClass type, boolean ignoreCase, ResourceSet resourceSet, CanLoadFromDescriptionHelper canLoadFromDescriptionHelper, IContainer container) { if (selectable == null || selectable.isEmpty()) return outer; IScope scope = new UserDataAwareScope(outer, selectable, filter, type, ignoreCase, resourceSet, canLoadFromDescriptionHelper, container); return scope; }
Example #2
Source File: ImportScope.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override protected Iterable<IEObjectDescription> getLocalElementsByName(QualifiedName name) { List<IEObjectDescription> result = newArrayList(); QualifiedName resolvedQualifiedName = null; ISelectable importFrom = getImportFrom(); for (ImportNormalizer normalizer : normalizers) { final QualifiedName resolvedName = normalizer.resolve(name); if (resolvedName != null) { Iterable<IEObjectDescription> resolvedElements = importFrom.getExportedObjects(type, resolvedName, isIgnoreCase()); for (IEObjectDescription resolvedElement : resolvedElements) { if (resolvedQualifiedName == null) resolvedQualifiedName = resolvedName; else if (!resolvedQualifiedName.equals(resolvedName)) { if (result.get(0).getEObjectOrProxy() != resolvedElement.getEObjectOrProxy()) { return emptyList(); } } QualifiedName alias = normalizer.deresolve(resolvedElement.getName()); if (alias == null) throw new IllegalStateException("Couldn't deresolve " + resolvedElement.getName() + " with import " + normalizer); final AliasedEObjectDescription aliasedEObjectDescription = new AliasedEObjectDescription(alias, resolvedElement); result.add(aliasedEObjectDescription); } } } return result; }
Example #3
Source File: DefaultUniqueNameContext.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
public DefaultUniqueNameContext(IResourceDescription resourceDescription, ISelectable validationScope, ICaseInsensitivityHelper caseInsensitivityHelper, CancelIndicator cancelIndicator) { this.resourceDescription = resourceDescription; this.validationScope = validationScope; this.caseInsensitivityHelper = caseInsensitivityHelper; this.cancelIndicator = cancelIndicator; }
Example #4
Source File: AbstractCompoundSelectable.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public Iterable<IEObjectDescription> getExportedObjects() { return Iterables.concat(Iterables.transform(getSelectables(), new Function<ISelectable, Iterable<IEObjectDescription>>() { @Override public Iterable<IEObjectDescription> apply(ISelectable from) { if (from != null) return from.getExportedObjects(); return Collections.emptyList(); } })); }
Example #5
Source File: AbstractCompoundSelectable.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public Iterable<IEObjectDescription> getExportedObjectsByObject(final EObject object) { return Iterables.concat(Iterables.transform(getSelectables(), new Function<ISelectable, Iterable<IEObjectDescription>>() { @Override public Iterable<IEObjectDescription> apply(ISelectable from) { if (from != null) return from.getExportedObjectsByObject(object); return Collections.emptyList(); } })); }
Example #6
Source File: AbstractCompoundSelectable.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public Iterable<IEObjectDescription> getExportedObjects(final EClass type, final QualifiedName qualifiedName, final boolean ignoreCase) { return Iterables.concat(Iterables.transform(getSelectables(), new Function<ISelectable, Iterable<IEObjectDescription>>() { @Override public Iterable<IEObjectDescription> apply(ISelectable from) { if (from != null) return from.getExportedObjects(type, qualifiedName, ignoreCase); return Collections.emptyList(); } })); }
Example #7
Source File: LiveShadowedResourceDescriptions.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public Iterable<IEObjectDescription> getExportedObjects() { return Iterables.concat(Iterables.transform(getAllResourceDescriptions(), new Function<ISelectable, Iterable<IEObjectDescription>>() { @Override public Iterable<IEObjectDescription> apply(ISelectable from) { if (from != null) return from.getExportedObjects(); return ImmutableSet.of(); } })); }
Example #8
Source File: SimpleLocalScopeProvider.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public IScope getScope(final EObject context, final EReference reference) { ISelectable resourceContent = cache.get(Tuples.pair(SimpleLocalScopeProvider.class.getName(), reference), context.eResource(), new Provider<ISelectable>() { @Override public ISelectable get() { return getAllDescriptions(context.eResource()); } }); IScope globalScope = getGlobalScope(context.eResource(), reference); return createScope(globalScope, resourceContent, reference.getEReferenceType(), isIgnoreCase(reference)); }
Example #9
Source File: SimpleLocalScopeProvider.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected ISelectable getAllDescriptions(final Resource resource) { Iterable<EObject> allContents = new Iterable<EObject>(){ @Override public Iterator<EObject> iterator() { return resource.getAllContents(); } }; Iterable<IEObjectDescription> allDescriptions = Scopes.scopedElementsFor(allContents, qualifiedNameProvider); return new MultimapBasedSelectable(allDescriptions); }
Example #10
Source File: ImportScope.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
public ImportScope(List<ImportNormalizer> namespaceResolvers, IScope parent, ISelectable importFrom, EClass type, boolean ignoreCase) { super(parent, ignoreCase); this.type = type; this.normalizers = removeDuplicates(namespaceResolvers); this.importFrom = importFrom; }
Example #11
Source File: AbstractCompoundSelectable.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public Iterable<IEObjectDescription> getExportedObjectsByType(final EClass type) { return Iterables.concat(Iterables.transform(getSelectables(), new Function<ISelectable, Iterable<IEObjectDescription>>() { @Override public Iterable<IEObjectDescription> apply(ISelectable from) { if (from != null) return from.getExportedObjectsByType(type); return Collections.emptyList(); } })); }
Example #12
Source File: ImportScope.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected ISelectable getImportFrom() { ISelectable importFrom = this.importFrom; if (importFrom == null) { importFrom = new ScopeBasedSelectable(getParent()); } return importFrom; }
Example #13
Source File: ImportedNamespaceAwareLocalScopeProvider.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected IScope getResourceScope(final IScope parent, final EObject context, final EReference reference) { // TODO: SZ - context may not be a proxy, may it? if (context.eResource() == null) return parent; ISelectable allDescriptions = getAllDescriptions(context.eResource()); return SelectableBasedScope.createScope(parent, allDescriptions, reference.getEReferenceType(), isIgnoreCase(reference)); }
Example #14
Source File: ImportedNamespaceAwareLocalScopeProvider.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected ISelectable getAllDescriptions(final Resource resource) { return cache.get("internalGetAllDescriptions", resource, new Provider<ISelectable>() { @Override public ISelectable get() { return internalGetAllDescriptions(resource); } }); }
Example #15
Source File: ImportedNamespaceAwareLocalScopeProvider.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected ISelectable internalGetAllDescriptions(final Resource resource) { Iterable<EObject> allContents = new Iterable<EObject>(){ @Override public Iterator<EObject> iterator() { return EcoreUtil.getAllContents(resource, false); } }; Iterable<IEObjectDescription> allDescriptions = Scopes.scopedElementsFor(allContents, qualifiedNameProvider); return new MultimapBasedSelectable(allDescriptions); }
Example #16
Source File: ResourceDescriptionsBasedContainerTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Before public void setUp() throws Exception { eClass = EcoreFactory.eINSTANCE.createEClass(); eClass.setName("SomeName"); uri = URI.createURI("myURI"); ((InternalEObject)eClass).eSetProxyURI(uri.appendFragment("SomeName")); resourceDescription = new ResourceDescription(uri); container = createContainer(); selectableDelegate = new AbstractCompoundSelectable() { @Override protected Iterable<? extends ISelectable> getSelectables() { return getAllResourceDescriptions(); } }; }
Example #17
Source File: GamlScopeProvider.java From gama with GNU General Public License v3.0 | 5 votes |
@Override protected ISelectable getAllDescriptions(final Resource resource) { final GamlMultimapBasedSelectable result = new GamlMultimapBasedSelectable(); final IQualifiedNameProvider provider = getNameProvider(); final Iterator<EObject> iterator = resource.getAllContents(); while (iterator.hasNext()) { final EObject from = iterator.next(); final QualifiedName qualifiedName = provider.apply(from); if (qualifiedName != null) { result.add(qualifiedName, new EObjectDescription(qualifiedName, from, null)); } } return result; }
Example #18
Source File: SARLImportedNamespaceScopeProvider.java From sarl with Apache License 2.0 | 5 votes |
@Override protected ISelectable internalGetAllDescriptions(final Resource resource) { final List<IEObjectDescription> descriptions = Lists.newArrayList(); for (final EObject content: resource.getContents()) { if (content instanceof JvmDeclaredType) { // Begin fixing of issue #356. final JvmDeclaredType type = (JvmDeclaredType) content; if (!Strings.isNullOrEmpty(type.getIdentifier())) { // End of fixing doGetAllDescriptions(type, descriptions); } } } return new MultimapBasedSelectable(descriptions); }
Example #19
Source File: NamesAreUniqueValidationHelper.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.22 */ protected void doCheckUniqueIn(IEObjectDescription description, Context context, ValidationMessageAcceptor acceptor) { EObject object = description.getEObjectOrProxy(); Preconditions.checkArgument(!object.eIsProxy()); EClass clusterType = getClusterType(description); if (clusterType == null) { return; } ISelectable validationScope = context.getValidationScope(description, clusterType); if (validationScope.isEmpty()) { return; } boolean caseSensitive = context.isCaseSensitive(object, clusterType); Iterable<IEObjectDescription> sameNames = validationScope.getExportedObjects(clusterType, description.getName(), !caseSensitive); if (sameNames instanceof Collection<?>) { if (((Collection<?>) sameNames).size() <= 1) { return; } } for (IEObjectDescription candidate : sameNames) { EObject otherObject = candidate.getEObjectOrProxy(); if (object != otherObject && getAssociatedClusterType(candidate.getEClass()) == clusterType && !otherObject.eIsProxy() || !candidate.getEObjectURI().equals(description.getEObjectURI())) { if (isDuplicate(description, candidate)) { createDuplicateNameError(description, clusterType, acceptor); return; } } } }
Example #20
Source File: XbaseImportedNamespaceScopeProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected ISelectable internalGetAllDescriptions(final Resource resource) { Iterable<EObject> allContents = new Iterable<EObject>(){ @Override public Iterator<EObject> iterator() { return EcoreUtil.getAllContents(resource, false); } }; Iterable<IEObjectDescription> allDescriptions = Scopes.scopedElementsFor(allContents, qualifiedNameProvider); return new MultimapBasedSelectable(allDescriptions); }
Example #21
Source File: XbaseImportedNamespaceScopeProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected ISelectable getAllDescriptions(final Resource resource) { return cache.get("internalGetAllDescriptions", resource, new Provider<ISelectable>() { @Override public ISelectable get() { return internalGetAllDescriptions(resource); } }); }
Example #22
Source File: XImportSectionNamespaceScopeProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected IScope getResourceScope(IScope globalScope, @SuppressWarnings("unused") Resource res, EReference reference) { IScope result = globalScope; ISelectable globalScopeSelectable = new ScopeBasedSelectable(result); // implicit imports (i.e. java.lang.*) List<ImportNormalizer> normalizers = getImplicitImports(isIgnoreCase(reference)); if (!normalizers.isEmpty()) { result = createImportScope(result, normalizers, globalScopeSelectable, reference.getEReferenceType(), isIgnoreCase(reference)); } return result; }
Example #23
Source File: XbaseImportedNamespaceScopeProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected IScope getResourceScope(IScope globalScope, @SuppressWarnings("unused") Resource res, EReference reference) { IScope result = globalScope; ISelectable globalScopeSelectable = new ScopeBasedSelectable(result); // implicit imports (i.e. java.lang.*) List<ImportNormalizer> normalizers = getImplicitImports(isIgnoreCase(reference)); if (!normalizers.isEmpty()) { result = createImportScope(result, normalizers, globalScopeSelectable, reference.getEReferenceType(), isIgnoreCase(reference)); } return result; }
Example #24
Source File: NonResolvingImportScope.java From n4js with Eclipse Public License 1.0 | 5 votes |
@Override protected Iterable<IEObjectDescription> getLocalElementsByName(QualifiedName name) { List<IEObjectDescription> result = newArrayList(); QualifiedName resolvedQualifiedName = null; ISelectable importFrom = getImportFrom(); for (ImportNormalizer normalizer : myNormalizers) { final QualifiedName resolvedName = normalizer.resolve(name); if (resolvedName != null) { Iterable<IEObjectDescription> resolvedElements = importFrom.getExportedObjects(myType, resolvedName, isIgnoreCase()); for (IEObjectDescription resolvedElement : resolvedElements) { if (resolvedQualifiedName == null) resolvedQualifiedName = resolvedName; else if (!resolvedQualifiedName.equals(resolvedName)) { // change is here if (result.get(0).getEObjectURI().equals(resolvedElement.getEObjectURI())) { return emptyList(); } // change is above } QualifiedName alias = normalizer.deresolve(resolvedElement.getName()); if (alias == null) throw new IllegalStateException("Couldn't deresolve " + resolvedElement.getName() + " with import " + normalizer); final AliasedEObjectDescription aliasedEObjectDescription = new AliasedEObjectDescription(alias, resolvedElement); result.add(aliasedEObjectDescription); } } } return result; }
Example #25
Source File: XImportSectionNamespaceScopeProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected ISelectable getAllDescriptions(final Resource resource) { return cache.get("internalGetAllDescriptions", resource, new Provider<ISelectable>() { @Override public ISelectable get() { return internalGetAllDescriptions(resource); } }); }
Example #26
Source File: XImportSectionNamespaceScopeProvider.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected ISelectable internalGetAllDescriptions(final Resource resource) { Iterable<EObject> allContents = new Iterable<EObject>(){ @Override public Iterator<EObject> iterator() { return EcoreUtil.getAllContents(resource, false); } }; Iterable<IEObjectDescription> allDescriptions = Scopes.scopedElementsFor(allContents, qualifiedNameProvider); return new MultimapBasedSelectable(allDescriptions); }
Example #27
Source File: UserDataAwareScope.java From n4js with Eclipse Public License 1.0 | 5 votes |
UserDataAwareScope(IScope outer, ISelectable selectable, Predicate<IEObjectDescription> filter, EClass type, boolean ignoreCase, ResourceSet resourceSet, CanLoadFromDescriptionHelper canLoadFromDescriptionHelper, IContainer container) { super(outer, selectable, filter, type, ignoreCase); this.resourceSet = resourceSet; this.canLoadFromDescriptionHelper = canLoadFromDescriptionHelper; this.container = container; this.type = type; }
Example #28
Source File: DirtyStateAwareResourceDescriptions.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public Iterable<IEObjectDescription> getExportedObjects() { return Iterables.concat(Iterables.transform(getAllResourceDescriptions(), new Function<ISelectable, Iterable<IEObjectDescription>>() { @Override public Iterable<IEObjectDescription> apply(ISelectable from) { if (from != null) return from.getExportedObjects(); return Collections.emptyList(); } })); }
Example #29
Source File: XtendImportedNamespaceScopeProvider.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override protected ISelectable internalGetAllDescriptions(final Resource resource) { List<IEObjectDescription> descriptions = Lists.newArrayList(); for (EObject content: resource.getContents()) { if (content instanceof JvmDeclaredType) { JvmDeclaredType type = (JvmDeclaredType) content; if (!Strings.isEmpty(type.getIdentifier())) { doGetAllDescriptions(type, descriptions); } } } return new MultimapBasedSelectable(descriptions); }
Example #30
Source File: NonResolvingImportScope.java From n4js with Eclipse Public License 1.0 | 4 votes |
public NonResolvingImportScope(List<ImportNormalizer> namespaceResolvers, IScope parent, ISelectable importFrom, EClass type, boolean ignoreCase) { super(namespaceResolvers, parent, importFrom, type, ignoreCase); this.myType = type; }