private static void filterAlreadyImportedButUnresolved(@NotNull Collection<PsiClass> list, @NotNull PsiFile containingFile) {
    if (!(containingFile instanceof PsiJavaFile javaFile)) return;
    PsiImportList importList = javaFile.getImportList();
    PsiImportDeclaration[] importStatements = importList == null ? PsiImportStatementBase.EMPTY_ARRAY : importList.getAllImportDeclarations();
    Set<String> unresolvedImports = new HashSet<>(importStatements.length);
    for (PsiImportDeclaration statement : importStatements) {
      if (statement instanceof PsiImportStatementBase importStatementBase) {
        PsiJavaCodeReferenceElement ref = importStatementBase.getImportReference();
        String name = ref == null ? null : ref.getReferenceName();
        if (name != null && ref.resolve() == null) unresolvedImports.add(name);
      } else if (statement instanceof PsiImportModuleStatement importModuleStatement) {
        PsiJavaModuleReference ref = importModuleStatement.getModuleReference();
        if (ref != null && ref.resolve() == null) unresolvedImports.add(importModuleStatement.getReferenceName());
      }
    }
    if (unresolvedImports.isEmpty()) return;
    list.removeIf(aClass -> {
      String className = aClass.getName();
      return className != null && unresolvedImports.contains(className);
    });
  }
private static void filterAlreadyImportedButUnresolved(@NotNull Collection<PsiClass> list, @NotNull PsiFile containingFile)