[project model] don't extend Disposable interface in Library (IJPL-183361)

All implementations still extend it for now. This is the first step to ensure that plugins won't rely on Library being Disposable anymore.

GitOrigin-RevId: c0f198fb1b10eaf229e8318b952ac15b4a4e876c
This commit is contained in:
Nikolay Chashnikov
2025-06-05 16:05:12 +02:00
committed by intellij-monorepo-bot
parent 556cc97bef
commit 56ddbf1bef
8 changed files with 16 additions and 14 deletions

View File

@@ -906,7 +906,6 @@ com.intellij.openapi.roots.impl.libraries.LibraryEx$ModifiableModelEx
- a:setKind(com.intellij.openapi.roots.libraries.PersistentLibraryKind):V
- a:setProperties(com.intellij.openapi.roots.libraries.LibraryProperties):V
com.intellij.openapi.roots.libraries.Library
- com.intellij.openapi.Disposable
- com.intellij.openapi.roots.ProjectModelElement
- com.intellij.openapi.util.JDOMExternalizable
- sf:EMPTY_ARRAY:com.intellij.openapi.roots.libraries.Library[]

View File

@@ -25,7 +25,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.*;
@ApiStatus.NonExtendable
public interface Library extends JDOMExternalizable, Disposable, ProjectModelElement {
public interface Library extends JDOMExternalizable, ProjectModelElement {
Library[] EMPTY_ARRAY = new Library[0];
/**

View File

@@ -126,7 +126,7 @@ internal class GlobalLibraryTableDelegate(private val libraryTable: LibraryTable
if (library != null) {
// TODO There won't be any content in libraryImpl as EntityStore's current was already changed
dispatcher.multicaster.afterLibraryRemoved(library)
Disposer.dispose(library)
Disposer.dispose(library as Disposable)
}
}
is EntityChange.Replaced -> {
@@ -194,7 +194,7 @@ internal class GlobalLibraryTableDelegate(private val libraryTable: LibraryTable
override fun dispose() {
for (library in getLibraries()) {
Disposer.dispose(library)
Disposer.dispose(library as Disposable)
}
}

View File

@@ -58,7 +58,7 @@ class LibraryBridgeImpl(
initialId: LibraryId,
initialEntityStorage: VersionedEntityStorage,
private var targetBuilder: MutableEntityStorage?,
) : LibraryBridge, RootProvider, TraceableDisposable(true) {
) : LibraryBridge, RootProvider, TraceableDisposable(true), Disposable {
override fun getModule(): Module? = (libraryTable as? ModuleLibraryTableBridge)?.module

View File

@@ -116,7 +116,7 @@ open class ProjectLibraryTableBridgeImpl(
if (library != null) {
// TODO There won't be any content in libraryImpl as EntityStore's current was already changed
dispatcher.multicaster.afterLibraryRemoved(library)
Disposer.dispose(library)
Disposer.dispose(library as Disposable)
}
}
is EntityChange.Replaced -> {
@@ -250,7 +250,7 @@ open class ProjectLibraryTableBridgeImpl(
override fun dispose() {
for (library in libraries) {
Disposer.dispose(library)
Disposer.dispose(library as Disposable)
}
}

View File

@@ -1,6 +1,7 @@
// 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.impl.legacyBridge.module
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.diagnostic.debug
import com.intellij.openapi.diagnostic.logger
@@ -168,7 +169,7 @@ internal class LegacyProjectModelListenersBridge(
is EntityChange.Removed -> {
val library = event.storageBefore.libraryMap.getDataByEntity(change.oldEntity)
if (library != null) {
Disposer.dispose(library)
Disposer.dispose(library as Disposable)
}
}
is EntityChange.Replaced -> {

View File

@@ -2,6 +2,7 @@
package com.intellij.workspaceModel.ide.impl.legacyBridge.module.roots
import com.google.common.collect.HashBiMap
import com.intellij.openapi.Disposable
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.module.Module
import com.intellij.openapi.roots.ProjectModelExternalSource
@@ -158,9 +159,9 @@ internal class ModifiableModuleLibraryTableBridge(private val modifiableModel: M
}
modifiableModel.diff.removeEntity(libraryEntity)
Disposer.dispose(library)
Disposer.dispose(library as Disposable)
if (copyBridgeForDispose != null) {
Disposer.dispose(copyBridgeForDispose!!)
Disposer.dispose(copyBridgeForDispose!! as Disposable)
}
}
@@ -173,7 +174,7 @@ internal class ModifiableModuleLibraryTableBridge(private val modifiableModel: M
mutableLibraryMap.addMapping(mutableLibraryMap.getEntities(it as LibraryBridge).single(), originalLibrary)
}
Disposer.dispose(it)
Disposer.dispose(it as Disposable)
}
}
@@ -186,7 +187,7 @@ internal class ModifiableModuleLibraryTableBridge(private val modifiableModel: M
if (!changedLibs.contains(originBridge.libraryId) && originBridge.hasSameContent(copyBridge)) {
val mutableLibraryMap = modifiableModel.diff.mutableLibraryMap
mutableLibraryMap.addMapping(mutableLibraryMap.getEntities(copyBridge as LibraryBridge).single(), originBridge)
Disposer.dispose(copyBridge)
Disposer.dispose(copyBridge as Disposable)
}
}
}
@@ -216,7 +217,7 @@ internal class ModifiableModuleLibraryTableBridge(private val modifiableModel: M
actualBridge.entityStorage = storage
actualBridge.libraryTable = ModuleRootComponentBridge.getInstance(module).moduleLibraryTable
actualBridge.clearTargetBuilder()
Disposer.dispose(outdatedBridge)
Disposer.dispose(outdatedBridge as Disposable)
}
}

View File

@@ -1,6 +1,7 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.workspaceModel.ide.impl.legacyBridge.module.roots
import com.intellij.openapi.Disposable
import com.intellij.openapi.module.Module
import com.intellij.openapi.roots.ProjectModelExternalSource
import com.intellij.openapi.roots.impl.ModuleLibraryTableBase
@@ -68,7 +69,7 @@ class ModuleLibraryTableBridgeImpl(private val moduleBridge: ModuleBridge) : Mod
override fun dispose() {
for (library in libraryIterator) {
if (!(library as LibraryEx).isDisposed) Disposer.dispose(library)
if (!(library as LibraryEx).isDisposed) Disposer.dispose(library as Disposable)
}
}