@Override
  protected void invoke(@NotNull PsiElement element) {
    final PsiImportStatementBase importStatementBase = (PsiImportStatementBase)element;
    final PsiJavaFile javaFile = (PsiJavaFile)importStatementBase.getContainingFile();
    final PsiManager manager = importStatementBase.getManager();
    final PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
    if (importStatementBase instanceof PsiImportStatement importStatement) {
      final PsiClass[] classes = javaFile.getClasses();
      final String qualifiedName = importStatement.getQualifiedName();
      final ClassCollector visitor = new ClassCollector(qualifiedName);
      for (PsiClass aClass : classes) {
        aClass.accept(visitor);
      }
      final PsiClass[] importedClasses = visitor.getImportedClasses();
      Arrays.sort(importedClasses, new PsiClassComparator());
      createImportStatements(importStatement, importedClasses, factory::createImportStatement);
    }
    else if (importStatementBase instanceof PsiImportStaticStatement) {
      PsiClass targetClass = ((PsiImportStaticStatement)importStatementBase).resolveTargetClass();
      if (targetClass != null) {
        String[] members = ImportsUtil.collectReferencesThrough(javaFile,
                                                                importStatementBase.getImportReference(),
                                                                (PsiImportStaticStatement)importStatementBase)
          .stream()
          .map(PsiReference::resolve)
          .filter(resolve -> resolve instanceof PsiMember)
          .map(member -> ((PsiMember)member).getName())
          .distinct()
          .filter(Objects::nonNull)
          .toArray(String[]::new);

        createImportStatements(importStatementBase,
                               members,
                               member -> factory.createImportStaticStatement(targetClass, member));
      }
    }
  }
@Override
  protected void invoke(@NotNull PsiElement element)