Java Code Examples for org.eclipse.xtext.xbase.XConstructorCall#getArguments()
The following examples show how to use
org.eclipse.xtext.xbase.XConstructorCall#getArguments() .
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: XbaseCompiler.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
protected void _toJavaStatement(final XConstructorCall expr, ITreeAppendable b, final boolean isReferenced) { for (XExpression arg : expr.getArguments()) { prepareExpression(arg, b); } if (!isReferenced) { b.newLine(); constructorCallToJavaExpression(expr, b); b.append(";"); } else if (isVariableDeclarationRequired(expr, b, true)) { Later later = new Later() { @Override public void exec(ITreeAppendable appendable) { constructorCallToJavaExpression(expr, appendable); } }; declareFreshLocalVariable(expr, b, later); } }
Example 2
Source File: DefaultEarlyExitComputer.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
protected Collection<IEarlyExitComputer.ExitPoint> _exitPoints(final XConstructorCall expression) { EList<XExpression> _arguments = expression.getArguments(); for (final XExpression argument : _arguments) { { Collection<IEarlyExitComputer.ExitPoint> argumentExitPoints = this.getExitPoints(argument); boolean _isNotEmpty = this.isNotEmpty(argumentExitPoints); if (_isNotEmpty) { return argumentExitPoints; } } } return Collections.<IEarlyExitComputer.ExitPoint>emptyList(); }
Example 3
Source File: XtendJvmModelInferrer.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
/** * Anonymous classes are not inferred in the type inference phase, but later during type resolution. */ public void inferLocalClass( AnonymousClass anonymousClass, String localClassName, JvmFeature container) { final JvmGenericType inferredType = typesFactory.createJvmGenericType(); inferredType.setSimpleName(localClassName); inferredType.setAnonymous(!hasAdditionalMembers(anonymousClass)); inferredType.setFinal(true); inferredType.setVisibility(JvmVisibility.DEFAULT); inferredType.getSuperTypes().add(jvmTypesBuilder.inferredType(anonymousClass)); container.getLocalClasses().add(inferredType); associator.associatePrimary(anonymousClass, inferredType); for (XtendMember member : anonymousClass.getMembers()) { if (member instanceof XtendField || (member instanceof XtendFunction && ((XtendFunction) member).getName() != null) || member instanceof XtendConstructor) { transform(member, inferredType, true); } } appendSyntheticDispatchMethods(anonymousClass, inferredType); nameClashResolver.resolveNameClashes(inferredType); final XConstructorCall constructorCall = anonymousClass.getConstructorCall(); for (XExpression actualParameter : constructorCall.getArguments()) { associator.associateLogicalContainer(actualParameter, container); } }
Example 4
Source File: SARLOperationHelper.java From sarl with Apache License 2.0 | 5 votes |
/** Test if the given expression has side effects. * * @param expression the expression. * @param context the list of context expressions. * @return {@code true} if the expression has side effects. */ protected Boolean _hasSideEffects(XConstructorCall expression, ISideEffectContext context) { for (final XExpression ex : expression.getArguments()) { if (hasSideEffects(ex, context)) { return true; } } return false; }
Example 5
Source File: XbaseSemanticSequencer.java From xtext-extras with Eclipse Public License 2.0 | 4 votes |
/** * Constraint: * ( * constructor=[JvmConstructor|QualifiedName] * (typeArguments+=JvmArgumentTypeReference typeArguments+=JvmArgumentTypeReference*)? * (arguments+=XShortClosure | (arguments+=XExpression arguments+=XExpression*))? * arguments+=XClosure? * ) */ @Override protected void sequence_XConstructorCall(ISerializationContext context, XConstructorCall constructorCall) { INodesForEObjectProvider nodes = createNodeProvider(constructorCall); SequenceFeeder acceptor = createSequencerFeeder(context, constructorCall, nodes); XConstructorCallElements constructorCallElements = grammarAccess.getXConstructorCallAccess(); // constructor=[types::JvmConstructor|QualifiedName] acceptor.accept(constructorCallElements.getConstructorJvmConstructorQualifiedNameParserRuleCall_2_0_1(), constructorCall.getConstructor()); // '<' typeArguments+=JvmArgumentTypeReference (',' typeArguments+=JvmArgumentTypeReference)* '>' List<JvmTypeReference> typeArguments = constructorCall.getTypeArguments(); if (!typeArguments.isEmpty()) { acceptor.accept(constructorCallElements.getTypeArgumentsJvmArgumentTypeReferenceParserRuleCall_3_1_0(), typeArguments.get(0), 0); for (int i = 1; i < typeArguments.size(); i++) acceptor.accept(constructorCallElements.getTypeArgumentsJvmArgumentTypeReferenceParserRuleCall_3_2_1_0(), typeArguments.get(i), i); } /* * Constraint: * * (explicitConstructorCall?='(' (arguments+=XShortClosure | (arguments+=XExpression arguments+=XExpression*))?)? * arguments+=XClosure? * */ if (constructorCall.isExplicitConstructorCall()) { acceptor.accept(constructorCallElements.getExplicitConstructorCallLeftParenthesisKeyword_4_0_0()); } List<XExpression> arguments = constructorCall.getArguments(); if (!arguments.isEmpty()) { if (constructorCall.isExplicitConstructorCall() && isXShortClosureAndBuilderSyntax(arguments, XbasePackage.Literals.XCONSTRUCTOR_CALL__ARGUMENTS, nodes)) { acceptor.accept(constructorCallElements.getArgumentsXShortClosureParserRuleCall_4_1_0_0(), arguments.get(0), 0); acceptor.accept(constructorCallElements.getArgumentsXClosureParserRuleCall_5_0(), arguments.get(1), 1); } else if (constructorCall.isExplicitConstructorCall() && isXShortClosure(constructorCall, XbasePackage.Literals.XCONSTRUCTOR_CALL__ARGUMENTS, nodes)) { acceptor.accept(constructorCallElements.getArgumentsXShortClosureParserRuleCall_4_1_0_0(), arguments.get(0), 0); } else { int diff = 0; if (isBuilderSyntax(arguments, XbasePackage.Literals.XCONSTRUCTOR_CALL__ARGUMENTS, nodes)) { diff = 1; } if (constructorCall.isExplicitConstructorCall()) { if (arguments.size() - diff > 0) acceptor.accept(constructorCallElements.getArgumentsXExpressionParserRuleCall_4_1_1_0_0(), arguments.get(0), 0); for (int i = 1; i < arguments.size() - diff; i++) acceptor.accept(constructorCallElements.getArgumentsXExpressionParserRuleCall_4_1_1_1_1_0(), arguments.get(i), i); } if (diff != 0) { int lastIdx = arguments.size() - 1; acceptor.accept(constructorCallElements.getArgumentsXClosureParserRuleCall_5_0(), arguments.get(lastIdx), lastIdx); } } } acceptor.finish(); }
Example 6
Source File: AbstractExpressionGenerator.java From sarl with Apache License 2.0 | 4 votes |
private List<XExpression> getActualArguments(XConstructorCall expr) { final List<XExpression> actualArguments = expr.getArguments(); return Lists.transform(actualArguments, it -> normalizeBlockExpression(it)); }