use of com.intellij.openapi.module.impl.scopes.ModulesScope in project intellij-community by JetBrains.
the class LibraryScopeCache method calcLibraryUseScope.
@NotNull
private GlobalSearchScope calcLibraryUseScope(@NotNull List<OrderEntry> entries) {
Set<Module> modulesWithLibrary = new THashSet<>(entries.size());
Set<Module> modulesWithSdk = new THashSet<>(entries.size());
for (OrderEntry entry : entries) {
(entry instanceof JdkOrderEntry ? modulesWithSdk : modulesWithLibrary).add(entry.getOwnerModule());
}
modulesWithSdk.removeAll(modulesWithLibrary);
// optimisation: if the library attached to all modules (often the case with JDK) then replace the 'union of all modules' scope with just 'project'
if (modulesWithSdk.size() + modulesWithLibrary.size() == ModuleManager.getInstance(myProject).getModules().length) {
return GlobalSearchScope.allScope(myProject);
}
List<GlobalSearchScope> united = ContainerUtil.newArrayList();
if (!modulesWithSdk.isEmpty()) {
united.add(new ModulesScope(modulesWithSdk, myProject));
united.add(myLibrariesOnlyScope.intersectWith(new LibraryRuntimeClasspathScope(myProject, modulesWithSdk)));
} else {
united.add(myLibrariesOnlyScope);
}
for (Module module : modulesWithLibrary) {
united.add(GlobalSearchScope.moduleWithDependentsScope(module));
}
return GlobalSearchScope.union(united.toArray(new GlobalSearchScope[united.size()]));
}
Aggregations