private static List<CandidateInfo> collectStaticFactoriesInner(PsiNewExpression newExpression) {
    PsiExpressionList argumentList = newExpression.getArgumentList();
    if (argumentList == null) {
      return null;
    }

    final PsiClass psiClass = findClass(newExpression);
    if (psiClass == null) {
      //should not happens: unresolved class reference would be first and inference won't start
      return null;
    }

    final List<CandidateInfo> candidates = new ArrayList<>();
    PsiMethod[] constructors = psiClass.getConstructors();
    if (constructors.length == 0) {
      //default constructor
      constructors = new PsiMethod[] {null};
    }

    PsiFile containingFile = argumentList.getContainingFile();
    final MethodCandidatesProcessor
      processor = new MethodCandidatesProcessor(argumentList, containingFile, new PsiConflictResolver[0], candidates) {
      @Override
      protected boolean isAccepted(@NotNull PsiMethod candidate) {
        return true;
      }

      @Override
      protected PsiClass getContainingClass(@NotNull PsiMethod method) {
        if (newExpression.getAnonymousClass() != null) {
          return PsiTreeUtil.getContextOfType(argumentList, PsiClass.class, false);
        }
        return psiClass;
      }

      @Override
      protected boolean acceptVarargs() {
        return true;
      }
    };
    processor.setArgumentList(argumentList);

    for (PsiMethod constructor : constructors) {
      final PsiTypeParameter[] params = getAllTypeParams(constructor, psiClass);
      final PsiMethod staticFactory = generateStaticFactory(constructor, psiClass, params, newExpression.getClassReference());
      if (staticFactory != null) {
        processor.add(staticFactory, PsiSubstitutor.EMPTY);
      }
    }

    return processor.getResults();
  }
private static List<CandidateInfo> collectStaticFactoriesInner(PsiNewExpression newExpression)