/** * @param resolvedTypes the currently known resolved types */ public IScope createTypeScope(EObject context, EReference reference, IFeatureScopeSession session, IResolvedTypes resolvedTypes) { final IScope delegateScope = getDelegate().getScope(context, reference); return new NestedTypesScope(delegateScope, session); }
protected IScope createTypeScope(EObject context, EReference reference, IResolvedTypes resolvedTypes) { return getTypeScopes().createTypeScope(context, reference, this, resolvedTypes); }
@Override public IScope getScope(EObject context, EReference reference, IResolvedTypes types) { if (getFeatureScopes().isFeatureCallScope(reference)) { return createFeatureCallScope(context, reference, types); } else if (getConstructorScopes().isConstructorCallScope(reference)) { return createConstructorScope(context, reference, types); } else if (getTypeScopes().isTypeScope(reference)) { return createTypeScope(context, reference, types); } else { return getDefaultScopeProvider().getScope(context, reference); } }
@Override public void setWrapper(IScopeWrapper wrapper) { IDelegatingScopeProvider.setWrapper(typeScopes.getDelegate(), wrapper); IDelegatingScopeProvider.super.setWrapper(wrapper); }
/** * Creates the constructor scope for {@link XConstructorCall}. * The scope will likely contain descriptions for {@link JvmConstructor constructors}. * If there is not constructor declared, it may contain {@link JvmType types}. * * @param session the currently available visibilityHelper data * @param reference the reference that will hold the resolved constructor * @param resolvedTypes the currently known resolved types */ public IScope createConstructorScope(EObject context, EReference reference, IFeatureScopeSession session, IResolvedTypes resolvedTypes) { if (!(context instanceof XConstructorCall)) { return IScope.NULLSCOPE; } /* * We use a type scope here in order to provide better feedback for users, * e.g. if the constructor call refers to an interface or a primitive. */ final IScope delegateScope = typeScopes.createTypeScope(context, TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, session, resolvedTypes); IScope result = new ConstructorTypeScopeWrapper(context, session, delegateScope); return result; }
final Map<Key<?>, Binding<?>> bindings = this.originalInjector.getBindings(); Injector localInjector = CodeBuilderFactory.createOverridingInjector(this.originalInjector, (binder) -> binder.bind(AbstractTypeScopeProvider.class).toInstance(AbstractSourceAppender.this.scopeProvider)); final IScopeProvider oldDelegate = this.typeScopes.getDelegate(); localInjector.injectMembers(this.typeScopes); try {
return typeScopes.createTypeScope(context, reference);
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; } }