public static PsiType getTypeByMethod(@NotNull PsiElement context,
                                        PsiExpressionList argumentList,
                                        PsiElement parentMethod,
                                        boolean varargs,
                                        PsiSubstitutor substitutor,
                                        boolean inferParent) {
    if (parentMethod instanceof PsiMethod) {
      final PsiParameter[] parameters = ((PsiMethod)parentMethod).getParameterList().getParameters();
      if (parameters.length == 0) return null;
      final PsiExpression[] args = argumentList.getExpressions();
      if (!((PsiMethod)parentMethod).isVarArgs() && parameters.length != args.length && !inferParent) return null;
      PsiElement arg = context;
      while (arg.getParent() instanceof PsiParenthesizedExpression) {
        arg = arg.getParent();
      }
      final int i = ArrayUtilRt.find(args, arg);
      if (i < 0) return null;
      final PsiType parameterType = substitutor != null ? substitutor.substitute(getParameterType(parameters, i, varargs)) : null;
      final boolean isRaw = substitutor != null && PsiUtil.isRawSubstitutor((PsiMethod)parentMethod, substitutor);
      return isRaw ? TypeConversionUtil.erasure(parameterType) : parameterType;
    }
    return null;
  }
public static PsiType getTypeByMethod(@NotNull PsiElement context,
                                        PsiExpressionList argumentList,
                                        PsiElement parentMethod,
                                        boolean varargs,
                                        PsiSubstitutor substitutor,
                                        boolean inferParent)