protected void generateComment(Later expr, ITreeAppendable b, boolean isReferenced) { if (!isReferenced) { b.newLine().append("/* "); try { expr.exec(b); } finally { b.append(" */"); } } }
private void doCastConversion(final LightweightTypeReference castTo, final ITreeAppendable b, final Later expression) { b.append("(("); b.append(castTo); b.append(")"); expression.exec(b); b.append(")"); }
/** * @param primitive unused in this context but useful for inheritors */ private void convertPrimitiveToWrapper( final LightweightTypeReference primitive, final LightweightTypeReference wrapper, final ITreeAppendable appendable, final Later expression) { appendable.append(wrapper); appendable.append("."); appendable.append("valueOf("); expression.exec(appendable); appendable.append(")"); }
private void convertMultiType(LightweightTypeReference expectation, CompoundTypeReference multiType, XExpression context, ITreeAppendable b, Later expression) { LightweightTypeReference castTo = null; List<LightweightTypeReference> components = multiType.getMultiTypeComponents(); ITypeReferenceOwner owner = multiType.getOwner(); LightweightTypeReference commonType = owner.getServices().getTypeConformanceComputer().getCommonSuperType(components, owner); if (!isJavaConformant(expectation, commonType)) { for(LightweightTypeReference candidate: multiType.getMultiTypeComponents()) { if (isJavaConformant(expectation, candidate)) { castTo = candidate; break; } } } if (castTo != null && mustInsertTypeCast(context, castTo)) { b.append("(("); b.append(castTo); b.append(")"); expression.exec(b); b.append(")"); } else { expression.exec(b); } }
protected void declareFreshLocalVariable(XExpression expr, ITreeAppendable b, Later expression) { LightweightTypeReference type = getTypeForVariableDeclaration(expr); final String proposedName = makeJavaIdentifier(getFavoriteVariableName(expr)); final String varName = b.declareSyntheticVariable(expr, proposedName); b.newLine(); b.append(type); b.append(" ").append(varName).append(" = "); expression.exec(b); b.append(";"); }
private void convertListToArray( final LightweightTypeReference arrayTypeReference, final ITreeAppendable appendable, final Later expression) { appendable.append("(("); appendable.append(arrayTypeReference); appendable.append(")"); appendable.append(Conversions.class); appendable.append(".unwrapArray("); expression.exec(appendable); LightweightTypeReference rawTypeArrayReference = arrayTypeReference.getRawTypeReference(); appendable.append(", "); appendable.append(rawTypeArrayReference.getComponentType()); appendable.append(".class))"); }
Iterator<Later> iterator = laters.iterator(); while (iterator.hasNext()) { iterator.next().exec(operationAppendable); if (iterator.hasNext()) { operationAppendable.newLine().append(" && ");
private void convertArrayToList(final LightweightTypeReference left, final ITreeAppendable appendable, XExpression context, final Later expression) { if (!(context.eContainer() instanceof XCastedExpression)) { if (context.eContainer() instanceof XAbstractFeatureCall) { appendable.append("(("); } else { appendable.append("("); } appendable.append(left); appendable.append(")"); } appendable.append(Conversions.class); appendable.append(".doWrapArray("); expression.exec(appendable); if (!(context.eContainer() instanceof XCastedExpression)) { if (context.eContainer() instanceof XAbstractFeatureCall) { appendable.append("))"); } else { appendable.append(")"); } } else { appendable.append(")"); } }