@Nullable
  private static GrExpression inferArg(GrSignature signature,
                                       GrParameter[] parameters,
                                       GrParameter parameter,
                                       GrClosureSignatureUtil.ArgInfo<PsiElement> argInfo,
                                       Project project) {
    if (argInfo == null) return null;
    List<PsiElement> arguments = argInfo.args;

    if (argInfo.isMultiArg) { //arguments for Map and varArg
      final PsiType type = parameter.getDeclaredType();
      return GroovyRefactoringUtil.generateArgFromMultiArg(signature.getSubstitutor(), arguments, type, project);
    }
    else {  //arguments for simple parameters
      if (arguments.size() == 1) { //arg exists
        PsiElement arg = arguments.iterator().next();
        if (isVararg(parameter, parameters)) {
          if (arg instanceof GrSafeCastExpression) {
            PsiElement expr = ((GrSafeCastExpression)arg).getOperand();
            if (expr instanceof GrListOrMap && !((GrListOrMap)expr).isMap()) {
              return ((GrListOrMap)expr);
            }
          }
        }

        return (GrExpression)arg;
      }
      else { //arg is skipped. Parameter is optional
        return parameter.getInitializerGroovy();
      }
    }
  }
@Nullable
  private static GrExpression inferArg(GrSignature signature,
                                       GrParameter[] parameters,
                                       GrParameter parameter,
                                       GrClosureSignatureUtil.ArgInfo<PsiElement> argInfo,
                                       Project project)