void (@NotNull HighlightInfoHolder holder, @NotNull PsiJavaFile javaFile, @NotNull PsiImportStatementBase importStatement, @NotNull HighlightDisplayKey unusedImportKey) { // jsp include directive hack if (importStatement.isForeignFileImport()) return; if (PsiUtilCore.hasErrorElementChild(importStatement)) return; boolean isRedundant = myRefCountHolder.isRedundant(importStatement); if (!isRedundant && !(importStatement instanceof PsiImportStaticStatement)) { // check import from the same package String packageName = javaFile.getPackageName(); PsiJavaCodeReferenceElement reference = importStatement.getImportReference(); PsiElement resolved = reference == null ? null : reference.resolve(); if (resolved instanceof PsiPackage psiPackage) { isRedundant = packageName.equals(psiPackage.getQualifiedName()); } else if (resolved instanceof PsiClass psiClass && !importStatement.isOnDemand()) { String qName = psiClass.getQualifiedName(); if (qName != null) { String name = psiClass.getName(); isRedundant = qName.equals(packageName + '.' + name); } } } if (isRedundant) { registerRedundantImport(holder, importStatement, unusedImportKey); return; } int entryIndex = JavaCodeStyleManager.getInstance(myProject).findEntryIndex(importStatement); if (entryIndex < myCurrentEntryIndex && myOptimizeImportsFix == null) { // mis-sorted imports found myOptimizeImportsFix = QuickFixFactory.getInstance().createOptimizeImportsFix(true, myFile); } myCurrentEntryIndex = entryIndex; }