From 27a3789b656a385237083debd770c012d4c1c3d2 Mon Sep 17 00:00:00 2001 From: Ilya Korennoy Date: Fri, 6 Feb 2026 15:38:56 +0400 Subject: [PATCH] IJPL-930 Improve LibraryScopeCache GitOrigin-RevId: 67eb82b8cc8d90d201d04cd1a00ac2e5662131b8 --- .../openapi/roots/impl/LibraryScopeCache.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/platform/analysis-impl/src/com/intellij/openapi/roots/impl/LibraryScopeCache.java b/platform/analysis-impl/src/com/intellij/openapi/roots/impl/LibraryScopeCache.java index b36e934ac2a8..76f1018089eb 100644 --- a/platform/analysis-impl/src/com/intellij/openapi/roots/impl/LibraryScopeCache.java +++ b/platform/analysis-impl/src/com/intellij/openapi/roots/impl/LibraryScopeCache.java @@ -158,15 +158,13 @@ public final class LibraryScopeCache { var libraries = index.findContainingLibraries(virtualFile); var currentSnapshot = WorkspaceModel.getInstance(myProject).getCurrentSnapshot(); - LibraryEntity lib = null; List modulesLibraryUsedIn = new ArrayList<>(); - var exportedDependentsGraph = ModuleExportedDependenciesGraph.getInstance(myProject).exportedDependentsGraph(); for (var library: libraries) { - lib = library; modulesLibraryUsedIn.addAll(findModulesWithLibraryId(library.getSymbolicId(), currentSnapshot, exportedDependentsGraph)); } + LibraryEntity lib = ContainerUtil.getFirstItem(libraries); if (lib != null) { var roots = lib.getRoots().stream() .map(LibraryRoot::getUrl) @@ -340,18 +338,15 @@ public final class LibraryScopeCache { private void addModulesInheritingProjectSdk(SdkId sdkId, ImmutableEntityStorage currentSnapshot, Set result) { var projectSdk = ProjectRootManager.getInstance(myProject).getProjectSdk(); - if (projectSdk == null || !projectSdk.getName().equals(sdkId.getName())) { + if (projectSdk == null || (!projectSdk.getName().equals(sdkId.getName()) && !projectSdk.getSdkType().getName().equals(sdkId.getType()))) { return; } for (var moduleEntity : SequencesKt.toList(currentSnapshot.entities(ModuleEntity.class))) { - for (var dep : moduleEntity.getDependencies()) { - if (dep instanceof InheritedSdkDependency) { - var moduleBridge = ModuleBridges.findModule(moduleEntity, currentSnapshot); - if (moduleBridge != null) { - result.add(moduleBridge); - } - break; + if (ContainerUtil.exists(moduleEntity.getDependencies(), dep -> dep instanceof InheritedSdkDependency)) { + var moduleBridge = ModuleBridges.findModule(moduleEntity, currentSnapshot); + if (moduleBridge != null) { + result.add(moduleBridge); } } }