From 666c4f449fe3c705d22699c42d247f13eb289434 Mon Sep 17 00:00:00 2001 From: Alexander Koshevoy Date: Mon, 6 Oct 2025 19:26:24 +0200 Subject: [PATCH] [projectModel] Partition "Global Libraries" per eel environment and select via Project (IJPL-175311) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Application‑level libraries ("Global Libraries" in UI) must be isolated by the environment, so each EEL environment sees only its own library set. This prevents cross‑environment leakage and aligns library scoping with SDK scoping. Notes - Environment choice is derived from the passed `Project` (carrier of the already‑resolved `EelMachine`), so selection is synchronous and safe for this API surface. - API names stay as they are; documentation clarifies that the `Project` parameter selects the environment for the application‑level table and does not turn it into a project‑level table. - In the Project Structure UI, the existing environment‑scoped modifiable model remains owned by the UI; outside the UI, callers get a standalone modifiable model for the chosen environment. GitOrigin-RevId: e88445929d19012d029e79d44f09f694aba8df6f --- .../impl/elements/LibraryElementType.java | 2 +- .../RepositoryLibrarySynchronizer.kt | 4 +-- .../repositoryLibraryIdSynchronizers.kt | 9 ++--- .../roots/IdeaModifiableModelsProvider.java | 21 ++++++++++-- .../GlobalLibrariesConfigurable.java | 2 +- .../StructureConfigurableContext.java | 2 +- platform/lang-api/api-dump-experimental.txt | 2 ++ .../roots/ModifiableModelsProvider.java | 23 +++++++++++++ .../PlatformModifiableModelsProvider.java | 5 +++ .../LibraryRootPortableFilePathResolver.kt | 2 +- .../roots/IndexableEntityProviderMethods.kt | 2 +- .../api-dump-experimental.txt | 2 ++ .../libraries/LibraryTablesRegistrar.java | 33 +++++++++++++++++-- .../openapi/roots/libraries/LibraryUtil.java | 8 ++++- .../libraries/LibraryTablesRegistrarImpl.java | 15 +++++++-- .../module/ModuleDependencyIndexImpl.kt | 5 +++ .../conversion/EclipseClasspathReader.java | 2 +- .../EclipseUserLibrariesHelper.java | 2 +- .../KotlinWithLibraryConfigurator.kt | 2 +- .../plugin/impl/facet/PythonFacetUtil.java | 2 +- 20 files changed, 122 insertions(+), 23 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/packaging/impl/elements/LibraryElementType.java b/java/compiler/impl/src/com/intellij/packaging/impl/elements/LibraryElementType.java index 0d84961e4474..75bc9eeb042c 100644 --- a/java/compiler/impl/src/com/intellij/packaging/impl/elements/LibraryElementType.java +++ b/java/compiler/impl/src/com/intellij/packaging/impl/elements/LibraryElementType.java @@ -47,7 +47,7 @@ public class LibraryElementType extends ComplexPackagingElementType getAllLibraries(ArtifactEditorContext context) { List libraries = new ArrayList<>(); - ContainerUtil.addAll(libraries, LibraryTablesRegistrar.getInstance().getLibraryTable().getLibraries()); + ContainerUtil.addAll(libraries, LibraryTablesRegistrar.getInstance().getGlobalLibraryTable(context.getProject()).getLibraries()); ContainerUtil.addAll(libraries, LibraryTablesRegistrar.getInstance().getLibraryTable(context.getProject()).getLibraries()); return libraries; } diff --git a/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibrarySynchronizer.kt b/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibrarySynchronizer.kt index 90d0909c764c..764a46b66bc0 100644 --- a/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibrarySynchronizer.kt +++ b/java/idea-ui/src/com/intellij/jarRepository/RepositoryLibrarySynchronizer.kt @@ -42,10 +42,10 @@ private class RepositoryLibrarySynchronizer : ProjectActivity { val synchronizationQueue = project.serviceAsync() val synchronizer = ChangedRepositoryLibraryIdSynchronizer(synchronizationQueue) val globalLibSynchronizer = GlobalChangedRepositoryLibraryIdSynchronizer(synchronizationQueue, disposable) - for (libraryTable in getGlobalAndCustomLibraryTables()) { + for (libraryTable in getGlobalAndCustomLibraryTables(project)) { libraryTable.addListener(globalLibSynchronizer, disposable) } - installOnExistingLibraries(globalLibSynchronizer, disposable) + installOnExistingLibraries(project, globalLibSynchronizer, disposable) project.messageBus.connect(disposable).subscribe(WorkspaceModelTopics.CHANGED, synchronizer) synchronizationQueue.requestAllLibrariesSynchronization() } diff --git a/java/idea-ui/src/com/intellij/jarRepository/repositoryLibraryIdSynchronizers.kt b/java/idea-ui/src/com/intellij/jarRepository/repositoryLibraryIdSynchronizers.kt index 11eae4bb51a5..9d642e626c4b 100644 --- a/java/idea-ui/src/com/intellij/jarRepository/repositoryLibraryIdSynchronizers.kt +++ b/java/idea-ui/src/com/intellij/jarRepository/repositoryLibraryIdSynchronizers.kt @@ -2,6 +2,7 @@ package com.intellij.jarRepository import com.intellij.openapi.Disposable +import com.intellij.openapi.project.Project import com.intellij.openapi.roots.RootProvider import com.intellij.openapi.roots.impl.libraries.LibraryEx import com.intellij.openapi.roots.libraries.Library @@ -42,15 +43,15 @@ internal class GlobalChangedRepositoryLibraryIdSynchronizer(private val queue: L } } -internal fun installOnExistingLibraries(listener: RootProvider.RootSetChangedListener, disposable: Disposable) { - getGlobalAndCustomLibraryTables() +internal fun installOnExistingLibraries(project: Project, listener: RootProvider.RootSetChangedListener, disposable: Disposable) { + getGlobalAndCustomLibraryTables(project) .flatMap { it.libraries.asIterable() } .filterIsInstance() .forEach { it.rootProvider.addRootSetChangedListener(listener, disposable) } } -internal fun getGlobalAndCustomLibraryTables(): Sequence { - return LibraryTablesRegistrar.getInstance().customLibraryTables.asSequence() + LibraryTablesRegistrar.getInstance().libraryTable +internal fun getGlobalAndCustomLibraryTables(project: Project): Sequence { + return LibraryTablesRegistrar.getInstance().customLibraryTables.asSequence() + LibraryTablesRegistrar.getInstance().getGlobalLibraryTable(project) } internal class ChangedRepositoryLibraryIdSynchronizer(private val queue: LibraryIdSynchronizationQueue) : WorkspaceModelChangeListener { diff --git a/java/idea-ui/src/com/intellij/openapi/roots/IdeaModifiableModelsProvider.java b/java/idea-ui/src/com/intellij/openapi/roots/IdeaModifiableModelsProvider.java index 3ac3f4562dd8..c4855e92c677 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/IdeaModifiableModelsProvider.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/IdeaModifiableModelsProvider.java @@ -85,9 +85,7 @@ public final class IdeaModifiableModelsProvider implements ModifiableModelsProvi if (!project.isInitialized()) { continue; } - StructureConfigurableContext context = getProjectStructureContext(project); - LibraryTableModifiableModelProvider provider = context != null ? context.createModifiableModelProvider(LibraryTablesRegistrar.APPLICATION_LEVEL) : null; - final LibraryTable.ModifiableModel modifiableModel = provider != null ? provider.getModifiableModel() : null; + final LibraryTable.ModifiableModel modifiableModel = getGlobalModifiableModel(project); if (modifiableModel != null) { return modifiableModel; } @@ -95,6 +93,17 @@ public final class IdeaModifiableModelsProvider implements ModifiableModelsProvi return LibraryTablesRegistrar.getInstance().getLibraryTable().getModifiableModel(); } + @Override + public @NotNull LibraryTable.ModifiableModel getGlobalLibraryTableModifiableModel(@NotNull Project project) { + if (project.isInitialized()) { + final LibraryTable.ModifiableModel modifiableModel = getGlobalModifiableModel(project); + if (modifiableModel != null) { + return modifiableModel; + } + } + return LibraryTablesRegistrar.getInstance().getGlobalLibraryTable(project).getModifiableModel(); + } + @Override public LibraryTable.ModifiableModel getLibraryTableModifiableModel(@NotNull Project project) { StructureConfigurableContext context = getProjectStructureContext(project); @@ -113,6 +122,12 @@ public final class IdeaModifiableModelsProvider implements ModifiableModelsProvi } } + private static @Nullable LibraryTable.ModifiableModel getGlobalModifiableModel(@NotNull Project project) { + var context = getProjectStructureContext(project); + var provider = context != null ? context.createModifiableModelProvider(LibraryTablesRegistrar.APPLICATION_LEVEL) : null; + return provider != null ? provider.getModifiableModel() : null; + } + private static @Nullable StructureConfigurableContext getProjectStructureContext(@NotNull Project project) { if (ApplicationManager.getApplication().isHeadlessEnvironment()) return null; diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/GlobalLibrariesConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/GlobalLibrariesConfigurable.java index cf8f7ec14275..6f3ccfb4156b 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/GlobalLibrariesConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/GlobalLibrariesConfigurable.java @@ -31,7 +31,7 @@ public class GlobalLibrariesConfigurable extends BaseLibrariesConfigurable { @Override public LibraryTablePresentation getLibraryTablePresentation() { - return LibraryTablesRegistrar.getInstance().getLibraryTable().getPresentation(); + return LibraryTablesRegistrar.getInstance().getGlobalLibraryTable(myProject).getPresentation(); } @Override diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/StructureConfigurableContext.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/StructureConfigurableContext.java index 9a359665453c..29e631270cd4 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/StructureConfigurableContext.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/projectRoot/StructureConfigurableContext.java @@ -74,7 +74,7 @@ public final class StructureConfigurableContext implements Disposable, LibraryEd final LibraryTablesRegistrar tablesRegistrar = LibraryTablesRegistrar.getInstance(); myLevel2Providers.clear(); - myLevel2Providers.put(LibraryTablesRegistrar.APPLICATION_LEVEL, new LibrariesModifiableModel(tablesRegistrar.getLibraryTable(), myProject, this)); + myLevel2Providers.put(LibraryTablesRegistrar.APPLICATION_LEVEL, new LibrariesModifiableModel(tablesRegistrar.getGlobalLibraryTable(myProject), myProject, this)); myLevel2Providers.put(LibraryTablesRegistrar.PROJECT_LEVEL, new LibrariesModifiableModel(tablesRegistrar.getLibraryTable(myProject), myProject, this)); for (final LibraryTable table : tablesRegistrar.getCustomLibraryTables()) { myLevel2Providers.put(table.getTableLevel(), new LibrariesModifiableModel(table, myProject, this)); diff --git a/platform/lang-api/api-dump-experimental.txt b/platform/lang-api/api-dump-experimental.txt index 3495337d76f2..8411ef06d7b9 100644 --- a/platform/lang-api/api-dump-experimental.txt +++ b/platform/lang-api/api-dump-experimental.txt @@ -692,6 +692,8 @@ com.intellij.ide.bookmark.BookmarksManager - f:setBoilerplate(Z):V - f:setFrameworkLanguage(java.lang.String):V - f:setFrameworkVersion(java.lang.String):V +com.intellij.openapi.roots.ModifiableModelsProvider +- *a:getGlobalLibraryTableModifiableModel(com.intellij.openapi.project.Project):com.intellij.openapi.roots.libraries.LibraryTable$ModifiableModel *:com.intellij.openapi.roots.SkipAddingToWatchedRoots *a:com.intellij.platform.lang.lsWidget.LanguageServiceWidgetItem - ():V diff --git a/platform/lang-api/src/com/intellij/openapi/roots/ModifiableModelsProvider.java b/platform/lang-api/src/com/intellij/openapi/roots/ModifiableModelsProvider.java index 926e4bbcfc9c..39f240a83a49 100644 --- a/platform/lang-api/src/com/intellij/openapi/roots/ModifiableModelsProvider.java +++ b/platform/lang-api/src/com/intellij/openapi/roots/ModifiableModelsProvider.java @@ -6,6 +6,7 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.module.Module; import com.intellij.openapi.project.Project; import com.intellij.openapi.roots.libraries.LibraryTable; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -42,6 +43,28 @@ public interface ModifiableModelsProvider { @NotNull LibraryTable.ModifiableModel getLibraryTableModifiableModel(); + + /** + * Returns the application-level (aka "global") library table selected by the eel environment + * associated with the given {@code project}. The {@code project} parameter is used only to + * determine the environment (via the project's already-resolved {@code EelMachine}); the returned table + * is NOT a project-level table and may be used across projects that share the same environment. + *

+ * Environment selection notes: + *

    + *
  • Projects belonging to different eel environments see different sets of application-level libraries.
  • + *
  • This method does not perform any suspend/async operations; it relies on the environment + * already bound to the provided {@code project}.
  • + *
+ * + * @param project a non-disposed project whose bound eel environment is used to choose the + * application-level library table. + * @return the environment-specific application-level library table. + * @see com.intellij.openapi.roots.libraries.LibraryTablesRegistrar#getGlobalLibraryTable(Project) + */ + @ApiStatus.Experimental + @NotNull + LibraryTable.ModifiableModel getGlobalLibraryTableModifiableModel(@NotNull Project project); LibraryTable.ModifiableModel getLibraryTableModifiableModel(@NotNull Project project); void disposeLibraryTableModifiableModel(@NotNull LibraryTable.ModifiableModel model); } diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/PlatformModifiableModelsProvider.java b/platform/lang-impl/src/com/intellij/openapi/roots/PlatformModifiableModelsProvider.java index 1c299e2a8cc3..b86ba014dd93 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/PlatformModifiableModelsProvider.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/PlatformModifiableModelsProvider.java @@ -46,6 +46,11 @@ public final class PlatformModifiableModelsProvider implements ModifiableModelsP return LibraryTablesRegistrar.getInstance().getLibraryTable().getModifiableModel(); } + @Override + public @NotNull LibraryTable.ModifiableModel getGlobalLibraryTableModifiableModel(@NotNull Project project) { + return LibraryTablesRegistrar.getInstance().getGlobalLibraryTable(project).getModifiableModel(); + } + @Override public LibraryTable.ModifiableModel getLibraryTableModifiableModel(@NotNull Project project) { return LibraryTablesRegistrar.getInstance().getLibraryTable(project).getModifiableModel(); diff --git a/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/dump/paths/resolvers/LibraryRootPortableFilePathResolver.kt b/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/dump/paths/resolvers/LibraryRootPortableFilePathResolver.kt index 69d7d81596b6..dcb06c86e336 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/dump/paths/resolvers/LibraryRootPortableFilePathResolver.kt +++ b/platform/lang-impl/src/com/intellij/util/indexing/diagnostic/dump/paths/resolvers/LibraryRootPortableFilePathResolver.kt @@ -16,7 +16,7 @@ object LibraryRootPortableFilePathResolver : PortableFilePathResolver { return runReadAction { when (portableFilePath.libraryType) { PortableFilePath.LibraryRoot.LibraryType.APPLICATION -> { - findInLibraryTable(LibraryTablesRegistrar.getInstance().libraryTable, portableFilePath) + findInLibraryTable(LibraryTablesRegistrar.getInstance().getGlobalLibraryTable(project), portableFilePath) } PortableFilePath.LibraryRoot.LibraryType.PROJECT -> { findInLibraryTable(LibraryTablesRegistrar.getInstance().getLibraryTable(project), portableFilePath) diff --git a/platform/lang-impl/src/com/intellij/util/indexing/roots/IndexableEntityProviderMethods.kt b/platform/lang-impl/src/com/intellij/util/indexing/roots/IndexableEntityProviderMethods.kt index cd6deb0aad68..68559c8e899b 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/roots/IndexableEntityProviderMethods.kt +++ b/platform/lang-impl/src/com/intellij/util/indexing/roots/IndexableEntityProviderMethods.kt @@ -54,7 +54,7 @@ object IndexableEntityProviderMethods { fun createLibraryIterators(name: String, project: Project): List = runReadAction { val registrar = LibraryTablesRegistrar.getInstance() - getLibIteratorsByName(registrar.libraryTable, name)?.also { return@runReadAction it } + getLibIteratorsByName(registrar.getGlobalLibraryTable(project), name)?.also { return@runReadAction it } for (customLibraryTable in registrar.customLibraryTables) { getLibIteratorsByName(customLibraryTable, name)?.also { return@runReadAction it } } diff --git a/platform/projectModel-api/api-dump-experimental.txt b/platform/projectModel-api/api-dump-experimental.txt index 5cf7a7bbfbbc..35e20633a64e 100644 --- a/platform/projectModel-api/api-dump-experimental.txt +++ b/platform/projectModel-api/api-dump-experimental.txt @@ -77,3 +77,5 @@ com.intellij.openapi.roots.ProjectFileIndex *:com.intellij.openapi.roots.libraries.LibraryContext - com.intellij.codeInsight.multiverse.CodeInsightContext - a:getLibrary():com.intellij.openapi.roots.libraries.Library +Fa:com.intellij.openapi.roots.libraries.LibraryTablesRegistrar +- *a:getGlobalLibraryTable(com.intellij.openapi.project.Project):com.intellij.openapi.roots.libraries.LibraryTable diff --git a/platform/projectModel-api/src/com/intellij/openapi/roots/libraries/LibraryTablesRegistrar.java b/platform/projectModel-api/src/com/intellij/openapi/roots/libraries/LibraryTablesRegistrar.java index a821d77c30ee..ea9813ef25df 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/roots/libraries/LibraryTablesRegistrar.java +++ b/platform/projectModel-api/src/com/intellij/openapi/roots/libraries/LibraryTablesRegistrar.java @@ -20,11 +20,40 @@ public abstract class LibraryTablesRegistrar { } /** - * Returns the table containing application-level libraries. These libraries are shown in 'Project Structure' | 'Platform Settings' | 'Global Libraries' - * and may be added to dependencies of modules in any project. + * Returns the application-level (aka "global") library table for the eel environment of the current process. + *

+ * Now application-level libraries are partitioned per eel environment (similar to SDKs). + * The no-argument variant uses the process' current environment; callers that + * need a specific environment tied to a project should use {@link #getGlobalLibraryTable(Project)}. + * + * @return the application-level library table for the current process eel environment. */ public abstract @NotNull LibraryTable getLibraryTable(); + /** + * Returns the application-level (aka "global") library table selected by the eel environment + * associated with the given {@code project}. The {@code project} parameter is used only to + * determine the environment (via the project's already-resolved {@code EelMachine}); the returned table + * is NOT a project-level table and may be used across projects that share the same environment. + *

+ * UI location: 'Project Structure' | 'Platform Settings' | 'Global Libraries'. + *

+ * Environment selection notes: + *

    + *
  • Projects belonging to different eel environments see different sets of application-level libraries.
  • + *
  • This method does not perform any suspend/async operations; it relies on the environment + * already bound to the provided {@code project}.
  • + *
+ * + * @param project a non-disposed project whose bound eel environment is used to choose the + * application-level library table. + * @return the environment-specific application-level library table visible as "Global Libraries". + * @see #getLibraryTable() + * @see #getLibraryTable(Project) + */ + @ApiStatus.Experimental + public abstract @NotNull LibraryTable getGlobalLibraryTable(@NotNull Project project); + /** * Returns the table containing project-level libraries for given {@code project}. These libraries are shown in 'Project Structure' * | 'Project Settings' | 'Libraries' and may be added to dependencies of the corresponding project's modules only. diff --git a/platform/projectModel-api/src/com/intellij/openapi/roots/libraries/LibraryUtil.java b/platform/projectModel-api/src/com/intellij/openapi/roots/libraries/LibraryUtil.java index 439b95f68e59..ee350fc32de0 100644 --- a/platform/projectModel-api/src/com/intellij/openapi/roots/libraries/LibraryUtil.java +++ b/platform/projectModel-api/src/com/intellij/openapi/roots/libraries/LibraryUtil.java @@ -43,7 +43,13 @@ public final class LibraryUtil { return library; } } - final LibraryTable table = LibraryTablesRegistrar.getInstance().getLibraryTable(); + final LibraryTable table; + if (project != null) { + table = LibraryTablesRegistrar.getInstance().getGlobalLibraryTable(project); + } + else { + table = LibraryTablesRegistrar.getInstance().getLibraryTable(); + } return findInTable(table, fqn); } diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTablesRegistrarImpl.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTablesRegistrarImpl.java index fe48022ea80c..6e42e6b3a077 100644 --- a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTablesRegistrarImpl.java +++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryTablesRegistrarImpl.java @@ -10,7 +10,10 @@ import com.intellij.openapi.roots.libraries.CustomLibraryTableDescription; import com.intellij.openapi.roots.libraries.LibraryTable; import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar; import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.registry.Registry; import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager; +import com.intellij.platform.eel.EelMachine; +import com.intellij.platform.eel.provider.EelProviderUtil; import com.intellij.platform.eel.provider.LocalEelMachine; import com.intellij.workspaceModel.ide.legacyBridge.GlobalLibraryTableBridge; import org.jetbrains.annotations.NotNull; @@ -34,10 +37,18 @@ final class LibraryTablesRegistrarImpl extends LibraryTablesRegistrar implements @Override public @NotNull LibraryTable getLibraryTable() { - // todo: IJPL-175225 add possibility to select non-local global library tables return GlobalLibraryTableBridge.Companion.getInstance(LocalEelMachine.INSTANCE); } + @Override + public @NotNull LibraryTable getGlobalLibraryTable(@NotNull Project project) { + if (!Registry.is("ide.workspace.model.per.environment.model.separation", false)) { + return getLibraryTable(); + } + EelMachine eelMachine = EelProviderUtil.getEelDescriptor(project).getMachine(); + return GlobalLibraryTableBridge.Companion.getInstance(eelMachine); + } + @Override public @NotNull LibraryTable getLibraryTable(@NotNull Project project) { return project.getService(ProjectLibraryTable.class); @@ -47,7 +58,7 @@ final class LibraryTablesRegistrarImpl extends LibraryTablesRegistrar implements public LibraryTable getLibraryTableByLevel(String level, @NotNull Project project) { return switch (level) { case LibraryTablesRegistrar.PROJECT_LEVEL -> getLibraryTable(project); - case LibraryTablesRegistrar.APPLICATION_LEVEL -> getLibraryTable(); + case LibraryTablesRegistrar.APPLICATION_LEVEL -> getGlobalLibraryTable(project); default -> getCustomLibraryTableByLevel(level); }; } diff --git a/platform/projectModel-impl/src/com/intellij/workspaceModel/ide/impl/legacyBridge/module/ModuleDependencyIndexImpl.kt b/platform/projectModel-impl/src/com/intellij/workspaceModel/ide/impl/legacyBridge/module/ModuleDependencyIndexImpl.kt index a426c3b81299..bcf5b35c6af8 100644 --- a/platform/projectModel-impl/src/com/intellij/workspaceModel/ide/impl/legacyBridge/module/ModuleDependencyIndexImpl.kt +++ b/platform/projectModel-impl/src/com/intellij/workspaceModel/ide/impl/legacyBridge/module/ModuleDependencyIndexImpl.kt @@ -21,6 +21,8 @@ import com.intellij.openapi.roots.libraries.LibraryTablesRegistrar import com.intellij.platform.backend.workspace.WorkspaceModel import com.intellij.platform.backend.workspace.workspaceModel import com.intellij.platform.diagnostic.telemetry.helpers.MillisecondsMeasurer +import com.intellij.platform.eel.EelMachine +import com.intellij.platform.eel.provider.getEelDescriptor import com.intellij.platform.workspace.jps.entities.* import com.intellij.platform.workspace.jps.serialization.impl.LibraryNameGenerator import com.intellij.platform.workspace.storage.EntityChange @@ -69,6 +71,9 @@ open class ModuleDependencyIndexImpl(private val project: Project): ModuleDepend private val jdkChangeListener = JdkChangeListener() private val rootSetChangeListener = ReferencedRootSetChangeListener() + private val eelMachine: EelMachine + get() = project.getEelDescriptor().machine + init { if (!project.isDefault) { val messageBusConnection = project.messageBus.connect(this) diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathReader.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathReader.java index 74116bba323d..e7d1ffc722bf 100644 --- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathReader.java +++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/conversion/EclipseClasspathReader.java @@ -252,7 +252,7 @@ public class EclipseClasspathReader extends AbstractEclipseClasspathReader libraries = new ArrayList<>(Arrays.asList(LibraryTablesRegistrar.getInstance().getLibraryTable(project).getLibraries())); - ContainerUtil.addAll(libraries, LibraryTablesRegistrar.getInstance().getLibraryTable().getLibraries()); + ContainerUtil.addAll(libraries, LibraryTablesRegistrar.getInstance().getGlobalLibraryTable(project).getLibraries()); for (Library library : libraries) { Element libElement = new Element("library"); libElement.setAttribute("name", library.getName()); diff --git a/plugins/kotlin/project-configuration/src/org/jetbrains/kotlin/idea/configuration/KotlinWithLibraryConfigurator.kt b/plugins/kotlin/project-configuration/src/org/jetbrains/kotlin/idea/configuration/KotlinWithLibraryConfigurator.kt index 79ea8831da5d..e4bb1a5e3fb6 100644 --- a/plugins/kotlin/project-configuration/src/org/jetbrains/kotlin/idea/configuration/KotlinWithLibraryConfigurator.kt +++ b/plugins/kotlin/project-configuration/src/org/jetbrains/kotlin/idea/configuration/KotlinWithLibraryConfigurator.kt @@ -263,7 +263,7 @@ abstract class KotlinWithLibraryConfigurator

> protected private fun getKotlinLibrary(project: Project): Library? { return LibraryTablesRegistrar.getInstance().getLibraryTable(project).libraries.firstOrNull { isKotlinLibrary(it, project) } - ?: LibraryTablesRegistrar.getInstance().libraryTable.libraries.firstOrNull { isKotlinLibrary(it, project) } + ?: LibraryTablesRegistrar.getInstance().getGlobalLibraryTable(project).libraries.firstOrNull { isKotlinLibrary(it, project) } } private fun addLibraryToModuleIfNeeded( diff --git a/python/pluginCore/impl/src/com/intellij/python/community/plugin/impl/facet/PythonFacetUtil.java b/python/pluginCore/impl/src/com/intellij/python/community/plugin/impl/facet/PythonFacetUtil.java index ddbf7a0e87ec..19b726af5b04 100644 --- a/python/pluginCore/impl/src/com/intellij/python/community/plugin/impl/facet/PythonFacetUtil.java +++ b/python/pluginCore/impl/src/com/intellij/python/community/plugin/impl/facet/PythonFacetUtil.java @@ -41,7 +41,7 @@ public final class PythonFacetUtil { } if (name != null) { final ModifiableModelsProvider provider = ModifiableModelsProvider.getInstance(); - final LibraryTable.ModifiableModel libraryTableModifiableModel = provider.getLibraryTableModifiableModel(); + final LibraryTable.ModifiableModel libraryTableModifiableModel = provider.getGlobalLibraryTableModifiableModel(module.getProject()); Library library = libraryTableModifiableModel.getLibraryByName(name); provider.disposeLibraryTableModifiableModel(libraryTableModifiableModel); if (library == null) {