/** * Creates a scope for the local variables that have been registered in the given session. * * @param featureCall the feature call that is currently processed by the scoping infrastructure * @param parent the parent scope. Is never null. * @param session the currently known scope session. Is never null. * @param resolvedTypes may be used by inheritors. */ protected IScope createLocalVariableScope(EObject featureCall, IScope parent, IFeatureScopeSession session, IResolvedTypes resolvedTypes) { return new LocalVariableScope(parent, session, asAbstractFeatureCall(featureCall)); }
/** * Create a composite scope that returns description from multiple other scopes without applying shadowing semantics to then. */ protected CompositeScope createCompositeScope(EObject featureCall, IScope parent, IFeatureScopeSession session) { return new CompositeScope(parent, session, asAbstractFeatureCall(featureCall)); }
/** * Creates a scope for the statically imported features. * * @param featureCall the feature call that is currently processed by the scoping infrastructure * @param parent the parent scope. Is never null. * @param session the currently known scope session. Is never null. */ protected IScope createStaticFeaturesScope(EObject featureCall, IScope parent, IFeatureScopeSession session) { return new StaticImportsScope(parent, session, asAbstractFeatureCall(featureCall)); }
/** * Create a scope that returns types, e.g. for member feature calls that are actually type references like * {@code java.lang.String}. * * @param featureCall the feature call that is currently processed by the scoping infrastructure * @param parentSegments the segments of the fully qualified type name that are already known. The queried element name will be appended to them. * @param parent the parent scope. Is never null. * @param session the currently known scope session. Is never null. */ protected IScope createTypeLiteralScope(EObject featureCall, QualifiedName parentSegments, IScope parent, IFeatureScopeSession session, IResolvedTypes resolvedTypes) { return new TypeLiteralScope(parent, session, asAbstractFeatureCall(featureCall), resolvedTypes, parentSegments); }
/** * A constructor delegate scope provides the descriptions for {@code this()} and {@code super()} * calls in a constructor body. */ protected IScope createConstructorDelegateScope(EObject featureCall, LightweightTypeReference type, IScope parent, IFeatureScopeSession session) { return new ConstructorDelegateScope(parent, type, session, asAbstractFeatureCall(featureCall)); }
/** * Create a scope that returns nested types. * * @param featureCall the feature call that is currently processed by the scoping infrastructure * @param enclosingType the enclosing type including type parameters for the nested type literal scope. * @param rawEnclosingType the raw type that is used to query the nested types. * @param parent the parent scope. Is never null. * @param session the currently known scope session. Is never null. */ protected IScope createNestedTypeLiteralScope( EObject featureCall, LightweightTypeReference enclosingType, JvmDeclaredType rawEnclosingType, IScope parent, IFeatureScopeSession session) { return new NestedTypeLiteralScope(parent, session, asAbstractFeatureCall(featureCall), enclosingType, rawEnclosingType); }
/** * Create a scope that contains dynamic extension features, which are features that are contributed by an instance of a type. * * @param featureCall the feature call that is currently processed by the scoping infrastructure * @param firstArgument an optionally available first argument expression. * @param firstArgumentType optionally the type of the first argument * @param implicitArgument if the argument is an implicit argument or explicitly given (in concrete syntax) * @param parent the parent scope. Is never null. * @param session the currently known scope session. Is never null. */ protected IScope createDynamicExtensionsScope( EObject featureCall, XExpression firstArgument, LightweightTypeReference firstArgumentType, boolean implicitArgument, IScope parent, IFeatureScopeSession session) { return new DynamicExtensionsScope(parent, session, firstArgument, firstArgumentType, implicitArgument, asAbstractFeatureCall(featureCall), operatorMapping); }
/** * Create a scope that contains static extension features, which are features that are contributed statically via an import. * * @param featureCall the feature call that is currently processed by the scoping infrastructure * @param firstArgument an optionally available first argument expression. * @param firstArgumentType optionally the type of the first argument * @param implicitArgument if the argument is an implicit argument or explicitly given (in concrete syntax) * @param parent the parent scope. Is never null. * @param session the currently known scope session. Is never null. */ protected IScope createStaticExtensionsScope( EObject featureCall, XExpression firstArgument, LightweightTypeReference firstArgumentType, boolean implicitArgument, IScope parent, IFeatureScopeSession session) { return new StaticExtensionImportsScope(parent, session, firstArgument, firstArgumentType, implicitArgument, asAbstractFeatureCall(featureCall), operatorMapping); }
/** * Creates a scope for the static features that are exposed by a type that was used, e.g. * {@code java.lang.String.valueOf(1)} where {@code valueOf(1)} is to be linked. * * @param featureCall the feature call that is currently processed by the scoping infrastructure * @param receiver an optionally available receiver expression * @param receiverType the type of the receiver. It may be available even if the receiver itself is null, which indicates an implicit receiver. * @param receiverBucket the types that contribute the static features. * @param parent the parent scope. Is never null. * @param session the currently known scope session. Is never null. */ protected IScope createStaticFeatureOnTypeLiteralScope( EObject featureCall, XExpression receiver, LightweightTypeReference receiverType, TypeBucket receiverBucket, IScope parent, IFeatureScopeSession session) { return new StaticFeatureOnTypeLiteralScope(parent, session, asAbstractFeatureCall(featureCall), receiver, receiverType, receiverBucket, operatorMapping); }
/** * Creates a scope that returns the features of a given receiver type. * * @param featureCall the feature call that is currently processed by the scoping infrastructure * @param receiver an optionally available receiver expression * @param receiverType the type of the receiver. It may be available even if the receiver itself is null, which indicates an implicit receiver. * @param receiverFeature the feature that was linked as the receiver * @param implicitReceiver true if the receiver is an implicit receiver * @param validStatic true if the receiver is valid according the its static flag, e.g an implicit this in a static method is invalid * @param receiverBucket the types that contribute the static features. * @param parent the parent scope. Is never null. * @param session the currently known scope session. Is never null. */ protected IScope createReceiverFeatureScope( EObject featureCall, XExpression receiver, LightweightTypeReference receiverType, JvmIdentifiableElement receiverFeature, boolean implicitReceiver, boolean validStatic, TypeBucket receiverBucket, IScope parent, IFeatureScopeSession session) { return new ReceiverFeatureScope(parent, session, receiver, receiverType, implicitReceiver, asAbstractFeatureCall(featureCall), receiverBucket, receiverFeature, operatorMapping, validStatic); }
protected IScope createTypeLiteralScope(XExpression featureCall, XExpression receiver, IFeatureScopeSession session, IResolvedTypes resolvedTypes, LightweightTypeReference receiverType, JvmIdentifiableElement linkedReceiver) { if (linkedReceiver instanceof JvmDeclaredType) { IFeatureLinkingCandidate candidate = resolvedTypes.getLinkingCandidate(asAbstractFeatureCall(receiver)); if (candidate != null && candidate.isTypeLiteral()) { JvmDeclaredType declaringType = (JvmDeclaredType) linkedReceiver; IScope result = createNestedTypeLiteralScope(featureCall, receiverType, declaringType, IScope.NULLSCOPE, session); result = createStaticFeatureOnTypeLiteralScope(asAbstractFeatureCall(featureCall), declaringType, receiver, receiverType, result, session); return result; } } return null; }
/** * This method serves as an entry point for the content assist scoping for simple feature calls. * @param context the context e.g. a for loop expression, a block or a catch clause */ public IScope createSimpleFeatureCallScope(EObject context, IFeatureScopeSession session, IResolvedTypes resolvedTypes) { IScope root = IScope.NULLSCOPE; if (context instanceof XFeatureCall) { XFeatureCall featureCall = (XFeatureCall) context; if (!featureCall.isExplicitOperationCallOrBuilderSyntax()) { root = createTypeLiteralScope(context, QualifiedName.EMPTY, root, session, resolvedTypes); if (isDefiniteTypeLiteral(featureCall)) { return root; } } } IScope staticImports = createStaticFeaturesScope(context, root, session); IScope staticMembers = createStaticScope(asAbstractFeatureCall(context), null, null, staticImports, session, resolvedTypes); IScope staticExtensions = createStaticExtensionsScope(null, null, context, staticMembers, session, resolvedTypes); // we don't want to use captured instances of 'IT' as dynamic extension implicit argument // thus the dynamic extension scope only works for the *real* local variables IScope dynamicExtensions = createDynamicExtensionsScope(null, null, context, staticExtensions, session, resolvedTypes); IScope localVariables = createImplicitFeatureCallAndLocalVariableScope(context, dynamicExtensions, session, resolvedTypes); return localVariables; }
LightweightTypeReference receiverType = resolvedTypes.getActualType(receiver); if (receiverType != null && !isUnknownReceiverType(receiverType)) { JvmIdentifiableElement linkedReceiver = resolvedTypes.getLinkedFeature(asAbstractFeatureCall(receiver)); boolean typeLiteral = false; IScope root = createTypeLiteralScope(featureCall, receiver, session, resolvedTypes, receiverType, linkedReceiver); IScope staticScope = createStaticScope(asAbstractFeatureCall(featureCall), receiver, receiverType, root, session, resolvedTypes);