@NotNull
  private static List<ModuleFiles> collectClassFiles(@NotNull Project project) {
    ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
    indicator.setIndeterminate(true);
    indicator.setText(JavaRefactoringBundle.message("generate.module.descriptors.scanning.message"));

    Map<String, JavaModuleSettingsEntity> moduleSettingsByName = new HashMap<>();
    final Iterator<JavaModuleSettingsEntity> iterator = WorkspaceModel.getInstance(project).getCurrentSnapshot()
      .entities(JavaModuleSettingsEntity.class).iterator();
    while (iterator.hasNext()) {
      final JavaModuleSettingsEntity moduleSettings = iterator.next();
      moduleSettingsByName.put(moduleSettings.getModule().getName(), moduleSettings);
    }

    List<ModuleFiles> moduleFiles = new ArrayList<>();
    for (Module module : ModuleManager.getInstance(project).getModules()) {
      if (!mayContainModuleInfo(module)) continue;
      try {
        Path production = null;
        final JavaModuleSettingsEntity moduleSettings = moduleSettingsByName.get(module.getName());
        if (moduleSettings != null) {
          final VirtualFileUrl compilerOutput = moduleSettings.getCompilerOutput();
          if (compilerOutput != null) {
            final String url = VirtualFileManager.extractPath(compilerOutput.getUrl());
            final Path path = Paths.get(url);
            production = Files.exists(path) ? path : null;
          }
        }

        if (production == null) {
          final String url = CompilerPaths.getModuleOutputPath(module, false);
          if (url != null) {
            final Path path = Paths.get(url);
            production = Files.exists(path) ? path : null;
          }
        }

        moduleFiles.add(new ModuleFiles(module, collectClassFiles(production)));
      }
      catch (IOException e) {
        NotificationGroupManager.getInstance().getNotificationGroup("Failed to generate module descriptors")
          .createNotification(getTitle(), JavaRefactoringBundle.message("generate.module.descriptors.io.exceptions.message", module.getName()), NotificationType.ERROR)
          .setImportant(true)
          .notify(project);
        return Collections.emptyList();
      }
    }
    if (moduleFiles.isEmpty()) {
      NotificationGroupManager.getInstance().getNotificationGroup("Failed to generate module descriptors")
        .createNotification(getTitle(), JavaRefactoringBundle.message("generate.module.descriptors.no.suitable.modules.message"), NotificationType.WARNING)
        .setImportant(true)
        .notify(project);
    }
    return moduleFiles;
  }
@NotNull
  private static List<ModuleFiles> collectClassFiles(@NotNull Project project)