@Nullable private HighlightInfo processImport(@NotNull PsiImportStatementBase importStatement, @NotNull HighlightDisplayKey unusedImportKey) { // jsp include directive hack if (importStatement instanceof JspxImportStatement && ((JspxImportStatement)importStatement).isForeignFileImport()) return null; if (PsiUtilCore.hasErrorElementChild(importStatement)) return null; boolean isRedundant = myRefCountHolder.isRedundant(importStatement); if (!isRedundant && !(importStatement instanceof PsiImportStaticStatement)) { //check import from same package String packageName = ((PsiClassOwner)importStatement.getContainingFile()).getPackageName(); PsiJavaCodeReferenceElement reference = importStatement.getImportReference(); PsiElement resolved = reference == null ? null : reference.resolve(); if (resolved instanceof PsiPackage) { isRedundant = packageName.equals(((PsiPackage)resolved).getQualifiedName()); } else if (resolved instanceof PsiClass && !importStatement.isOnDemand()) { String qName = ((PsiClass)resolved).getQualifiedName(); if (qName != null) { String name = ((PsiClass)resolved).getName(); isRedundant = qName.equals(packageName + '.' + name); } } } if (isRedundant) { return registerRedundantImport(importStatement, unusedImportKey); } int entryIndex = myStyleManager.findEntryIndex(importStatement); if (entryIndex < myCurrentEntryIndex) { myHasMissortedImports = true; } myCurrentEntryIndex = entryIndex; return null; }