void (@NotNull PsiJavaCodeReferenceElement reference) { super.visitReferenceElement(reference); final PsiElement qualifier = reference.getQualifier(); if (!(qualifier instanceof PsiJavaCodeReferenceElement referenceElement)) { return; } if (PsiTreeUtil.getParentOfType(reference, PsiImportStatementBase.class, PsiPackageStatement.class) != null) { return; } final PsiReferenceParameterList parameterList = referenceElement.getParameterList(); if (parameterList != null && parameterList.getTypeParameterElements().length > 0) { return; } final PsiElement qualifierTarget = referenceElement.resolve(); if (!(qualifierTarget instanceof PsiClass)) { return; } final PsiClass referenceClass = PsiTreeUtil.getParentOfType(reference, PsiClass.class); if (referenceClass == null) { return; } final PsiElement target = reference.resolve(); if (!(target instanceof PsiClass aClass) || !PsiUtil.isAccessible(aClass, referenceClass, null)) { return; } ProblemHighlightType highlightType = ProblemHighlightType.GENERIC_ERROR_OR_WARNING; final boolean needsImport = (!referenceClass.equals(qualifierTarget) || !ClassUtils.isInsideClassBody(reference, referenceClass)) && (PsiTreeUtil.isAncestor(referenceClass, qualifierTarget, true) || !PsiTreeUtil.isAncestor(qualifierTarget, referenceClass, true)); if (needsImport) { if (ignoreReferencesNeedingImport) { if (!isOnTheFly()) return; highlightType = ProblemHighlightType.INFORMATION; } if (!canBeImported(aClass)) { return; } } final PsiClass containingClass = aClass.getContainingClass(); if (containingClass == null || !containingClass.equals(qualifierTarget)) { return; } final String shortName = aClass.getName(); if (!isReferenceToTarget(shortName, aClass, reference)) { return; } registerError(qualifier, highlightType, aClass); }