private void highlightReferencedMethodOrClassName(@NotNull PsiJavaCodeReferenceElement element, @Nullable PsiElement resolved) {
    PsiElement parent = element.getParent();
    TextAttributesScheme colorsScheme = myHolder.getColorsScheme();
    DumbService dumbService = DumbService.getInstance(myFile.getProject());
    if (parent instanceof PsiMethodCallExpression methodCall) {
      PsiMethod method = dumbService.computeWithAlternativeResolveEnabled(() -> methodCall.resolveMethod());
      PsiElement methodNameElement = element.getReferenceNameElement();
      if (method != null && methodNameElement != null&& !(methodNameElement instanceof PsiKeyword)) {
        myHolder.add(HighlightNamesUtil.highlightMethodName(method, methodNameElement, false, colorsScheme));
      }
    }
    else if (parent instanceof PsiConstructorCall constructorCall) {
      PsiMethod method = dumbService.computeWithAlternativeResolveEnabled(() -> constructorCall.resolveConstructor());
      PsiMember methodOrClass = method != null ? method : resolved instanceof PsiClass ? (PsiClass)resolved : null;
      if (methodOrClass != null) {
        PsiElement referenceNameElement = element.getReferenceNameElement();
        if(referenceNameElement != null) {
          // exclude type parameters from the highlighted text range
          myHolder.add(HighlightNamesUtil.highlightMethodName(methodOrClass, referenceNameElement, false, colorsScheme));
        }
      }
    }
    else if (resolved instanceof PsiPackage) {
      // highlight package (and the following dot) as a class
      myHolder.add(HighlightNamesUtil.highlightPackage(resolved, element, colorsScheme));
    }
    else if (resolved instanceof PsiClass psiClass) {
      myHolder.add(HighlightNamesUtil.highlightClassName(psiClass, element, colorsScheme));
    }
    else if (element.getParent() instanceof PsiAnnotation) {
      myHolder.add(HighlightNamesUtil.highlightClassName(null, element, colorsScheme));
    }
    else if (PsiTreeUtil.skipParentsOfType(element, PsiJavaCodeReferenceElement.class) instanceof PsiAnnotation) {
      myHolder.add(HighlightNamesUtil.highlightPackage(null, element, colorsScheme));
    }
  }
private void highlightReferencedMethodOrClassName(@NotNull PsiJavaCodeReferenceElement element, @Nullable PsiElement resolved)