[java] Don't use project as disposable

Introduces `JavaPluginDisposable` and migrates existing project disposables to the new project level service. #IDEA-383890 Fixed

GitOrigin-RevId: 762429b8f44959e127324d19053a8b05a818f414
This commit is contained in:
Bart van Helvert
2026-01-07 11:33:05 +00:00
committed by intellij-monorepo-bot
parent f1811ad257
commit b9b383c76e
22 changed files with 79 additions and 25 deletions
@@ -0,0 +1,24 @@
// 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.java
import com.intellij.openapi.Disposable
import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import kotlinx.coroutines.CoroutineScope
import org.jetbrains.annotations.ApiStatus
/**
* A project level disposable for the Java plugin.
* Use this class instead of passing [Project] as a disposable to make sure your resource gets disposed when the Java plugin is unloaded.
*/
@ApiStatus.Internal
@Service(Service.Level.PROJECT)
class JavaPluginDisposable(val coroutineScope: CoroutineScope) : Disposable {
override fun dispose() { }
companion object {
@JvmStatic
fun getInstance(project: Project): JavaPluginDisposable = project.service<JavaPluginDisposable>()
}
}