void (@NotNull PsiFile file, @NotNull InspectionManager manager, @NotNull ProblemsHolder problemsHolder, @NotNull GlobalInspectionContext globalContext, @NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor) { if (!(file instanceof PsiJavaFile javaFile) || FileTypeUtils.isInServerPageFile(file)) return; final ImportsAreUsedVisitor visitor = new ImportsAreUsedVisitor(javaFile); javaFile.accept(visitor); for (PsiImportStatementBase unusedImportStatement : visitor.getUnusedImportStatements()) { PsiJavaCodeReferenceElement reference = unusedImportStatement.getImportReference(); if (reference != null && reference.multiResolve(false).length > 0 && !(PsiTreeUtil.skipWhitespacesForward(unusedImportStatement) instanceof PsiErrorElement)) { problemsHolder.registerProblem(unusedImportStatement, InspectionGadgetsBundle.message("unused.import.problem.descriptor"), new DeleteImportFix()); } } }