@Override
  public @NotNull Collection<PsiJavaModule> findModules(@NotNull String moduleName, @NotNull GlobalSearchScope scope) {
    GlobalSearchScope excludingScope = new LibSrcExcludingScope(scope);

    Project project = myManager.getProject();
    List<PsiJavaModule> results = new ArrayList<>(JavaModuleNameIndex.getInstance().getModules(moduleName, project, excludingScope));

    Set<VirtualFile> shadowedRoots = new HashSet<>();
    for (VirtualFile manifest : JavaSourceModuleNameIndex.getFilesByKey(moduleName, excludingScope)) {
      VirtualFile root = manifest.getParent().getParent();
      shadowedRoots.add(root);
      results.add(LightJavaModule.create(myManager, root, moduleName));
    }

    for (VirtualFile root : JavaAutoModuleNameIndex.getFilesByKey(moduleName, excludingScope)) {
      if (shadowedRoots.contains(root)) { //already found by MANIFEST attribute
        continue;
      }
      VirtualFile manifest = root.findFileByRelativePath(JarFile.MANIFEST_NAME);
      if (manifest != null && LightJavaModule.claimedModuleName(manifest) != null) {
        continue;
      }
      results.add(LightJavaModule.create(myManager, root, moduleName));
    }

    if (results.isEmpty()) {
      CachedValuesManager valuesManager = CachedValuesManager.getManager(project);
      ProjectRootModificationTracker rootModificationTracker = ProjectRootModificationTracker.getInstance(project);
      for (Module module : ModuleManager.getInstance(project).getModules()) {
        VirtualFile[] sourceRoots = ModuleRootManager.getInstance(module).getSourceRoots(false);
        if (sourceRoots.length > 0) {
          String virtualAutoModuleName = ManifestUtil.lightManifestAttributeValue(module, PsiJavaModule.AUTO_MODULE_NAME);
          if (moduleName.equals(virtualAutoModuleName)) {
            results.add(LightJavaModule.create(myManager, sourceRoots[0], moduleName));
            break;
          }

          String defaultModuleName = valuesManager.getCachedValue(module, () ->
            CachedValueProvider.Result.create(LightJavaModule.moduleName(module.getName()), rootModificationTracker)
          );
          if (moduleName.equals(defaultModuleName)) {
            results.add(LightJavaModule.create(myManager, sourceRoots[0], moduleName));
            break;
          }
        }
      }
    }
    
    return upgradeModules(sortModules(results, scope), moduleName, scope);
  }
@Override
  public @NotNull Collection<PsiJavaModule> findModules(@NotNull String moduleName, @NotNull GlobalSearchScope scope)