void (PsiJavaCodeReferenceElement reference) { final PsiElement qualifier = reference.getQualifier(); if (!(qualifier instanceof PsiJavaCodeReferenceElement qualifierReference)) { return; } final PsiElement parent = reference.getParent(); if (parent instanceof PsiMethodCallExpression || parent instanceof PsiAssignmentExpression || parent instanceof PsiVariable) { return; } final PsiElement element = PsiTreeUtil.getParentOfType(reference, PsiImportStatementBase.class, PsiPackageStatement.class, JavaCodeFragment.class, PsiAnnotation.class); if (element != null && !(element instanceof PsiAnnotation)) { return; } if (!(reference.getContainingFile() instanceof PsiJavaFile containingFile)) { return; } final PsiElement target = reference.resolve(); if (!(target instanceof PsiClass)) { return; } final CodeStyleSettings styleSettings = CodeStyle.getSettings(containingFile); final PsiDocComment containingComment = PsiTreeUtil.getParentOfType(reference, PsiDocComment.class); boolean reportAsInformationInsideJavadoc = false; if (containingComment != null) { if (acceptFqnInJavadoc(containingFile, styleSettings)) { return; } JavaCodeStyleSettings javaSettings = styleSettings.getCustomSettings(JavaCodeStyleSettings.class); if (javaSettings.CLASS_NAMES_IN_JAVADOC == JavaCodeStyleSettings.FULLY_QUALIFY_NAMES_IF_NOT_IMPORTED) { reportAsInformationInsideJavadoc = !ImportHelper.isAlreadyImported(containingFile, reference.getQualifiedName()); } } final PsiElement qualifierTarget = qualifierReference.resolve(); if (!(qualifierTarget instanceof PsiPackage)) { return; } final List<PsiJavaCodeReferenceElement> references = new SmartList<>(); references.add(reference); if (styleSettings.getCustomSettings(JavaCodeStyleSettings.class).INSERT_INNER_CLASS_IMPORTS) { collectInnerClassNames(reference, references); } Collections.reverse(references); PsiResolveHelper resolveHelper = JavaPsiFacade.getInstance(containingFile.getProject()).getResolveHelper(); for (final PsiJavaCodeReferenceElement aReference : references) { final PsiElement referenceTarget = aReference.resolve(); if (!(referenceTarget instanceof PsiClass aClass)) { continue; } final String qualifiedName = aClass.getQualifiedName(); if (qualifiedName == null) { continue; } if (!resolveHelper.isAccessible(aClass, containingFile, null)) { continue; } if (!ImportUtils.nameCanBeImported(qualifiedName, reference)) { continue; } final PsiElement qualifier1 = aReference.getQualifier(); if (qualifier1 != null) { Set<String> nonUniqueReferences = getNonUniqueReferencesFromCache(containingFile); if (nonUniqueReferences.contains(aReference.getReferenceName())) { continue; } PsiElement elementToHighlight = qualifier1; final ProblemHighlightType highlightType; if (reportAsInformationInsideJavadoc || ignoreInModuleStatements && PsiTreeUtil.getParentOfType(reference, PsiUsesStatement.class, PsiProvidesStatement.class) != null || InspectionProjectProfileManager.isInformationLevel(getShortName(), aReference) && isOnTheFly()) { if (!isOnTheFly()) return; highlightType = ProblemHighlightType.INFORMATION; elementToHighlight = aReference; } else { highlightType = ProblemHighlightType.GENERIC_ERROR_OR_WARNING; } final boolean inSameFile = aClass.getContainingFile() == containingFile || ImportHelper.isAlreadyImported(containingFile, qualifiedName); registerError(elementToHighlight, highlightType, inSameFile); } break; } }