Collection<JavaModuleSourceRoot> (@NotNull File dir) { final List<JavaSourceRootDetector> detectors = ContainerUtil.findAll(ProjectStructureDetector.EP_NAME.getExtensions(), JavaSourceRootDetector.class); final RootDetectionProcessor processor = new RootDetectionProcessor(dir, detectors.toArray(new JavaSourceRootDetector[0])); final Map<ProjectStructureDetector,List<DetectedProjectRoot>> rootsMap = processor.runDetectors(); Map<File, JavaModuleSourceRoot> result = new HashMap<>(); for (List<DetectedProjectRoot> roots : rootsMap.values()) { for (DetectedProjectRoot root : roots) { if (root instanceof JavaModuleSourceRoot sourceRoot) { final File directory = sourceRoot.getDirectory(); final JavaModuleSourceRoot oldRoot = result.remove(directory); if (oldRoot != null) { result.put(directory, oldRoot.combineWith(sourceRoot)); } else { result.put(directory, sourceRoot); } } } } return result.values(); }