/** Generate the Java code related to the expression for the continue keyword. * * @param breakExpression the expression. * @param appendable the output. * @since 0.7 */ @SuppressWarnings("static-method") protected void _toJavaExpression(SarlContinueExpression breakExpression, ITreeAppendable appendable) { appendable.append("/* error - couldn't compile nested continue */"); //$NON-NLS-1$ }
@Override public ITreeAppendable append(CharSequence content) { this.delegate.append(content); return this; }
public Function1<? super ITreeAppendable, ? extends ITreeAppendable> setSuffix(final String suffix) { final Function1<ITreeAppendable, ITreeAppendable> _function = (ITreeAppendable it) -> { return it.append(suffix); }; return this.suffix = _function; }
protected void appendClosureParameterVarArgs(JvmFormalParameter closureParam, LightweightTypeReference parameterType, ITreeAppendable appendable) { appendable.append("final "); appendable.append(parameterType); appendable.append("... "); final String proposedParamName = makeJavaIdentifier(closureParam.getName()); String name = appendable.declareVariable(closureParam, proposedParamName); appendable.append(name); }
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; }
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(", "); } }
@Override public void exec(ITreeAppendable appendable) { appendable.append(getDefaultValueLiteral(expr)); } });
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 void _toJavaLiteral(final JvmIntAnnotationValue it, final ITreeAppendable appendable, final GeneratorConfig config) { final Procedure1<Integer> _function = (Integer it_1) -> { appendable.append(it_1.toString()); }; this._loopExtensions.<Integer>forEachWithShortcut(appendable, it.getValues(), _function); }
protected void _toJavaLiteral(final JvmBooleanAnnotationValue it, final ITreeAppendable appendable, final GeneratorConfig config) { final Procedure1<Boolean> _function = (Boolean it_1) -> { appendable.append(it_1.toString()); }; this._loopExtensions.<Boolean>forEachWithShortcut(appendable, it.getValues(), _function); }
/** Generate the Java code related to the expression for the assert keyword. * * @param assertExpression the expression. * @param appendable the output. */ protected void _toJavaExpression(SarlAssertExpression assertExpression, ITreeAppendable appendable) { if (!assertExpression.isIsStatic() && isAtLeastJava8(assertExpression)) { appendable.append("/* error - couldn't compile nested assert */"); //$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 appendConstructedTypeName(XConstructorCall constructorCall, ITreeAppendable typeAppendable) { JvmDeclaredType type = constructorCall.getConstructor().getDeclaringType(); if (type instanceof JvmGenericType && ((JvmGenericType) type).isAnonymous()) { typeAppendable.append(Iterables.getLast(type.getSuperTypes()).getType()); } else { typeAppendable.append(constructorCall.getConstructor().getDeclaringType()); } }
public void generateTypeParameterDeclaration(final JvmTypeParameter it, final ITreeAppendable appendable, final GeneratorConfig config) { final ITreeAppendable tracedAppendable = appendable.trace(it); this._treeAppendableUtil.traceSignificant(tracedAppendable, it).append(it.getName()); this.generateTypeParameterConstraints(it, tracedAppendable, config); }
@Override public void acceptIfCondition(XExpression condition) { currentAppendable = null; ifStack.add((RichStringIf) condition.eContainer()); appendable.newLine(); pushAppendable(condition.eContainer()); appendable.append("{").increaseIndentation(); writeIf(condition); }
public void setCompilationStrategy(final JvmExecutable executable, final CompilationStrategy compilationStrategy) { this.checkCanceled(); final Procedure1<ITreeAppendable> _function = (ITreeAppendable it) -> { final CompilationContextImpl context = new CompilationContextImpl(it, this); it.append(this.trimTrailingLinebreak(compilationStrategy.compile(context), executable)); }; this.jvmTypesBuilder.setBody(executable, _function); }
protected void compileAnonymousClassBody(AnonymousClass anonymousClass, JvmDeclaredType type, ITreeAppendable b) { ITreeAppendable appendable = b.trace(anonymousClass, true); appendable.append(" "); appendable.openScope(); GeneratorConfig config = generatorConfigProvider.get(anonymousClass); jvmModelGenerator.assignThisAndSuper(appendable, type, config); jvmModelGenerator.generateMembersInBody(type, appendable, config); appendable.closeScope(); }