diff --git a/platform/projectModel-impl/api-dump.txt b/platform/projectModel-impl/api-dump.txt index cac5fe6f27f0..7d2cda5cc40a 100644 --- a/platform/projectModel-impl/api-dump.txt +++ b/platform/projectModel-impl/api-dump.txt @@ -511,6 +511,8 @@ f:com.intellij.workspaceModel.ide.impl.legacyBridge.library.LibraryEntityUtils - sf:findLibraryId(com.intellij.openapi.roots.libraries.Library):com.intellij.platform.workspace.jps.entities.LibraryId f:com.intellij.workspaceModel.ide.impl.legacyBridge.module.ModuleEntityUtils - sf:getModuleLevelLibraries(com.intellij.platform.workspace.jps.entities.ModuleEntity,com.intellij.platform.workspace.storage.EntityStorage):kotlin.sequences.Sequence +f:com.intellij.workspaceModel.ide.legacyBridge.LibraryBridgesKt +- sf:findLibraryEntity(com.intellij.openapi.roots.libraries.Library,com.intellij.platform.workspace.storage.EntityStorage):com.intellij.platform.workspace.jps.entities.LibraryEntity f:com.intellij.workspaceModel.ide.legacyBridge.ModuleBridges - sf:findModule(com.intellij.platform.workspace.jps.entities.ModuleEntity,com.intellij.platform.workspace.storage.EntityStorage):com.intellij.openapi.module.Module - sf:findModuleEntity(com.intellij.openapi.module.Module,com.intellij.platform.workspace.storage.EntityStorage):com.intellij.platform.workspace.jps.entities.ModuleEntity diff --git a/platform/projectModel-impl/src/com/intellij/workspaceModel/ide/legacyBridge/LibraryBridges.kt b/platform/projectModel-impl/src/com/intellij/workspaceModel/ide/legacyBridge/LibraryBridges.kt new file mode 100644 index 000000000000..7c1b58ebbe30 --- /dev/null +++ b/platform/projectModel-impl/src/com/intellij/workspaceModel/ide/legacyBridge/LibraryBridges.kt @@ -0,0 +1,16 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.workspaceModel.ide.legacyBridge + +import com.intellij.openapi.roots.libraries.Library +import com.intellij.platform.workspace.jps.entities.LibraryEntity +import com.intellij.platform.workspace.storage.EntityStorage +import com.intellij.workspaceModel.ide.impl.legacyBridge.library.LibraryBridge +import com.intellij.workspaceModel.ide.impl.legacyBridge.library.ProjectLibraryTableBridgeImpl.Companion.libraryMap + + +/** + * @return corresponding [LibraryEntity] or null if library isn't associated with entity yet + */ +fun Library.findLibraryEntity(entityStorage: EntityStorage): LibraryEntity? { + return entityStorage.libraryMap.getEntities(this as LibraryBridge).firstOrNull() as LibraryEntity? +} \ No newline at end of file