void () { myProgress.setIndeterminate(true); final Map<File, ModuleDescriptor> contentRootToModules = new HashMap<>(); try { myProgress.pushState(); List<DetectedSourceRoot> processedRoots = new ArrayList<>(); for (DetectedSourceRoot root : getSourceRootsToScan()) { final File sourceRoot = root.getDirectory(); if (isIgnoredName(sourceRoot)) { continue; } myProgress.setText(JavaUiBundle.message("module.insight.scan.progress.text.scanning", sourceRoot.getPath())); final HashSet<String> usedPackages = new HashSet<>(); mySourceRootToReferencedPackagesMap.put(sourceRoot, usedPackages); final HashSet<String> selfPackages = new HashSet<>(); addExportedPackages(sourceRoot, selfPackages); scanSources(sourceRoot, ProjectFromSourcesBuilderImpl.getPackagePrefix(root), usedPackages, selfPackages) ; usedPackages.removeAll(selfPackages); processedRoots.add(root); } myProgress.popState(); myProgress.pushState(); myProgress.setText(JavaUiBundle.message("module.insight.scan.progress.text.building.modules.layout")); Map<File, ModuleCandidate> rootToModule = new HashMap<>(); for (DetectedSourceRoot sourceRoot : processedRoots) { final File srcRoot = sourceRoot.getDirectory(); final File moduleContentRoot = isEntryPointRoot(srcRoot) ? srcRoot : srcRoot.getParentFile(); rootToModule.computeIfAbsent(moduleContentRoot, file -> new ModuleCandidate(moduleContentRoot)).myRoots.add(sourceRoot); } maximizeModuleFolders(rootToModule.values()); for (Map.Entry<File, ModuleCandidate> entry : rootToModule.entrySet()) { File root = entry.getKey(); ModuleCandidate module = entry.getValue(); ModuleDescriptor moduleDescriptor = createModuleDescriptor(module.myFolder, module.myRoots); contentRootToModules.put(root, moduleDescriptor); } buildModuleDependencies(contentRootToModules); myProgress.popState(); } catch (ProcessCanceledException ignored) { } addModules(contentRootToModules.values()); }