Java Code Examples for org.eclipse.xtext.xbase.XAbstractFeatureCall#getActualReceiver()
The following examples show how to use
org.eclipse.xtext.xbase.XAbstractFeatureCall#getActualReceiver() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XbaseValidator.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected void checkIsValidConstructorArgument(XExpression argument, JvmType containerType) { TreeIterator<EObject> iterator = EcoreUtil2.eAll(argument); while(iterator.hasNext()) { EObject partOfArgumentExpression = iterator.next(); if (partOfArgumentExpression instanceof XFeatureCall || partOfArgumentExpression instanceof XMemberFeatureCall) { XAbstractFeatureCall featureCall = (XAbstractFeatureCall) partOfArgumentExpression; XExpression actualReceiver = featureCall.getActualReceiver(); if(actualReceiver instanceof XFeatureCall && ((XFeatureCall)actualReceiver).getFeature() == containerType) { JvmIdentifiableElement feature = featureCall.getFeature(); if (feature != null && !feature.eIsProxy()) { if (feature instanceof JvmField) { if (!((JvmField) feature).isStatic()) error("Cannot refer to an instance field " + feature.getSimpleName() + " while explicitly invoking a constructor", partOfArgumentExpression, null, INVALID_CONSTRUCTOR_ARGUMENT); } else if (feature instanceof JvmOperation) { if (!((JvmOperation) feature).isStatic()) error("Cannot refer to an instance method while explicitly invoking a constructor", partOfArgumentExpression, null, INVALID_CONSTRUCTOR_ARGUMENT); } } } } else if(isLocalClassSemantics(partOfArgumentExpression)) { iterator.prune(); } } }
Example 2
Source File: CreateMemberQuickfixes.java From xtext-xtend with Eclipse Public License 2.0 | 6 votes |
protected LightweightTypeReference getReceiverType(XAbstractFeatureCall featureCall) { XExpression actualReceiver = featureCall.getActualReceiver(); ITypeReferenceOwner owner = new StandardTypeReferenceOwner(services, featureCall); if (actualReceiver == null) { JvmDeclaredType callersType = getCallersType(featureCall); if (callersType != null) return owner.newParameterizedTypeReference(callersType); } else if (actualReceiver instanceof XAbstractFeatureCall && ((XAbstractFeatureCall) actualReceiver).isTypeLiteral()) { JvmType type = (JvmType) ((XAbstractFeatureCall) actualReceiver).getFeature(); ParameterizedTypeReference reference = owner.newParameterizedTypeReference(type); return reference; } else { LightweightTypeReference typeRef = typeResolver.resolveTypes(featureCall).getActualType(actualReceiver); if(typeRef != null && typeRef.getType() instanceof JvmDeclaredType) return typeRef; } return null; }
Example 3
Source File: InvokedResolvedOperation.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected LightweightTypeReference getReceiverType(XAbstractFeatureCall featureCall, IResolvedTypes resolvedTypes, ITypeReferenceOwner owner) { XExpression receiver = featureCall.getActualReceiver(); if (receiver == null) { // static feature call JvmOperation operation = (JvmOperation) featureCall.getFeature(); JvmDeclaredType declaringType = operation.getDeclaringType(); return owner.newParameterizedTypeReference(declaringType); } return resolvedTypes.getActualType(receiver); }
Example 4
Source File: XbaseCopyQualifiedNameService.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected IResolvedExecutable _resolveExecutable(JvmConstructor constructor, XAbstractFeatureCall featureCall, IResolvedTypes resolvedTypes) { XExpression actualReceiver = featureCall.getActualReceiver(); if (actualReceiver != null) { LightweightTypeReference actualType = resolvedTypes.getActualType(actualReceiver); return findDeclaredConstructor(constructor, actualType); } return null; }
Example 5
Source File: XbaseCopyQualifiedNameService.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected IResolvedExecutable _resolveExecutable(JvmOperation operation, XAbstractFeatureCall featureCall, IResolvedTypes resolvedTypes) { XExpression actualReceiver = featureCall.getActualReceiver(); if (actualReceiver != null) { LightweightTypeReference actualType = resolvedTypes.getActualType(actualReceiver); ResolvedFeatures resolvedFeatures = overrideHelper.getResolvedFeatures(actualType); for (IResolvedOperation resolvedOperation : resolvedFeatures.getAllOperations()) { if (resolvedOperation.getDeclaration().equals(operation)) { return resolvedOperation; } } } return null; }
Example 6
Source File: XtendHoverSerializer.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public String computeUnsugaredExpression(EObject object) { if (object instanceof XAbstractFeatureCall) { StringBuilder stringBuilder = new StringBuilder(); XAbstractFeatureCall featureCall = (XAbstractFeatureCall) object; JvmIdentifiableElement feature = featureCall.getFeature(); if (feature != null && !feature.eIsProxy()) { // Static extensions which are no expliciteOperationCalls if (featureCall instanceof XMemberFeatureCall && feature instanceof JvmOperation && !((XMemberFeatureCall) featureCall).isExplicitOperationCall()) { JvmOperation jvmOperation = (JvmOperation) feature; if (jvmOperation.isStatic()) { return stringBuilder.append(getStaticCallDesugaredVersion(featureCall, jvmOperation)).toString(); } } // Static calls with implicit receiver or implicit first argument if (featureCall.getImplicitReceiver() != null || featureCall.getImplicitFirstArgument() != null) { if (featureCall.isStatic()) { return stringBuilder.append(getStaticCallDesugaredVersion(featureCall, (JvmMember) feature)).toString(); } XExpression receiver = featureCall.getActualReceiver(); if (receiver instanceof XMemberFeatureCall) { stringBuilder.append(THIS).append(DELIMITER); stringBuilder.append(((XMemberFeatureCall) receiver).getFeature().getSimpleName()).append(DELIMITER); } else if (receiver instanceof XAbstractFeatureCall) { JvmIdentifiableElement receiverFeature = ((XAbstractFeatureCall) receiver).getFeature(); if (receiverFeature == feature.eContainer()) { stringBuilder.append(THIS).append(DELIMITER); } else { stringBuilder.append(receiverFeature.getSimpleName()).append(DELIMITER); } } stringBuilder.append(feature.getSimpleName()); if (feature instanceof JvmExecutable) stringBuilder.append(computeArguments(featureCall)); return stringBuilder.toString(); } } } return ""; }
Example 7
Source File: SARLHoverSerializer.java From sarl with Apache License 2.0 | 5 votes |
@Override public String computeUnsugaredExpression(EObject object) { if (object instanceof XAbstractFeatureCall) { final XAbstractFeatureCall featureCall = (XAbstractFeatureCall) object; final JvmIdentifiableElement feature = featureCall.getFeature(); if (feature instanceof JvmExecutable && !feature.eIsProxy() && (featureCall.getImplicitReceiver() != null || featureCall.getImplicitFirstArgument() != null) && !featureCall.isStatic()) { final XExpression receiver = featureCall.getActualReceiver(); if (receiver instanceof XMemberFeatureCall) { final JvmIdentifiableElement memberFeature = ((XMemberFeatureCall) receiver).getFeature(); final String name = memberFeature.getSimpleName(); if (Utils.isNameForHiddenCapacityImplementationCallingMethod(name)) { final JvmOperation op = (JvmOperation) memberFeature; final StringBuilder result = new StringBuilder(); result.append("getSkill(typeof("); //$NON-NLS-1$ result.append(op.getReturnType().getSimpleName()); result.append("))."); //$NON-NLS-1$ result.append(feature.getSimpleName()); result.append(computeArguments(featureCall)); return result.toString(); } } } } return super.computeUnsugaredExpression(object); }
Example 8
Source File: FeatureCallCompiler.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
protected XExpression getActualReceiver(final XAbstractFeatureCall expr) { return expr.getActualReceiver(); }
Example 9
Source File: XbaseInterpreter.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
protected XExpression getActualReceiver(XAbstractFeatureCall featureCall) { return featureCall.getActualReceiver(); }
Example 10
Source File: AbstractExpressionGenerator.java From sarl with Apache License 2.0 | 4 votes |
/** Compute the list of object that serve as the receiver for the given call. * * @param call the feature call to analyze. * @param output the objects that constitute the call's receiver. * @param thisKeyword the "this" keyword. * @param referenceNameDefinition replies the name of the expression, if defined. * @return {@code true} if a receiver was found; otherwise {@code false}. */ public static boolean buildCallReceiver(XAbstractFeatureCall call, Function0<? extends String> thisKeyword, Function1<? super XExpression, ? extends String> referenceNameDefinition, List<Object> output) { if (call.isStatic()) { if (call instanceof XMemberFeatureCall) { final XMemberFeatureCall memberFeatureCall = (XMemberFeatureCall) call; if (memberFeatureCall.isStaticWithDeclaringType()) { final XAbstractFeatureCall target = (XAbstractFeatureCall) memberFeatureCall.getMemberCallTarget(); final JvmType declaringType = (JvmType) target.getFeature(); output.add(declaringType); return true; } } output.add(((JvmFeature) call.getFeature()).getDeclaringType()); return true; } final XExpression receiver = call.getActualReceiver(); if (receiver == null) { return false; } final XExpression implicit = call.getImplicitReceiver(); if (receiver == implicit) { output.add(thisKeyword.apply()); } else { output.add(receiver); if (receiver instanceof XAbstractFeatureCall) { // some local types have a reference name bound to the empty string // which is the reason why we have to check for an empty string as a valid // reference name here // see AnonymousClassCompilerTest.testCapturedLocalVar_04 // if it turns out that we have to deal with generics there too, we may // have to create a field in the synthesized local class with a unique // name that points to 'this' if (((XAbstractFeatureCall) receiver).getFeature() instanceof JvmType) { final String referenceName = referenceNameDefinition.apply(receiver); if (referenceName != null && referenceName.length() == 0) { return false; } } } } return true; }