Java Code Examples for org.eclipse.xtext.xbase.XAbstractFeatureCall#isExplicitOperationCallOrBuilderSyntax()

The following examples show how to use org.eclipse.xtext.xbase.XAbstractFeatureCall#isExplicitOperationCallOrBuilderSyntax() . 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: TypeLiteralLinkingCandidate.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
public TypeLiteralLinkingCandidate(
		XAbstractFeatureCall featureCall, 
		IIdentifiableElementDescription description,
		ITypeExpectation expectation, 
		final ExpressionTypeComputationState state) {
	super(featureCall, description, expectation, state, new TypeLiteralLinkingCandidateResolver(featureCall) {
		
		@Override
		protected IFeatureLinkingCandidate getLinkingCandidate(XExpression target) {
			return state.getResolvedTypes().getLinkingCandidate((XAbstractFeatureCall) target);
		}
		
	});
	if (featureCall.isExplicitOperationCallOrBuilderSyntax()) {
		throw new IllegalArgumentException("Cannot be a type literal: " + String.valueOf(featureCall));
	}
	this.helper = new TypeLiteralHelper(state);
}
 
Example 2
Source File: SerializerScopeProvider.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
protected IScope getExecutableScope(XAbstractFeatureCall call, JvmIdentifiableElement feature) {
	final String simpleName = feature.getSimpleName();
	QualifiedName name = QualifiedName.create(simpleName);
	if (call.isOperation()) {
		QualifiedName operator = getOperator(call, name);
		if (operator == null) {
			return IScope.NULLSCOPE;
		}
		return new SingletonScope(EObjectDescription.create(operator, feature), IScope.NULLSCOPE);
	}
	if (call instanceof XAssignment) {
		return getAccessorScope(simpleName, name, feature);
	}
	if (call.isExplicitOperationCallOrBuilderSyntax() || ((JvmExecutable) feature).getParameters().size() > 1
			|| (!call.isExtension() && ((JvmExecutable) feature).getParameters().size() == 1)) {
		return new SingletonScope(EObjectDescription.create(name, feature), IScope.NULLSCOPE);
	}

	return getAccessorScope(simpleName, name, feature);
}
 
Example 3
Source File: TypeLiteralScope.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected List<IEObjectDescription> getLocalElementsByName(QualifiedName name) {
	XAbstractFeatureCall featureCall = getFeatureCall();
	if (featureCall.isExplicitOperationCallOrBuilderSyntax())
		return Collections.emptyList();
	QualifiedName fqn = parentSegments.append(name);
	IScope typeScope = getSession().getScope(getFeatureCall(), TypesPackage.Literals.JVM_PARAMETERIZED_TYPE_REFERENCE__TYPE, resolvedTypes);
	IEObjectDescription typeDescription = typeScope.getSingleElement(fqn);
	if (typeDescription != null) {
		EObject type = typeDescription.getEObjectOrProxy();
		if (type instanceof JvmType)
			return Collections.<IEObjectDescription>singletonList(new TypeLiteralDescription(
					new AliasedEObjectDescription(name, typeDescription), isVisible((JvmType) type)));
	}
	return Collections.emptyList();
}
 
Example 4
Source File: NestedTypeLiteralScope.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected List<IEObjectDescription> getLocalElementsByName(QualifiedName name) {
	XAbstractFeatureCall featureCall = getFeatureCall();
	if (featureCall.isExplicitOperationCallOrBuilderSyntax())
		return Collections.emptyList();
	if (rawEnclosingType instanceof JvmDeclaredType && name.getSegmentCount() == 1) {
		String singleSegment = name.getFirstSegment();
		List<String> lookup = Collections.singletonList(singleSegment);
		if (singleSegment.indexOf('$') != -1) {
			lookup = Strings.split(singleSegment, '$');
		}
		JvmType result = findNestedType((JvmDeclaredType)rawEnclosingType, lookup.iterator());
		if (result != null) {
			IEObjectDescription description = EObjectDescription.create(name, result);
			return Collections.<IEObjectDescription>singletonList(new TypeLiteralDescription(description, enclosingType, isVisible(result)));
		}
	}
	return Collections.emptyList();
}
 
Example 5
Source File: FeatureLinkingCandidate.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected boolean isOperationCallSyntax() {
	XAbstractFeatureCall featureCall = getFeatureCall();
	if (featureCall instanceof XBinaryOperation || featureCall instanceof XAssignment) {
		return false;
	}
	return featureCall.isExplicitOperationCallOrBuilderSyntax();
}
 
Example 6
Source File: AmbiguousFeatureLinkingCandidate.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected String[] getDiagnosticData() {
	FeatureLinkingCandidate primaryCandidate = getPrimaryCandidate();
	XAbstractFeatureCall expression = primaryCandidate.getExpression();
	if (expression.isExplicitOperationCallOrBuilderSyntax()) {
		return null;
	}
	Set<String> data = Sets.newLinkedHashSet();
	for (ILinkingCandidate candidate : getAlternatives()) {
		JvmIdentifiableElement feature = candidate.getFeature();
		String simpleName = feature.getSimpleName();
		data.add(simpleName + "()");
	}
	return data.toArray(new String[data.size()]);
}
 
