void (StringBuilder mainBuilder, GrVariableDeclaration variableDeclaration) { ExpressionContext extended = context.extend(); GrVariable[] variables = variableDeclaration.getVariables(); if (variables.length > 0 && variables[0] instanceof PsiField) { GenerationUtil.writeDocComment(mainBuilder, ((PsiField)variables[0]), true); } StringBuilder builder = new StringBuilder(); StringBuilder initBuilder = new StringBuilder(); initBuilder.append("{\n"); for (GrVariable variable : variables) { PsiType type = extended.typeProvider.getVarType(variable); ModifierListGenerator.writeModifiers(builder, variable.getModifierList()); TypeWriter.writeType(builder, type, variable); builder.append(' '); builder.append(variable.getName()); final GrExpression initializer = variable.getInitializerGroovy(); if (initializer != null) { int count = extended.myStatements.size(); StringBuilder initializerBuilder = new StringBuilder(); extended.searchForLocalVarsToWrap(initializer); initializer.accept(new ExpressionGenerator(initializerBuilder, extended)); if (extended.myStatements.size() == count) { //didn't use extra statements builder.append(" = ").append(initializerBuilder); } else { StringBuilder assignment = new StringBuilder().append(variable.getName()).append(" = ").append(initializerBuilder).append(';'); GenerationUtil.writeStatement(initBuilder, assignment, null, extended); } } builder.append(";\n"); } if (!extended.myStatements.isEmpty()) { initBuilder.append("}\n"); mainBuilder.append(initBuilder); } mainBuilder.append(builder); }