[kotlin] Add API to find LibraryEntity instance by Library

GitOrigin-RevId: 11ef39e4b518ff42e71225b59ba1fb5f830b688a
This commit is contained in:
Vlad Koshkin
2024-07-31 12:51:52 +02:00
committed by intellij-monorepo-bot
parent 11c5236c22
commit 5d7378cd9e
2 changed files with 18 additions and 0 deletions

View File

@@ -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

View File

@@ -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?
}