Java 类org.eclipse.xtext.resource.ISelectable 实例源码

项目:n4js    文件:UserDataAwareScope.java   
/**
 * 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;
}
项目:gama    文件:GamlScopeProvider.java   
@Override
protected ISelectable getAllDescriptions(final Resource resource) {
    List<IEObjectDescription> descriptions = null;
    final Iterator<EObject> iterator = resource.getAllContents();
    while (iterator.hasNext()) {
        final EObject from = iterator.next();
        final QualifiedName qualifiedName = getNameProvider().apply(from);
        if (qualifiedName != null) {
            if (descriptions == null)
                descriptions = new ArrayList<>();
            descriptions.add(new EObjectDescription(qualifiedName, from, null));
        }
    }
    return new MultimapBasedSelectable(descriptions);

}
项目:CooperateModelingEnvironment    文件:DuplicateImportScope.java   
@Override
protected Iterable<IEObjectDescription> getLocalElementsByName(QualifiedName name) {
    List<IEObjectDescription> result = newArrayList();
    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) {
                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;
}
项目:CooperateModelingEnvironment    文件:CooperateImportedNamespaceAwareLocalScopeProvider.java   
@Override
protected ISelectable internalGetAllDescriptions(Resource resource) {
    Iterable<EObject> allContents = new Iterable<EObject>() {
        @Override
        public Iterator<EObject> iterator() {
            return EcoreUtil.getAllContents(resource, false);
        }
    };
    Iterable<IEObjectDescription> allDescriptions = Scopes.scopedElementsFor(allContents,
            this.getQualifiedNameProvider());

    Iterable<IEObjectDescription> allAliasedDescriptions = new Iterable<IEObjectDescription>() {
        @Override
        public Iterator<IEObjectDescription> iterator() {
            return Streams.stream(allDescriptions)
                    .map(CooperateImportedNamespaceAwareLocalScopeProvider::createAliasedDescription).iterator();
        }
    };

    return new MultimapBasedSelectable(allAliasedDescriptions);
}
项目:n4js    文件:UserDataAwareScope.java   
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;
}
项目:xtext-extras    文件:XbaseImportedNamespaceScopeProvider.java   
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;
}
项目:xtext-extras    文件:XbaseImportedNamespaceScopeProvider.java   
protected ISelectable getAllDescriptions(final Resource resource) {
    return cache.get("internalGetAllDescriptions", resource, new Provider<ISelectable>() {
        @Override
        public ISelectable get() {
            return internalGetAllDescriptions(resource);
        }
    });
}
项目:xtext-extras    文件:XbaseImportedNamespaceScopeProvider.java   
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);
}
项目:xtext-extras    文件:XImportSectionNamespaceScopeProvider.java   
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;
}
项目:xtext-extras    文件:XImportSectionNamespaceScopeProvider.java   
protected ISelectable getAllDescriptions(final Resource resource) {
    return cache.get("internalGetAllDescriptions", resource, new Provider<ISelectable>() {
        @Override
        public ISelectable get() {
            return internalGetAllDescriptions(resource);
        }
    });
}
项目:xtext-extras    文件:XImportSectionNamespaceScopeProvider.java   
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);
}
项目:xtext-core    文件:AbstractCompoundSelectable.java   
@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();
        }
    }));
}
项目:xtext-core    文件:AbstractCompoundSelectable.java   
@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();
        }
    }));
}
项目:xtext-core    文件:AbstractCompoundSelectable.java   
@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();
        }
    }));
}
项目:xtext-core    文件:AbstractCompoundSelectable.java   
@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();
        }
    }));
}
项目:xtext-core    文件:LiveShadowedResourceDescriptions.java   
@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();
        }
    }));
}
项目:xtext-core    文件:SimpleLocalScopeProvider.java   
@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));
}
项目:xtext-core    文件:SimpleLocalScopeProvider.java   
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);
}
项目:xtext-core    文件:ImportScope.java   
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;
}
项目:xtext-core    文件:ImportScope.java   
@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;
}
项目:xtext-core    文件:ImportScope.java   
protected ISelectable getImportFrom() {
    ISelectable importFrom = this.importFrom;
    if (importFrom == null) {
        importFrom = new ScopeBasedSelectable(getParent());
    }
    return importFrom;
}
项目:xtext-core    文件:ImportedNamespaceAwareLocalScopeProvider.java   
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));
}
项目:xtext-core    文件:ImportedNamespaceAwareLocalScopeProvider.java   
protected ISelectable getAllDescriptions(final Resource resource) {
    return cache.get("internalGetAllDescriptions", resource, new Provider<ISelectable>() {
        @Override
        public ISelectable get() {
            return internalGetAllDescriptions(resource);
        }
    });
}
项目:xtext-core    文件:ImportedNamespaceAwareLocalScopeProvider.java   
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);
}
项目:xtext-core    文件:ResourceDescriptionsBasedContainerTest.java   
@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();
        }
    };
}
项目:n4js    文件:EagerResourceSetBasedResourceDescriptions.java   
@Override
protected Iterable<? extends ISelectable> getSelectables() {
    return getAllResourceDescriptions();
}
项目:n4js    文件:PolyfillAwareSelectableBasedScope.java   
/**
 * Delegates to super constructor.
 */
