@Override public ITreeAppendable newLine() { this.delegate.newLine(); return this; }
/** Generate the Java code related to the preparation statements for the break keyword. * * @param breakExpression the expression. * @param appendable the output. * @param isReferenced indicates if the expression is referenced. */ @SuppressWarnings("static-method") protected void _toJavaStatement(SarlBreakExpression breakExpression, ITreeAppendable appendable, boolean isReferenced) { appendable.newLine().append("break;"); //$NON-NLS-1$ }
/** Generate the Java code related to the preparation statements for the break keyword. * * @param breakExpression the expression. * @param appendable the output. * @param isReferenced indicates if the expression is referenced. * @since 0.7 */ @SuppressWarnings("static-method") protected void _toJavaStatement(SarlContinueExpression breakExpression, ITreeAppendable appendable, boolean isReferenced) { appendable.newLine().append("continue;"); //$NON-NLS-1$ }
/** * Close a block of code. * * @param appendable the receiver of the block closing code. */ protected void closeBlock(ITreeAppendable appendable) { appendable.decreaseIndentation(); appendable.newLine().append("}"); }
@Override public void acceptEndIf() { currentAppendable = null; RichStringIf richStringIf = ifStack.removeLast(); for (int i = 0; i < richStringIf.getElseIfs().size() + 2; i++) { appendable.decreaseIndentation(); appendable.newLine(); appendable.append("}"); } popAppendable(); }
protected void writeElse() { currentAppendable = null; appendable.decreaseIndentation(); appendable.newLine(); appendable.append("} else {"); appendable.increaseIndentation(); }
protected void generateComment(Later expr, ITreeAppendable b, boolean isReferenced) { if (!isReferenced) { b.newLine().append("/* "); try { expr.exec(b); } finally { b.append(" */"); } } }
@Override public void acceptSemanticText(CharSequence text, /* @Nullable */ RichStringLiteral origin) { setCurrentAppendable(origin); if (text.length() == 0) return; currentAppendable.newLine(); currentAppendable.append(variableName); currentAppendable.append(".append(\""); currentAppendable.append(Strings.convertToJavaString(text.toString(), false)); currentAppendable.append("\");"); }
public ITreeAppendable generateBodyWithIssues(final ITreeAppendable appendable, final Iterable<Issue> errors) { ITreeAppendable _xblockexpression = null; { appendable.append("{").increaseIndentation().newLine().append("throw new Error(\"Unresolved compilation problems:\""); appendable.increaseIndentation(); final Consumer<Issue> _function = (Issue it) -> { appendable.newLine().append("+ \"\\n").append(this.doConvertToJavaString(it.getMessage())).append("\""); }; errors.forEach(_function); _xblockexpression = appendable.append(");").decreaseIndentation().decreaseIndentation().newLine().append("}"); } return _xblockexpression; }
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); } }
@Override public void acceptSemanticLineBreak(int charCount, RichStringLiteral origin, boolean controlStructureSeen) { setCurrentAppendable(origin); currentAppendable.newLine(); currentAppendable.append(variableName); if (!controlStructureSeen) { currentAppendable.append(".newLine();"); } else { currentAppendable.append(".newLineIfNotEmpty();"); } }
protected void appendExtensionAnnotation(EObject context, ITreeAppendable appendable, boolean newLine) { JvmType extension = findKnownTopLevelType(Extension.class, context); if (extension != null) { appendable.append("@"); appendable.append(extension); if (!newLine) appendable.append(" "); else appendable.newLine(); } }
@Override public void acceptIfCondition(XExpression condition) { currentAppendable = null; ifStack.add((RichStringIf) condition.eContainer()); appendable.newLine(); pushAppendable(condition.eContainer()); appendable.append("{").increaseIndentation(); writeIf(condition); }
protected void generateCheckedExceptionHandling(ITreeAppendable appendable) { String name = appendable.declareSyntheticVariable(new Object(), "_e"); appendable.decreaseIndentation().newLine().append("} catch (").append(Throwable.class).append(" ").append(name).append(") {").increaseIndentation(); appendable.newLine().append("throw "); appendable.append(Exceptions.class); appendable.append(".sneakyThrow("); appendable.append(name); appendable.append(");"); appendable.decreaseIndentation().newLine().append("}"); }
protected void writeIf(XExpression condition) { ITreeAppendable debugAppendable = appendable.trace(condition.eContainer(), true); internalToJavaStatement(condition, debugAppendable, true); debugAppendable.newLine(); debugAppendable.append("if ("); internalToJavaExpression(condition, debugAppendable); debugAppendable.append(") {").increaseIndentation(); }
/** * @param isReferenced unused in this context but necessary for dispatch signature */ protected void _toJavaStatement(XThrowExpression expr, ITreeAppendable b, boolean isReferenced) { internalToJavaStatement(expr.getExpression(), b, true); b.newLine().append("throw "); internalToConvertedExpression(expr.getExpression(), b, null); b.append(";"); }
public void generateEnumLiteral(final JvmEnumerationLiteral it, final ITreeAppendable appendable, final GeneratorConfig config) { appendable.newLine(); this.generateJavaDoc(it, appendable, config); this.generateAnnotations(it.getAnnotations(), appendable, true, config); appendable.append(this.makeJavaIdentifier(it.getSimpleName())); }
protected void executeThenPart(XSwitchExpression expr, String switchResultName, XExpression then, ITreeAppendable b, boolean isReferenced) { final boolean canBeReferenced = isReferenced && !isPrimitiveVoid(then); internalToJavaStatement(then, b, canBeReferenced); if (canBeReferenced) { b.newLine().append(switchResultName).append(" = "); internalToConvertedExpression(then, b, getLightweightType(expr)); b.append(";"); } }
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(";"); }
protected String declareSwitchResultVariable(XSwitchExpression expr, ITreeAppendable b, boolean isReferenced) { LightweightTypeReference type = getTypeForVariableDeclaration(expr); String switchResultName = b.declareSyntheticVariable(getSwitchExpressionKey(expr), "_switchResult"); if (isReferenced) { b.newLine(); b.append(type); b.append(" ").append(switchResultName).append(" = "); b.append(getDefaultValueLiteral(expr)); b.append(";"); } return switchResultName; }