Java Code Examples for org.eclipse.xtext.xbase.XMemberFeatureCall#isExplicitOperationCallOrBuilderSyntax()
The following examples show how to use
org.eclipse.xtext.xbase.XMemberFeatureCall#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: XbaseValidator.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Check public void checkExplicitOperationCall(XMemberFeatureCall featureCall) { if (featureCall.getFeature() instanceof JvmOperation && !featureCall.isExplicitOperationCallOrBuilderSyntax() && featureCall.getFeature().getSimpleName().equals(featureCall.getConcreteSyntaxFeatureName())) { addIssue("Method call without parentheses", featureCall, XbasePackage.Literals.XABSTRACT_FEATURE_CALL__FEATURE, OPERATION_WITHOUT_PARENTHESES); } }
Example 2
Source File: XbaseSemanticSequencer.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
/** * Constraint: * ( * memberCallTarget=XMemberFeatureCall_XMemberFeatureCall_1_1_0_0_0 * (nullSafe?='?.' | spreading?='*.')? * (typeArguments+=JvmArgumentTypeReference typeArguments+=JvmArgumentTypeReference*)? * feature=[JvmIdentifiableElement|ID] * (explicitOperationCall?='(' (memberCallArguments+=XShortClosure | (memberCallArguments+=XExpression memberCallArguments+=XExpression*))?)? * ) * * * Features: * feature[1, 1] * typeArguments[0, *] * memberCallTarget[1, 1] * memberCallArguments[1, *] * EXCLUDE_IF_UNSET explicitOperationCall * explicitOperationCall[0, 1] * MANDATORY_IF_SET memberCallArguments * EXCLUDE_IF_UNSET memberCallArguments * MANDATORY_IF_SET memberCallArguments * MANDATORY_IF_SET memberCallArguments * spreading[0, 1] * EXCLUDE_IF_SET nullSafe * nullSafe[0, 1] * EXCLUDE_IF_SET spreading */ @Override protected void sequence_XMemberFeatureCall(ISerializationContext context, XMemberFeatureCall featureCall) { INodesForEObjectProvider nodes = createNodeProvider(featureCall); SequenceFeeder acceptor = createSequencerFeeder(context, featureCall, nodes); XMemberFeatureCallElements memberFeatureCallElements= grammarAccess.getXMemberFeatureCallAccess(); // memberCallTarget=XMemberFeatureCall_XMemberFeatureCall_1_1_0_0_0 acceptor.accept(memberFeatureCallElements.getXMemberFeatureCallMemberCallTargetAction_1_1_0_0_0(), featureCall.getMemberCallTarget()); // (nullSafe?='?.' | explicitStatic?='::')? if (featureCall.isNullSafe()) acceptor.accept(memberFeatureCallElements.getNullSafeQuestionMarkFullStopKeyword_1_1_0_0_1_1_0()); else if (featureCall.isExplicitStatic()) acceptor.accept(memberFeatureCallElements.getExplicitStaticColonColonKeyword_1_1_0_0_1_2_0()); // (typeArguments+=JvmArgumentTypeReference typeArguments+=JvmArgumentTypeReference*)? List<JvmTypeReference> typeArguments = featureCall.getTypeArguments(); if (!typeArguments.isEmpty()) { acceptor.accept(memberFeatureCallElements.getTypeArgumentsJvmArgumentTypeReferenceParserRuleCall_1_1_1_1_0(), typeArguments.get(0), 0); for (int i = 1; i < typeArguments.size(); i++) acceptor.accept(memberFeatureCallElements.getTypeArgumentsJvmArgumentTypeReferenceParserRuleCall_1_1_1_2_1_0(), typeArguments.get(i), i); } // feature=[JvmIdentifiableElement|ID] acceptor.accept(memberFeatureCallElements.getFeatureJvmIdentifiableElementIdOrSuperParserRuleCall_1_1_2_0_1(), featureCall.getFeature()); // (explicitOperationCall?='(' (memberCallArguments+=XShortClosure | (memberCallArguments+=XExpression memberCallArguments+=XExpression*))?)? memberCallArguments+=XClosure? if (featureCall.isExplicitOperationCallOrBuilderSyntax()) { if (featureCall.isExplicitOperationCall()) acceptor.accept(memberFeatureCallElements.getExplicitOperationCallLeftParenthesisKeyword_1_1_3_0_0()); List<XExpression> arguments = featureCall.getMemberCallArguments(); if (!arguments.isEmpty()) { if (featureCall.isExplicitOperationCall() && isXShortClosureAndBuilderSyntax(arguments, XbasePackage.Literals.XFEATURE_CALL__FEATURE_CALL_ARGUMENTS, nodes)) { acceptor.accept(memberFeatureCallElements.getMemberCallArgumentsXShortClosureParserRuleCall_1_1_3_1_0_0(), arguments.get(0), 0); acceptor.accept(memberFeatureCallElements.getMemberCallArgumentsXClosureParserRuleCall_1_1_4_0(), arguments.get(1), 1); } else if (featureCall.isExplicitOperationCall() && isXShortClosure(featureCall, XbasePackage.Literals.XMEMBER_FEATURE_CALL__MEMBER_CALL_ARGUMENTS, nodes)) { acceptor.accept(memberFeatureCallElements.getMemberCallArgumentsXShortClosureParserRuleCall_1_1_3_1_0_0(), arguments.get(0), 0); } else { int diff = 0; if (isBuilderSyntax(featureCall, XbasePackage.Literals.XMEMBER_FEATURE_CALL__MEMBER_CALL_ARGUMENTS, featureCall.isExplicitOperationCall(), nodes)) { diff = 1; } if (featureCall.isExplicitOperationCall()) { if (arguments.size() - diff > 0) acceptor.accept(memberFeatureCallElements.getMemberCallArgumentsXExpressionParserRuleCall_1_1_3_1_1_0_0(), arguments.get(0), 0); for (int i = 1; i < arguments.size() - diff; i++) acceptor.accept(memberFeatureCallElements.getMemberCallArgumentsXExpressionParserRuleCall_1_1_3_1_1_1_1_0(), arguments.get(i), i); } if (diff != 0) { int lastIdx = arguments.size() - 1; acceptor.accept(memberFeatureCallElements.getMemberCallArgumentsXClosureParserRuleCall_1_1_4_0(), arguments.get(lastIdx), lastIdx); } } } } acceptor.finish(); }