/** Generate the given object. * * @param forLoop the for-loop. * @param it the target for the generated content. * @param context the context. * @return the statement. */ protected XExpression _generate(XForLoopExpression forLoop, IAppendable it, IExtraLanguageGeneratorContext context) { it.append("for "); //$NON-NLS-1$ final String varName = it.declareUniqueNameVariable(forLoop.getDeclaredParam(), forLoop.getDeclaredParam().getSimpleName()); it.append(varName); it.append(" in "); //$NON-NLS-1$ generate(forLoop.getForExpression(), it, context); it.append(":"); //$NON-NLS-1$ it.increaseIndentation().newLine(); final XExpression last = generate(forLoop.getEachExpression(), it, context); it.decreaseIndentation(); return last; }
/** Generate the given object. * * @param varDeclaration the variable declaration. * @param it the target for the generated content. * @param context the context. * @return the statement. */ protected XExpression _generate(XVariableDeclaration varDeclaration, IAppendable it, IExtraLanguageGeneratorContext context) { final String name = it.declareUniqueNameVariable(varDeclaration, varDeclaration.getName()); it.append(name); it.append(" = "); //$NON-NLS-1$ if (varDeclaration.getRight() != null) { generate(varDeclaration.getRight(), it, context); } else if (varDeclaration.getType() != null) { it.append(toDefaultValue(varDeclaration.getType())); } else { it.append("None"); //$NON-NLS-1$ } if (context.getExpectedExpressionType() != null) { it.newLine(); it.append("return ").append(name); //$NON-NLS-1$ } return varDeclaration; }
for (final JvmFormalParameter param : closure.getFormalParameters()) { it.append(", "); //$NON-NLS-1$ final String name = it.declareUniqueNameVariable(param, param.getName()); it.append(name);
/** Generate the given object. * * @param tryStatement the try-catch-finally statement. * @param it the target for the generated content. * @param context the context. * @return the statement. */ protected XExpression _generate(XTryCatchFinallyExpression tryStatement, IAppendable it, IExtraLanguageGeneratorContext context) { it.append("try:"); //$NON-NLS-1$ it.increaseIndentation().newLine(); generate(tryStatement.getExpression(), context.getExpectedExpressionType(), it, context); it.decreaseIndentation().newLine(); for (final XCatchClause clause : tryStatement.getCatchClauses()) { it.append("except "); //$NON-NLS-1$ it.append(clause.getDeclaredParam().getParameterType().getType()); it.append(", "); //$NON-NLS-1$ it.append(it.declareUniqueNameVariable(clause.getDeclaredParam(), clause.getDeclaredParam().getSimpleName())); it.append(":"); //$NON-NLS-1$ it.increaseIndentation().newLine(); generate(clause.getExpression(), context.getExpectedExpressionType(), it, context); it.decreaseIndentation().newLine(); } if (tryStatement.getFinallyExpression() != null) { it.append("finally:"); //$NON-NLS-1$ it.increaseIndentation().newLine(); generate(tryStatement.getFinallyExpression(), it, context); it.decreaseIndentation(); } return tryStatement; }
final String varName; if (switchStatement.getDeclaredParam() != null) { varName = it.declareUniqueNameVariable(switchStatement.getDeclaredParam(), switchStatement.getDeclaredParam().getSimpleName()); } else {