private static GrStatement @NotNull [] createResultStatement(ExtractInfoHelper helper) {
    VariableInfo[] outputVars = helper.getOutputVariableInfos();

    PsiType type = helper.getOutputType();
    GrStatement[] statements = helper.getStatements();
    GrMethodCallExpression callExpression = createMethodCall(helper);

    if ((outputVars.length == 0 || PsiTypes.voidType().equals(type)) && !helper.hasReturnValue()) return new GrStatement[]{callExpression};
    GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(helper.getProject());
    if (helper.hasReturnValue()) {
      return new GrStatement[]{factory.createStatementFromText("return " + callExpression.getText())};
    }

    LOG.assertTrue(outputVars.length > 0);

    final List<VariableInfo> mustAdd = mustAddVariableDeclaration(statements, outputVars);
    if (mustAdd.isEmpty()) {
      return new GrStatement[]{
        createAssignment(outputVars, callExpression, helper.getProject())
      };
    }
    else if (mustAdd.size() == outputVars.length && outputVars.length == 1) {
      return new GrVariableDeclaration[]{
        factory.createVariableDeclaration(ArrayUtilRt.EMPTY_STRING_ARRAY, callExpression, outputVars[0].getType(), outputVars[0].getName())
      };
    }
    else if (varsAreEqual(mustAdd, outputVars)) {
      return createTupleDeclaration(outputVars, callExpression, helper.getProject());
    }
    else {
      final List<GrStatement> result = generateVarDeclarations(mustAdd, helper.getProject(), null);
      result.add(createAssignment(outputVars, callExpression, helper.getProject()));
      return result.toArray(GrStatement.EMPTY_ARRAY);
    }
  }
private static GrStatement @NotNull [] createResultStatement(ExtractInfoHelper helper)