Java 类org.eclipse.xtext.scoping.impl.MapBasedScope 实例源码

项目:xtext-extras    文件:XbaseWithAnnotationsBatchScopeProvider.java   
@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);
}
项目:statecharts    文件:STextGlobalScopeProvider.java   
/**
 * Overidden to avoid scope nesting which is not required and slows down because
 * of shadowing testing.
 */
@Override
protected IScope getScope(Resource resource, boolean ignoreCase, EClass type,
        Predicate<IEObjectDescription> filter) {
    final LinkedHashSet<URI> uniqueImportURIs = getImportedUris(resource);
    IResourceDescriptions descriptions = getResourceDescriptions(resource, uniqueImportURIs);
    List<URI> urisAsList = Lists.newArrayList(uniqueImportURIs);
    Collections.reverse(urisAsList);
    List<IEObjectDescription> objectDescriptions = new ArrayList<IEObjectDescription>();
    for (URI uri : urisAsList) {
        IScope scope = createLazyResourceScope(IScope.NULLSCOPE, uri, descriptions, type, filter, ignoreCase);
        Iterables.addAll(objectDescriptions, scope.getAllElements());
    }
    return MapBasedScope.createScope(IScope.NULLSCOPE, objectDescriptions);
}
项目:openhab-hdl    文件:ScriptScopeProvider.java   
@Override
public IScope createSimpleFeatureCallScope(EObject context,
        EReference reference, Resource resource,
        boolean includeCurrentBlock, int idx) {
    IScope parent =  super.createSimpleFeatureCallScope(context, reference, resource,
            includeCurrentBlock, idx);
    List<IEObjectDescription> descriptions = new ArrayList<IEObjectDescription>();
    descriptions.addAll(createItemFeatures(resource.getResourceSet()));
    descriptions.addAll(createTypeFeatures(resource.getResourceSet()));

    return MapBasedScope.createScope(parent, descriptions);
}
项目:openhab-hdl    文件:RulesScopeProvider.java   
@Override
protected IScope createLocalVarScope(IScope parentScope,
        LocalVariableScopeContext scopeContext) {
    if(scopeContext.getContext() instanceof Rule) {
        IScope parent = super.createLocalVarScope(parentScope, scopeContext);
        List<IEObjectDescription> descriptions = new ArrayList<IEObjectDescription>();
        descriptions.addAll(createVarFeatures(scopeContext.getContext().eResource()));
        descriptions.addAll(createTriggerSpecificVars((Rule) scopeContext.getContext()));
        return MapBasedScope.createScope(parent, descriptions);
    } else {
        return super.createLocalVarScope(parentScope, scopeContext);
    }
}