static void checkConstructorCall(@NotNull Project project, @NotNull PsiClassType.ClassResolveResult typeResolveResult,
                                   @NotNull PsiConstructorCall constructorCall,
                                   @NotNull PsiType type,
                                   @Nullable PsiJavaCodeReferenceElement classReference,
                                   @NotNull JavaSdkVersion javaSdkVersion,
                                   @Nullable PsiElement elementToHighlight,
                                   @NotNull Consumer<? super HighlightInfo.Builder> errorSink) {
    if (elementToHighlight == null) return;
    PsiExpressionList list = constructorCall.getArgumentList();
    if (list == null) return;
    PsiClass aClass = typeResolveResult.getElement();
    if (aClass == null) return;
    PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(project).getResolveHelper();
    PsiClass accessObjectClass = null;
    if (constructorCall instanceof PsiNewExpression) {
      PsiExpression qualifier = ((PsiNewExpression)constructorCall).getQualifier();
      if (qualifier != null) {
        accessObjectClass = (PsiClass)PsiUtil.getAccessObjectClass(qualifier).getElement();
      }
    }
    if (classReference != null && !resolveHelper.isAccessible(aClass, constructorCall, accessObjectClass)) {
      String description = HighlightUtil.accessProblemDescription(classReference, aClass, typeResolveResult);
      PsiElement element = ObjectUtils.notNull(classReference.getReferenceNameElement(), classReference);
      HighlightInfo.Builder info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(element).descriptionAndTooltip(description);
      HighlightFixUtil.registerAccessQuickFixAction(info, element.getTextRange(), aClass, classReference, null, null);
      errorSink.accept(info);
      return;
    }
    PsiMethod[] constructors = aClass.getConstructors();

    if (constructors.length == 0) {
      if (!list.isEmpty()) {
        String constructorName = aClass.getName();
        String argTypes = buildArgTypesList(list, false);
        String description = JavaErrorBundle.message("wrong.constructor.arguments", constructorName + "()", argTypes);
        String tooltip = createMismatchedArgumentsHtmlTooltip(list, null, PsiParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);
        HighlightInfo.Builder info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(list).description(description).escapedToolTip(tooltip).navigationShift(+1);
        if (classReference != null) {
          ConstructorParametersFixer.registerFixActions(classReference, constructorCall, info, getFixRange(list));
        }
        TextRange textRange = constructorCall.getTextRange();
        QuickFixAction.registerQuickFixActions(
          info, textRange, QuickFixFactory.getInstance().createCreateConstructorFromUsageFixes(constructorCall)
        );
        RemoveRedundantArgumentsFix.registerIntentions(list, info, getFixRange(list));
        errorSink.accept(info);
        return;
      }
      if (classReference != null && aClass.hasModifierProperty(PsiModifier.PROTECTED) && callingProtectedConstructorFromDerivedClass(constructorCall, aClass)) {
        HighlightInfo.Builder info = buildAccessProblem(classReference, aClass, typeResolveResult);
        errorSink.accept(info);
      }
      else if (aClass.isInterface() && constructorCall instanceof PsiNewExpression) {
        PsiReferenceParameterList typeArgumentList = ((PsiNewExpression)constructorCall).getTypeArgumentList();
        if (typeArgumentList.getTypeArguments().length > 0) {
          HighlightInfo.Builder info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeArgumentList)
            .descriptionAndTooltip(JavaErrorBundle.message("anonymous.class.implements.interface.cannot.have.type.arguments"));
          errorSink.accept(info);
        }
      }
      return;
    }

    PsiElement place = list;
    if (constructorCall instanceof PsiNewExpression) {
      PsiAnonymousClass anonymousClass = ((PsiNewExpression)constructorCall).getAnonymousClass();
      if (anonymousClass != null) place = anonymousClass;
    }

    JavaResolveResult[] results = resolveHelper.multiResolveConstructor((PsiClassType)type, list, place);
    MethodCandidateInfo result = null;
    if (results.length == 1) result = (MethodCandidateInfo)results[0];

    PsiMethod constructor = result == null ? null : result.getElement();

    boolean applicable = true;
    try {
      PsiDiamondType diamondType = constructorCall instanceof PsiNewExpression ? PsiDiamondType.getDiamondType((PsiNewExpression)constructorCall) : null;
      JavaResolveResult staticFactory = diamondType != null ? diamondType.getStaticFactory() : null;
      if (staticFactory instanceof MethodCandidateInfo) {
        if (((MethodCandidateInfo)staticFactory).isApplicable()) {
          result = (MethodCandidateInfo)staticFactory;
          if (constructor == null) {
            constructor = ((MethodCandidateInfo)staticFactory).getElement();
          }
        }
        else {
          applicable = false;
        }
      }
      else {
        applicable = result != null && result.isApplicable();
      }
    }
    catch (IndexNotReadyException ignored) {
    }
    boolean reported = false;
    if (constructor == null) {
      if (IncompleteModelUtil.isIncompleteModel(list) &&
          ContainerUtil.exists(results, r -> r instanceof MethodCandidateInfo info && info.isPotentiallyCompatible() == ThreeState.YES) &&
          ContainerUtil.exists(list.getExpressions(), e -> IncompleteModelUtil.mayHaveUnknownTypeDueToPendingReference(e))) {
        return;
      }
      String name = aClass.getName();
      name += buildArgTypesList(list, true);
      String description = JavaErrorBundle.message("cannot.resolve.constructor", name);
      HighlightInfo.Builder info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
        .range(elementToHighlight).descriptionAndTooltip(description);
      TextRange fixRange = getFixRange(elementToHighlight);
      WrapExpressionFix.registerWrapAction(results, list.getExpressions(), info, fixRange);
      registerFixesOnInvalidConstructorCall(info, constructorCall, classReference, list, aClass, constructors, results, fixRange);
      errorSink.accept(info);
      reported = true;
    }
    else if (classReference != null &&
             (!result.isAccessible() ||
              constructor.hasModifierProperty(PsiModifier.PROTECTED) && callingProtectedConstructorFromDerivedClass(constructorCall, aClass))) {
      HighlightInfo.Builder info = buildAccessProblem(classReference, constructor, result);
      errorSink.accept(info);
      reported = true;
    }
    else if (!applicable) {
      HighlightInfo.Builder info = createIncompatibleCallHighlightInfo(list, result, errorSink);
      if (info != null) {
        JavaResolveResult[] methodCandidates = results;
        if (constructorCall instanceof PsiNewExpression) {
          methodCandidates = resolveHelper.getReferencedMethodCandidates((PsiCallExpression)constructorCall, true);
        }
        registerFixesOnInvalidConstructorCall(info, constructorCall, classReference, list, aClass, constructors, methodCandidates, getFixRange(list));
        registerMethodReturnFixAction(info, result, constructorCall);
        errorSink.accept(info);
        reported = true;
      }
    }
    else if (constructorCall instanceof PsiNewExpression) {
      PsiReferenceParameterList typeArgumentList = ((PsiNewExpression)constructorCall).getTypeArgumentList();
      HighlightInfo.Builder info = GenericsHighlightUtil.checkReferenceTypeArgumentList(constructor, typeArgumentList, result.getSubstitutor(), false, javaSdkVersion);
      if (info != null) {
        errorSink.accept(info);
        reported = true;
      }
    }

    HighlightInfo.Builder info = result == null || reported ? null : checkVarargParameterErasureToBeAccessible(result, constructorCall);
    if (result != null && info == null && !reported) {
      info = createIncompatibleTypeHighlightInfo(constructorCall, resolveHelper, result, constructorCall);
    }
    errorSink.accept(info);
  }
static void checkConstructorCall(@NotNull Project project, @NotNull PsiClassType.ClassResolveResult typeResolveResult,
                                   @NotNull PsiConstructorCall constructorCall,
                                   @NotNull PsiType type,
                                   @Nullable PsiJavaCodeReferenceElement classReference,
                                   @NotNull JavaSdkVersion javaSdkVersion,
                                   @Nullable PsiElement elementToHighlight,
                                   @NotNull Consumer<? super HighlightInfo.Builder> errorSink)