private static @Nullable UsageType getClassUsageType(@NotNull PsiElement element, UsageTarget @NotNull [] targets) {
    final PsiJavaCodeReferenceElement codeReference = PsiTreeUtil.getParentOfType(element, PsiJavaCodeReferenceElement.class);
    if(codeReference != null && isNestedClassOf(codeReference,targets)){
      return UsageType.CLASS_NESTED_CLASS_ACCESS;
    }

    if (element.getParent() instanceof PsiAnnotation &&
        element == ((PsiAnnotation)element.getParent()).getNameReferenceElement()) {
      return UsageType.ANNOTATION;
    }

    if (element.getParent() instanceof PsiTypeElement && element.getParent().getParent() instanceof PsiPattern) {
      return UsageType.PATTERN;
    }

    if (PsiTreeUtil.getParentOfType(element, PsiImportStatementBase.class, false) != null) return UsageType.CLASS_IMPORT;
    PsiReferenceList referenceList = PsiTreeUtil.getParentOfType(element, PsiReferenceList.class);
    if (referenceList != null) {
      PsiElement parent = referenceList.getParent();
      if (parent instanceof PsiClass aClass) {
        if (aClass.getExtendsList() == referenceList || aClass.getImplementsList() == referenceList) return UsageType.CLASS_EXTENDS_IMPLEMENTS_LIST;
        if (aClass.getPermitsList() == referenceList) return UsageType.CLASS_PERMITS_LIST;
      }
      if (referenceList.getParent() instanceof PsiMethod) return UsageType.CLASS_METHOD_THROWS_LIST;
    }
    if (PsiTreeUtil.getParentOfType(element, PsiTypeParameterList.class) != null ||
        PsiTreeUtil.getParentOfType(element, PsiReferenceParameterList.class) != null) {
      return UsageType.TYPE_PARAMETER;
    }

    PsiTypeCastExpression castExpression = PsiTreeUtil.getParentOfType(element, PsiTypeCastExpression.class);
    if (castExpression != null) {
      if (PsiTreeUtil.isAncestor(castExpression.getCastType(), element, true)) return UsageType.CLASS_CAST_TO;
    }

    PsiInstanceOfExpression instanceOfExpression = PsiTreeUtil.getParentOfType(element, PsiInstanceOfExpression.class);
    if (instanceOfExpression != null) {
      if (PsiTreeUtil.isAncestor(instanceOfExpression.getCheckType(), element, true)) return UsageType.CLASS_INSTANCE_OF;
    }

    if (PsiTreeUtil.getParentOfType(element, PsiClassObjectAccessExpression.class) != null) return UsageType.CLASS_CLASS_OBJECT_ACCESS;

    final PsiMethodReferenceExpression methodReferenceExpression = PsiTreeUtil.getParentOfType(element, PsiMethodReferenceExpression.class);
    if (methodReferenceExpression != null && methodReferenceExpression.isConstructor()) {
      final PsiElement qualifier = methodReferenceExpression.getQualifier();
      if (qualifier instanceof PsiTypeElement && ((PsiTypeElement)qualifier).getType() instanceof PsiArrayType) {
        return UsageType.CLASS_NEW_ARRAY;
      }
      return UsageType.CLASS_NEW_OPERATOR;
    }

    if (element instanceof PsiReferenceExpression expression && expression.resolve() instanceof PsiClass) {
      return UsageType.CLASS_STATIC_MEMBER_ACCESS;
    }

    final PsiParameter psiParameter = PsiTreeUtil.getParentOfType(element, PsiParameter.class);
    if (psiParameter != null) {
      final PsiElement scope = psiParameter.getDeclarationScope();
      if (scope instanceof PsiMethod) return UsageType.CLASS_METHOD_PARAMETER_DECLARATION;
      if (scope instanceof PsiCatchSection) return UsageType.CLASS_CATCH_CLAUSE_PARAMETER_DECLARATION;
      if (scope instanceof PsiForeachStatement) return UsageType.CLASS_LOCAL_VAR_DECLARATION;
      return null;
    }

    PsiField psiField = PsiTreeUtil.getParentOfType(element, PsiField.class);
    if (psiField != null) {
      if (PsiTreeUtil.isAncestor(psiField.getTypeElement(), element, true)) return UsageType.CLASS_FIELD_DECLARATION;
    }

    PsiLocalVariable psiLocalVar = PsiTreeUtil.getParentOfType(element, PsiLocalVariable.class);
    if (psiLocalVar != null) {
      if (PsiTreeUtil.isAncestor(psiLocalVar.getTypeElement(), element, true)) return UsageType.CLASS_LOCAL_VAR_DECLARATION;
    }

    PsiMethod psiMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
    if (psiMethod != null) {
      final PsiTypeElement retType = psiMethod.getReturnTypeElement();
      if (retType != null && PsiTreeUtil.isAncestor(retType, element, true)) return UsageType.CLASS_METHOD_RETURN_TYPE;
    }

    final PsiNewExpression psiNewExpression = PsiTreeUtil.getParentOfType(element, PsiNewExpression.class);
    if (psiNewExpression != null) {
      final PsiJavaCodeReferenceElement classReference = psiNewExpression.getClassOrAnonymousClassReference();
      if (classReference != null && PsiTreeUtil.isAncestor(classReference, element, false)) {
        if (isAnonymousClassOf(psiNewExpression.getAnonymousClass(), targets)) {
          return UsageType.CLASS_ANONYMOUS_NEW_OPERATOR;
        }
        if (psiNewExpression.isArrayCreation()) {
          return UsageType.CLASS_NEW_ARRAY;
        }
        return UsageType.CLASS_NEW_OPERATOR;
      }
    }

    return null;
  }
private static @Nullable UsageType getClassUsageType(@NotNull PsiElement element, UsageTarget @NotNull [] targets)