boolean (@NotNull final String url) { if (myScopeModules.isEmpty() && myIncludedUnloadedModules.isEmpty()) { return false; // optimization } Module candidateModule = null; int maxUrlLength = 0; final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); for (final Module module : myModules) { final String[] contentRootUrls = getModuleContentUrls(module); for (final String contentRootUrl : contentRootUrls) { if (contentRootUrl.length() < maxUrlLength) { continue; } if (!isUrlUnderRoot(url, contentRootUrl)) { continue; } if (contentRootUrl.length() == maxUrlLength) { if (candidateModule == null) { candidateModule = module; } else { // the same content root exists in several modules if (!candidateModule.equals(module)) { candidateModule = ReadAction.compute(() -> { final VirtualFile contentRootFile = VirtualFileManager.getInstance().findFileByUrl(contentRootUrl); if (contentRootFile != null) { return projectFileIndex.getModuleForFile(contentRootFile); } return null; }); } } } else { maxUrlLength = contentRootUrl.length(); candidateModule = module; } } } if (candidateModule != null && myScopeModules.contains(candidateModule)) { final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(candidateModule); final String[] excludeRootUrls = moduleRootManager.getExcludeRootUrls(); for (String excludeRootUrl : excludeRootUrls) { if (isUrlUnderRoot(url, excludeRootUrl)) { return false; } } final String[] sourceRootUrls = moduleRootManager.getSourceRootUrls(); for (String sourceRootUrl : sourceRootUrls) { if (isUrlUnderRoot(url, sourceRootUrl)) { return true; } } } ModuleManager moduleManager = ModuleManager.getInstance(myProject); for (String unloadedModule : myIncludedUnloadedModules) { UnloadedModuleDescription moduleDescription = moduleManager.getUnloadedModuleDescription(unloadedModule); if (moduleDescription != null) { for (VirtualFilePointer pointer : moduleDescription.getContentRoots()) { if (isUrlUnderRoot(url, pointer.getUrl())) { return true; } } } } return false; }