protected IScope createStaticExtensionsScope(XExpression receiver, LightweightTypeReference receiverType, EObject featureCall, IScope parent, IFeatureScopeSession session, IResolvedTypes resolvedTypes) { IFeatureScopeSession nextCaptureLayer = session.getNextCaptureLayer(); if (nextCaptureLayer != null) { parent = createStaticExtensionsScope(receiver, receiverType, featureCall, parent, nextCaptureLayer, resolvedTypes); } IScope result = parent; if (receiver == null) { // 'this' is a valid implicit first argument, e.g. implementations of Iterable may use #filter on themselves result = createImplicitExtensionScope(THIS, featureCall, session, resolvedTypes, result); // 'it' has a higher priority than 'this' as implicit first argument result = createImplicitExtensionScope(IT, featureCall, session, resolvedTypes, result); return result; } else { if (receiverType == null) { throw new IllegalStateException("Unknown receiver type"); } result = createStaticExtensionsScope(featureCall, receiver, receiverType, false, parent, session); } return result; }
protected IScope createImplicitExtensionScope(QualifiedName implicitName, EObject featureCall, IFeatureScopeSession session, IResolvedTypes resolvedTypes, IScope parent) { IEObjectDescription thisDescription = session.getLocalElement(implicitName); if (thisDescription != null) { JvmIdentifiableElement thisElement = (JvmIdentifiableElement) thisDescription.getEObjectOrProxy(); LightweightTypeReference type = resolvedTypes.getActualType(thisElement); if (type != null && !type.isUnknown()) { XFeatureCall implicitReceiver = xbaseFactory.createXFeatureCall(); implicitReceiver.setFeature(thisElement); return createStaticExtensionsScope(featureCall, implicitReceiver, type, true, parent, session); } } return parent; }
/** * 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; }
IScope staticExtensionScope = createStaticExtensionsScope(receiver, receiverType, featureCall, staticScope, session, resolvedTypes);