List<GrStatement> (List<VariableInfo> varInfos, Project project, @Nullable GrExpression initializer) { List<GrStatement> result = new ArrayList<>(); if (varInfos.isEmpty()) return result; GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(project); boolean distinctDeclaration = haveDifferentTypes(varInfos); if (distinctDeclaration) { for (VariableInfo info : varInfos) { result.add(factory.createVariableDeclaration(ArrayUtilRt.EMPTY_STRING_ARRAY, "", info.getType(), info.getName())); } } else { String[] names = new String[varInfos.size()]; for (int i = 0, mustAddLength = varInfos.size(); i < mustAddLength; i++) { names[i] = varInfos.get(i).getName(); } result.add(factory.createVariableDeclaration(ArrayUtilRt.EMPTY_STRING_ARRAY, initializer, varInfos.get(0).getType(), names)); } return result; }