public StaticFeatureDescriptionWithImplicitReceiver(QualifiedName qualifiedName, JvmFeature feature, LightweightTypeReference receiverType, int bucketId, boolean visible) { super(qualifiedName, feature, bucketId, visible); this.implicitReceiverType = receiverType; this.implicitReceiver = XbaseFactory.eINSTANCE.createXFeatureCall(); }
protected IFeatureScopeSession addExtensionsToMemberSession(ResolvedTypes resolvedTypes, IFeatureScopeSession featureScopeSession, JvmDeclaredType type) { IEObjectDescription thisDescription = featureScopeSession.getLocalElement(IFeatureNames.THIS); if (thisDescription == null) { throw new IllegalStateException("Cannot find feature 'THIS'"); } JvmIdentifiableElement thisFeature = (JvmIdentifiableElement) thisDescription.getEObjectOrProxy(); IFeatureScopeSession childSession = addExtensionFieldsToMemberSession( resolvedTypes, featureScopeSession, type, thisFeature, Sets.<String>newHashSetWithExpectedSize(8), Sets.<JvmType>newHashSetWithExpectedSize(4)); XFeatureCall thisAccess = getXbaseFactory().createXFeatureCall(); thisAccess.setFeature(thisFeature); LightweightTypeReference thisType = resolvedTypes.getActualType(thisFeature); childSession = childSession.addToExtensionScope(Collections.<XExpression, LightweightTypeReference>singletonMap(thisAccess, thisType)); return childSession; }
@Override public void addExtensionsToCurrentScope(List<? extends JvmIdentifiableElement> extensionProviders) { if (extensionProviders.isEmpty()) return; if (extensionProviders.size() == 1) { addExtensionToCurrentScope(extensionProviders.get(0)); return; } Map<XExpression, LightweightTypeReference> prototypeToType = Maps2.newLinkedHashMapWithExpectedSize(extensionProviders.size()); for(JvmIdentifiableElement extensionProvider: extensionProviders) { LightweightTypeReference knownType = getResolvedTypes().getActualType(extensionProvider); if (knownType != null && !knownType.isAny() && !knownType.isUnknown()) { XFeatureCall prototype = getResolver().getXbaseFactory().createXFeatureCall(); prototype.setFeature(extensionProvider); prototypeToType.put(prototype, knownType); } } if (!prototypeToType.isEmpty()) featureScopeSession = featureScopeSession.addToExtensionScope(prototypeToType); }
/** Create a reference to "this" object or to the current type. * * @return the reference. */ public XFeatureCall createReferenceToThis() { final XExpression expr = getXExpression(); XtendTypeDeclaration type = EcoreUtil2.getContainerOfType(expr, XtendTypeDeclaration.class); JvmType jvmObject = getAssociatedElement(JvmType.class, type, expr.eResource()); final XFeatureCall thisFeature = XbaseFactory.eINSTANCE.createXFeatureCall(); thisFeature.setFeature(jvmObject); return thisFeature; }
protected XAbstractFeatureCall createExtensionProvider(JvmIdentifiableElement thisFeature, JvmField field) { if (field.isStatic()) { XFeatureCall extensionProvider = getXbaseFactory().createXFeatureCall(); extensionProvider.setFeature(field); return extensionProvider; } else { XMemberFeatureCall extensionProvider = getXbaseFactory().createXMemberFeatureCall(); extensionProvider.setFeature(field); XFeatureCall thisAccess = getXbaseFactory().createXFeatureCall(); thisAccess.setFeature(thisFeature); extensionProvider.setMemberCallTarget(thisAccess); return extensionProvider; } }
@Override public void addExtensionToCurrentScope(JvmIdentifiableElement extensionProvider) { LightweightTypeReference knownType = getResolvedTypes().getActualType(extensionProvider); if (knownType != null && !knownType.isAny() && !knownType.isUnknown()) { XFeatureCall prototype = getResolver().getXbaseFactory().createXFeatureCall(); prototype.setFeature(extensionProvider); featureScopeSession = featureScopeSession.addToExtensionScope(Collections.<XExpression, LightweightTypeReference>singletonMap(prototype, knownType)); } }
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; }
protected IScope createDynamicExtensionsScope(QualifiedName implicitFirstArgumentName, IEObjectDescription firstArgumentDescription, EObject featureCall, IFeatureScopeSession captureLayer, IFeatureScopeSession session, IResolvedTypes resolvedTypes, IScope parent) { JvmIdentifiableElement feature = (JvmIdentifiableElement) firstArgumentDescription.getEObjectOrProxy(); if (feature instanceof JvmType && THIS.equals(implicitFirstArgumentName) && !session.isInstanceContext()) { return parent; } LightweightTypeReference type = resolvedTypes.getActualType(feature); if (type != null && !type.isUnknown()) { XFeatureCall implicitArgument = xbaseFactory.createXFeatureCall(); implicitArgument.setFeature(feature); return createDynamicExtensionsScope(featureCall, implicitArgument, type, true, parent, captureLayer); } return parent; }
protected IScope createImplicitFeatureCallScope(QualifiedName implicitName, EObject featureCall, IFeatureScopeSession session, IResolvedTypes resolvedTypes, IScope parent) { IEObjectDescription thisDescription = session.getLocalElement(implicitName); if (thisDescription != null) { JvmIdentifiableElement thisElement = (JvmIdentifiableElement) thisDescription.getEObjectOrProxy(); boolean validStaticScope = true; if (thisElement instanceof JvmType && THIS.equals(implicitName) && !session.isInstanceContext()) { validStaticScope = false; } LightweightTypeReference type = resolvedTypes.getActualType(thisElement); if (type !=null && !type.isUnknown()) { XFeatureCall implicitReceiver = xbaseFactory.createXFeatureCall(); implicitReceiver.setFeature(thisElement); return createFeatureScopeForTypeRef(implicitReceiver, type, true, featureCall, session, thisElement, parent, validStaticScope); } } return parent; }
final XFeatureCall call = XbaseFactory.eINSTANCE.createXFeatureCall(); superCall.setXExpression(call); final List<XExpression> arguments = call.getFeatureCallArguments(); for (final IFormalParameterBuilder currentParam : sarlParams) { final XFeatureCall argumentSource = XbaseFactory.eINSTANCE.createXFeatureCall(); arguments.add(argumentSource); currentParam.setReferenceInto(argumentSource);
/** Create the extension provider dedicated to the access to the used capacity functions. * * @param thisFeature the current object. * @param field the extension field. * @return the SARL capacity extension provider, or {@code null}. */ protected XAbstractFeatureCall createSarlCapacityExtensionProvider(JvmIdentifiableElement thisFeature, JvmField field) { // For capacity call redirection if (thisFeature instanceof JvmDeclaredType) { final JvmAnnotationReference capacityAnnotation = this.annotationLookup.findAnnotation(field, ImportedCapacityFeature.class); if (capacityAnnotation != null) { final String methodName = Utils.createNameForHiddenCapacityImplementationCallingMethodFromFieldName( field.getSimpleName()); final JvmOperation callerOperation = findOperation((JvmDeclaredType) thisFeature, methodName); if (callerOperation != null) { final XbaseFactory baseFactory = getXbaseFactory(); final XMemberFeatureCall extensionProvider = baseFactory.createXMemberFeatureCall(); extensionProvider.setFeature(callerOperation); final XFeatureCall thisAccess = baseFactory.createXFeatureCall(); thisAccess.setFeature(thisFeature); extensionProvider.setMemberCallTarget(thisAccess); return extensionProvider; } } } return null; }
/** Create a reference to "super" object or to the super type. * * @return the reference. */ public XFeatureCall createReferenceToSuper() { final XExpression expr = getXExpression(); XtendTypeDeclaration type = EcoreUtil2.getContainerOfType(expr, XtendTypeDeclaration.class); JvmType jvmObject = getAssociatedElement(JvmType.class, type, expr.eResource()); final XFeatureCall superFeature = XbaseFactory.eINSTANCE.createXFeatureCall(); JvmIdentifiableElement feature; if (jvmObject instanceof JvmDeclaredType) { feature = ((JvmDeclaredType) jvmObject).getExtendedClass().getType(); } else { feature = findType(expr, getQualifiedName(type)).getType(); if (feature instanceof JvmDeclaredType) { feature = ((JvmDeclaredType) feature).getExtendedClass().getType(); } else { feature = null; } } if (feature == null) { return null; } superFeature.setFeature(feature); return superFeature; }
final List<XExpression> arguments = call.getMemberCallArguments(); for (final IFormalParameterBuilder currentParam : sarlParams) { final XFeatureCall argumentSource = XbaseFactory.eINSTANCE.createXFeatureCall(); arguments.add(argumentSource); currentParam.setReferenceInto(argumentSource);