Example 7
Source File: LocalVariableScope.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
protected boolean looksLikeLocalVariable(XAbstractFeatureCall featureCall) {
	if (featureCall instanceof XFeatureCall) {
		boolean result = !featureCall.isExplicitOperationCallOrBuilderSyntax() && featureCall.getTypeArguments().isEmpty();
		return result;
	}
	return false;
}
 
Example 8
Source File: FeatureCallAsTypeLiteralHelper.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
public boolean isDefiniteTypeLiteral(XAbstractFeatureCall featureCall) {
	if (featureCall.isExplicitOperationCallOrBuilderSyntax())
		return false;
	if (!featureCall.getTypeArguments().isEmpty())
		return false;
	if (featureCall.eContainingFeature() == XbasePackage.Literals.XMEMBER_FEATURE_CALL__MEMBER_CALL_TARGET) {
		XMemberFeatureCall container = (XMemberFeatureCall) featureCall.eContainer();
		if (container.isExplicitStatic()) {
			return true;
		}
		return isDefiniteTypeLiteral(container);
	}
	return false;
}
 
Example 9
Source File: CreateMemberQuickfixes.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
protected boolean isThis(XAssignment assigment) {
	XExpression assignable = assigment.getAssignable();
	if (!(assignable instanceof XAbstractFeatureCall)) {
		return false;
	}
	XAbstractFeatureCall featureCall = (XAbstractFeatureCall) assignable;
	return featureCall.getFeature() instanceof JvmDeclaredType
			&& !featureCall.isExplicitOperationCallOrBuilderSyntax() && !featureCall.isTypeLiteral();
}
 
Example 10
Source File: ScopeProviderAccess.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
private boolean canBeTypeLiteral(XAbstractFeatureCall featureCall) {
	return !featureCall.isExplicitOperationCallOrBuilderSyntax() && featureCall.getTypeArguments().isEmpty();
}
 
Example 11
Source File: CreateMemberQuickfixes.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void addQuickfixes(Issue issue, IssueResolutionAcceptor issueResolutionAcceptor,
		IXtextDocument xtextDocument, XtextResource resource, EObject referenceOwner, EReference unresolvedReference)
		throws Exception {
	if (referenceOwner instanceof XAbstractFeatureCall) {
		XAbstractFeatureCall call = (XAbstractFeatureCall) referenceOwner;
		
		String newMemberName = (issue.getData() != null && issue.getData().length > 0) ? issue.getData()[0] : null;
		if(newMemberName != null) {
			if (call instanceof XMemberFeatureCall) {
				if(!call.isExplicitOperationCallOrBuilderSyntax()) { 
					newFieldQuickfix(newMemberName, call, issue, issueResolutionAcceptor);
					newGetterQuickfixes(newMemberName, call, issue, issueResolutionAcceptor);
				}
				newMethodQuickfixes(newMemberName, call, issue, issueResolutionAcceptor);
				
			} else if(call instanceof XFeatureCall) {
				if(!call.isExplicitOperationCallOrBuilderSyntax()) {
					if(logicalContainerProvider.getNearestLogicalContainer(call) instanceof JvmExecutable)
						newLocalVariableQuickfix(newMemberName, call, issue, issueResolutionAcceptor);
					newFieldQuickfix(newMemberName, call, issue, issueResolutionAcceptor);
					newGetterQuickfixes(newMemberName, call, issue, issueResolutionAcceptor);
				}
				newMethodQuickfixes(newMemberName, call, issue, issueResolutionAcceptor);
				
			} else if (call instanceof XAssignment) {
				newSetterQuickfix(issue, issueResolutionAcceptor, newMemberName, call);
				XAssignment assigment = (XAssignment) call;
				if(assigment.getAssignable() == null) {
					newLocalVariableQuickfix(newMemberName, call, issue, issueResolutionAcceptor);
					newFieldQuickfix(newMemberName, call, issue, issueResolutionAcceptor);
				} else if (isThis(assigment)) {
					newFieldQuickfix(newMemberName, call, issue, issueResolutionAcceptor);
				}
			}
		} 
		if (call.isOperation()) {
			JvmIdentifiableElement feature = call.getFeature();
			if(feature.eIsProxy()) {
				String operatorMethodName = getOperatorMethodName(call);
				if(operatorMethodName != null) 
					newMethodQuickfixes(operatorMethodName, call, issue, issueResolutionAcceptor);
			}
		}
		if(call instanceof XFeatureCall && call.getFeature() instanceof JvmConstructor) {
			newConstructorQuickfix(issue, issueResolutionAcceptor, (XFeatureCall) call);
		}
	}
	if(referenceOwner instanceof XConstructorCall) {
		newConstructorQuickfix(issue, issueResolutionAcceptor, (XConstructorCall) referenceOwner);
	}
}