@Override protected void internalToConvertedExpression(XExpression obj, ITreeAppendable appendable) { if (obj instanceof XAbstractFeatureCall) { _toJavaExpression((XAbstractFeatureCall) obj, appendable); } else { super.internalToConvertedExpression(obj, appendable); } }
@Override protected void doInternalToJavaStatement(XExpression obj, ITreeAppendable appendable, boolean isReferenced) { if (obj instanceof XFeatureCall) { _toJavaStatement((XFeatureCall) obj, appendable, isReferenced); } else if (obj instanceof XAbstractFeatureCall) { _toJavaStatement((XAbstractFeatureCall) obj, appendable, isReferenced); } else { super.doInternalToJavaStatement(obj, appendable, isReferenced); } }
protected void appendArgument(XExpression argument, ITreeAppendable b) { appendArgument(argument, b, true); }
@Override public void exec(ITreeAppendable appendable) { appendNullValueUntyped(getTypeForVariableDeclaration(expr), expr, appendable); } };
protected void featureCalltoJavaExpression(final XAbstractFeatureCall call, ITreeAppendable b, boolean isExpressionContext) { if (call instanceof XAssignment) { assignmentToJavaExpression((XAssignment) call, b, isExpressionContext); } else { if (needMultiAssignment(call)) { appendLeftOperand(call, b, isExpressionContext).append(" = "); } final JvmAnnotationReference annotationRef = this.expressionHelper.findInlineAnnotation(call); if (annotationRef == null || !isConstantExpression(annotationRef)) { boolean hasReceiver = appendReceiver(call, b, isExpressionContext); if (hasReceiver) { b.append("."); b = appendTypeArguments(call, b); } } appendFeatureCall(call, b); } }
EList<XExpression> elements = ((XListLiteral)customAnnotationValue.getValues().get(0)).getElements(); for (XExpression e : elements) { LightweightTypeReference lightweightType = getLightweightType(e); if (lightweightType != null && lightweightType.isType(Class.class)) { importedTypes.add(lightweightType.toTypeReference()); throw new IllegalStateException(); IResolvedTypes resolvedTypes = batchTypeResolver.resolveTypes(call); List<XExpression> arguments = getActualArguments(call); Matcher matcher = pattern.matcher(formatString); int prevEnd = 0; List<LightweightTypeReference> typeArguments = resolvedTypes.getActualTypeArguments(call); LightweightTypeReference typeArgument = typeArguments.get(index - (numberArguments+numberImports+1)); serialize(typeArgument.getRawTypeReference().toTypeReference(), call, b); } else if (index >= numberArguments && index < numberArguments + numberImports) { serialize(importedTypes.get(index - numberArguments), call, b); } else if (index == numberArguments + numberImports) { appendTypeArguments(call, b); } else { XExpression argument = arguments.get(index); appendArgument(argument, b, index > 0);
protected void assignmentToJavaExpression(XAssignment expr, ITreeAppendable b, boolean isExpressionContext) { final JvmIdentifiableElement feature = expr.getFeature(); if (feature instanceof JvmOperation) { boolean appendReceiver = appendReceiver(expr, b, isExpressionContext); if (appendReceiver) b.append("."); appendFeatureCall(expr, b); } else { boolean isArgument = expr.eContainer() instanceof XAbstractFeatureCall; boolean appendReceiver = appendReceiver(expr, b, isExpressionContext); if (appendReceiver) b.append("."); appendFeatureCall(expr, b); } else { String name = b.getName(expr.getFeature()); internalToJavaExpression(expr.getValue(), b); if (isArgument) { b.append(")");
protected void appendFeatureCall(XAbstractFeatureCall call, ITreeAppendable b) { if (expressionHelper.isInlined(call)) { appendInlineFeatureCall(call, b); return; if (feature instanceof JvmExecutable) { b.append("("); List<XExpression> arguments = getActualArguments(call); if (!arguments.isEmpty()) { XExpression receiver = null; appendArguments(arguments, b, shouldBreakFirstArgument);
protected void _toJavaStatement(final XFeatureCall expr, final ITreeAppendable b, boolean isReferenced) { // if it's a call to this() or super() make sure the arguments are forced to be compiled to expressions. if (expr.getFeature() instanceof JvmConstructor) { b.newLine(); featureCalltoJavaExpression(expr, b, false); b.append(";"); } else { _toJavaStatement((XAbstractFeatureCall) expr, b, isReferenced); } }
protected void appendArguments(List<? extends XExpression> arguments, ITreeAppendable b) { appendArguments(arguments, b, true); }
@Override protected ITreeAppendable appendTypeArguments(XAbstractFeatureCall call, ITreeAppendable original) { if (!call.getTypeArguments().isEmpty()) { return super.appendTypeArguments(call, original); } ILocationData completeLocationData = getLocationWithTypeArguments(call); ITreeAppendable completeFeatureCallAppendable = completeLocationData != null ? original.trace(completeLocationData) : original; IResolvedTypes resolvedTypes = batchTypeResolver.resolveTypes(call); List<LightweightTypeReference> typeArguments = resolvedTypes.getActualTypeArguments(call); if (!typeArguments.isEmpty()) { for(LightweightTypeReference typeArgument: typeArguments) { if (typeArgument.isWildcard()) { return completeFeatureCallAppendable; } } completeFeatureCallAppendable.append("<"); for (int i = 0; i < typeArguments.size(); i++) { if (i != 0) { completeFeatureCallAppendable.append(", "); } completeFeatureCallAppendable.append(typeArguments.get(i)); } completeFeatureCallAppendable.append(">"); } return completeFeatureCallAppendable; }
protected ITreeAppendable appendLeftOperand(final XAbstractFeatureCall expr, ITreeAppendable appendable, boolean isExpressionContext) { XBinaryOperation binaryOperation = (XBinaryOperation) expr; XAbstractFeatureCall leftOperand = (XAbstractFeatureCall) binaryOperation.getLeftOperand(); JvmIdentifiableElement feature = leftOperand.getFeature(); if (appendable.hasName(feature)) { return appendable.append(appendable.getName(feature)); } boolean hasReceiver = appendReceiver(leftOperand, appendable, isExpressionContext); if (hasReceiver) { appendable.append("."); } return appendable.append(feature.getSimpleName()); }
protected void appendArguments(List<? extends XExpression> arguments, ITreeAppendable b, boolean shouldWrapLine) { for (int i = 0; i < arguments.size(); i++) { XExpression argument = arguments.get(i); appendArgument(argument, b, shouldWrapLine || i > 0); if (i + 1 < arguments.size()) b.append(", "); } }