Result (GroovyPsiElement root, Result analyzedVars, ExpressionContext context) { LocalVarAnalyzer visitor = new LocalVarAnalyzer(); root.accept(visitor); Map<PsiVariable, String> varToName = analyzedVars == null ? new HashMap<>() : analyzedVars.varToName; Set<PsiVariable> toWrap = analyzedVars == null ? new HashSet<>() : analyzedVars.toWrap; Set<PsiVariable> toMakeFinal = analyzedVars == null ? new HashSet<>() : analyzedVars.toMakeFinal; for (PsiVariable v : visitor.touched) { if (visitor.rewritten.contains(v)) { toWrap.add(v); if (v instanceof PsiParameter) { varToName.put(v, GenerationUtil.suggestVarName(v.getType(), root, context)); } else { varToName.put(v, v.getName()); } } else { toMakeFinal.add(v); varToName.put(v, v.getName()); } } return analyzedVars == null ? new Result(toMakeFinal, toWrap, varToName) : analyzedVars; }