protected PolyfillAwareSelectableBasedScope(IScope outer, ISelectable selectable,
        Predicate<IEObjectDescription> filter, EClass type, boolean ignoreCase) {
    super(outer, selectable, filter, type, ignoreCase);
}
项目:n4js    文件:MainModuleAwareSelectableBasedScope.java   
/**
 * Creates new scope with given ISelectable.
 */
public static IScope createMainModuleAwareScope(IScope parent, ISelectable selectable,
        EClass type) {
    return new MainModuleAwareSelectableBasedScope(parent, selectable, null, type, true);
}
项目:n4js    文件:MainModuleAwareSelectableBasedScope.java   
/**
 * Delegates to super constructor.
 */
protected MainModuleAwareSelectableBasedScope(IScope outer, ISelectable selectable,
        Predicate<IEObjectDescription> filter, EClass type, boolean ignoreCase) {
    super(outer, selectable, filter, type, ignoreCase);
}
项目:xtext-extras    文件:XImportSectionNamespaceScopeProvider.java   
protected ImportScope createImportScope(IScope parent, List<ImportNormalizer> namespaceResolvers, ISelectable importFrom, EClass type, boolean ignoreCase) {
    if (importFrom == null)
        throw new NullPointerException("importFrom");

    return new ImportScope(namespaceResolvers, parent, importFrom, type, ignoreCase);
}
项目:xtext-core    文件:ResourceSetBasedResourceDescriptions.java   
@Override
protected Iterable<? extends ISelectable> getSelectables() {
    return getAllResourceDescriptions();
}
项目:xtext-core    文件:EagerResourceSetBasedResourceDescriptions.java   
@Override
protected Iterable<? extends ISelectable> getSelectables() {
    return getAllResourceDescriptions();
}
项目:xtext-core    文件:SimpleLocalScopeProvider.java   
protected IScope createScope(IScope parent, ISelectable resourceContent, EClass type, boolean ignoreCase) {
    return SelectableBasedScope.createScope(parent, resourceContent, type, ignoreCase);
}
项目:xtext-core    文件:SelectableBasedScope.java   
public static IScope createScope(IScope outer, ISelectable selectable, EClass type, boolean ignoreCase) {
    return createScope(outer, selectable, null, type, ignoreCase);
}
项目:xtext-core    文件:SelectableBasedScope.java   
public static IScope createScope(IScope outer, ISelectable selectable, Predicate<IEObjectDescription> filter, EClass type, boolean ignoreCase) {
    if (selectable == null || selectable.isEmpty())
        return outer;
    return new SelectableBasedScope(outer, selectable, filter, type, ignoreCase);
}
项目:xtext-core    文件:SelectableBasedScope.java   
protected SelectableBasedScope(IScope outer, ISelectable selectable, Predicate<IEObjectDescription> filter, EClass type, boolean ignoreCase) {
    super(outer, ignoreCase);
    this.filter = filter;
    this.selectable = selectable;
    this.type = type;
}
项目:xtext-core    文件:SelectableBasedScope.java   
protected ISelectable getSelectable() {
    return selectable;
}
项目:xtext-core    文件:LoadOnDemandResourceDescriptions.java   
@Override
protected Iterable<? extends ISelectable> getSelectables() {
    return getAllResourceDescriptions();
}
项目:xtext-core    文件:ImportedNamespaceAwareLocalScopeProvider.java   
protected ImportScope createImportScope(IScope parent, List<ImportNormalizer> namespaceResolvers, ISelectable importFrom, EClass type, boolean ignoreCase) {
    return new ImportScope(namespaceResolvers, parent, importFrom, type, ignoreCase);
}
项目:xtext-core    文件:ChunkedResourceDescriptions.java   
@Override
protected Iterable<? extends ISelectable> getSelectables() {
  return this.chunk2resourceDescriptions.values();
}