don't use deprecated Disposable

GitOrigin-RevId: 7dbd7ecf2d9911bafab8a0cc69f77802c959de40
This commit is contained in:
Vladimir Krivosheev
2025-06-05 08:53:43 +02:00
committed by intellij-monorepo-bot
parent c0b830cd55
commit 11878c32d9
12 changed files with 41 additions and 39 deletions

View File

@@ -9,9 +9,6 @@
- s:getEntries():kotlin.enums.EnumEntries
- s:valueOf(java.lang.String):com.intellij.openapi.client.ClientKind
- s:values():com.intellij.openapi.client.ClientKind[]
f:com.intellij.openapi.extensions.ExtensionPointName
- com.intellij.openapi.extensions.BaseExtensionPointName
- *f:computeIfAbsent(java.lang.Class,java.util.function.Supplier):java.lang.Object
com.intellij.openapi.extensions.PluginDescriptor
- *:getClassLoader():java.lang.ClassLoader
f:com.intellij.openapi.extensions.ProjectExtensionPointName

View File

@@ -1,9 +1,10 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// 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.psi.codeStyle;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.Service;
import kotlinx.coroutines.CoroutineScope;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
@@ -20,15 +21,15 @@ final class LanguageCodeStyleSettingsProviderService implements Disposable {
private final Object lock = new Object();
@SuppressWarnings("PublicConstructorInNonPublicClass")
public LanguageCodeStyleSettingsProviderService() {
LanguageCodeStyleSettingsProvider.EP_NAME.addChangeListener(() -> {
public LanguageCodeStyleSettingsProviderService(@NotNull CoroutineScope coroutineScope) {
LanguageCodeStyleSettingsProvider.EP_NAME.addChangeListener(coroutineScope, () -> {
allProviders = null;
LanguageCodeStyleSettingsProvider.cleanSettingsPagesProvidersCache();
}, this);
});
LanguageCodeStyleSettingsContributor.EP_NAME.addChangeListener(() -> {
LanguageCodeStyleSettingsContributor.EP_NAME.addChangeListener(coroutineScope, () -> {
allProviders = null;
}, this);
});
}
public @NotNull List<LanguageCodeStyleSettingsProvider> getAllProviders() {

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// 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.framework.detection.impl;
import com.intellij.framework.FrameworkType;
@@ -10,6 +10,7 @@ import com.intellij.openapi.util.Pair;
import com.intellij.patterns.ElementPattern;
import com.intellij.util.containers.MultiMap;
import com.intellij.util.indexing.FileContent;
import kotlinx.coroutines.CoroutineScope;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
@@ -27,8 +28,8 @@ public final class FrameworkDetectorRegistryImpl extends FrameworkDetectorRegist
private final Object myInitializationLock = new Object();
public FrameworkDetectorRegistryImpl() {
FrameworkDetector.EP_NAME.addChangeListener(() -> onDetectorsChanged(), this);
public FrameworkDetectorRegistryImpl(@NotNull CoroutineScope coroutineScope) {
FrameworkDetector.EP_NAME.addChangeListener(coroutineScope, this::onDetectorsChanged);
}
private synchronized void ensureDetectorsLoaded() {

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// 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.openapi.roots.impl
import com.intellij.configurationStore.BatchUpdateListener
@@ -181,8 +181,8 @@ open class ProjectRootManagerComponent(
}
}
}
AdditionalLibraryRootsProvider.EP_NAME.addChangeListener(rootsExtensionPointListener, this)
OrderEnumerationHandler.EP_NAME.addChangeListener(rootsExtensionPointListener, this)
AdditionalLibraryRootsProvider.EP_NAME.addChangeListener(coroutineScope, rootsExtensionPointListener)
OrderEnumerationHandler.EP_NAME.addChangeListener(coroutineScope, rootsExtensionPointListener)
}
protected open fun projectClosed() {

View File

@@ -96,7 +96,9 @@ class CustomActionsSchema(private val coroutineScope: CoroutineScope?) : Persist
idToName.put(IdeActions.GROUP_NAVBAR_POPUP, ActionsTreeUtil.getNavigationBarPopupMenu())
idToName.put(IdeActions.GROUP_NAVBAR_TOOLBAR, ActionsTreeUtil.getNavigationBarToolbar())
fillExtGroups(idToName, extGroupIds)
EP_NAME.addChangeListener({ fillExtGroups(idToName, extGroupIds) }, null)
if (coroutineScope != null) {
EP_NAME.addChangeListener(coroutineScope) { fillExtGroups(idToName, extGroupIds) }
}
idToName.putAll(additionalIdToName)
this.idToName = idToName
}

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// 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.core.fileIndex.impl
import com.intellij.injected.editor.VirtualFileWindow
@@ -23,6 +23,7 @@ import com.intellij.platform.backend.workspace.virtualFile
import com.intellij.platform.workspace.storage.WorkspaceEntity
import com.intellij.platform.workspace.storage.impl.url.VirtualFileUrlManagerImpl
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.serviceContainer.NonInjectable
import com.intellij.util.PathUtil
import com.intellij.util.Query
import com.intellij.util.ThreeState
@@ -30,10 +31,11 @@ import com.intellij.util.concurrency.annotations.RequiresReadLock
import com.intellij.util.containers.TreeNodeProcessingResult
import com.intellij.workspaceModel.core.fileIndex.*
import com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileInternalInfo.NonWorkspace
import kotlinx.coroutines.CoroutineScope
import java.util.concurrent.TimeUnit.MINUTES
import java.util.concurrent.atomic.AtomicReference
class WorkspaceFileIndexImpl(private val project: Project) : WorkspaceFileIndexEx, Disposable.Default {
class WorkspaceFileIndexImpl(private val project: Project, coroutineScope: CoroutineScope) : WorkspaceFileIndexEx, Disposable.Default {
companion object {
val EP_NAME: ExtensionPointName<WorkspaceFileIndexContributor<*>> = ExtensionPointName("com.intellij.workspaceModel.fileIndexContributor")
}
@@ -41,7 +43,8 @@ class WorkspaceFileIndexImpl(private val project: Project) : WorkspaceFileIndexE
private val indexDataReference = AtomicReference<WorkspaceFileIndexData>(EmptyWorkspaceFileIndexData.NOT_INITIALIZED)
private val throttledLogger = ThrottledLogger(thisLogger(), MINUTES.toMillis(1))
constructor(project: Project, indexData: WorkspaceFileIndexData) : this(project) {
@NonInjectable
constructor(project: Project, indexData: WorkspaceFileIndexData, coroutineScope: CoroutineScope) : this(project, coroutineScope) {
indexDataReference.set(indexData)
}
@@ -73,8 +76,7 @@ class WorkspaceFileIndexImpl(private val project: Project) : WorkspaceFileIndexE
}
})
LowMemoryWatcher.register({ indexData.onLowMemory() }, project)
val clearData = Runnable { indexData = EmptyWorkspaceFileIndexData.RESET }
EP_NAME.addChangeListener(clearData, this)
EP_NAME.addChangeListener(coroutineScope) { indexData = EmptyWorkspaceFileIndexData.RESET }
}
override fun isInWorkspace(file: VirtualFile): Boolean {

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// 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.internal.statistic.eventLog
import com.intellij.internal.statistic.eventLog.StatisticsEventLoggerProvider.Companion.EP_NAME
@@ -9,16 +9,17 @@ import com.intellij.openapi.application.ApplicationInfo
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.Service
import com.intellij.util.PlatformUtils
import kotlinx.coroutines.CoroutineScope
import java.util.concurrent.atomic.AtomicReference
@Service(Service.Level.APP)
internal class StatisticsEventLogProvidersHolder {
internal class StatisticsEventLogProvidersHolder(coroutineScope: CoroutineScope) {
private val eventLoggerProviders: AtomicReference<Map<String, StatisticsEventLoggerProvider>> =
AtomicReference(calculateEventLogProvider())
init {
if (ApplicationManager.getApplication().extensionArea.hasExtensionPoint(EP_NAME)) {
EP_NAME.addChangeListener(Runnable { eventLoggerProviders.set(calculateEventLogProvider()) }, null)
EP_NAME.addChangeListener(coroutineScope) { eventLoggerProviders.set(calculateEventLogProvider()) }
}
}

View File

@@ -195,7 +195,6 @@ a:com.intellij.tasks.TaskRepositoryType
- java.lang.Comparable
- sf:EP_NAME:com.intellij.openapi.extensions.ExtensionPointName
- <init>():V
- s:addEPListChangeListener(com.intellij.openapi.Disposable,java.lang.Runnable):V
- compareTo(com.intellij.tasks.TaskRepositoryType):I
- a:createEditor(com.intellij.tasks.TaskRepository,com.intellij.openapi.project.Project,com.intellij.util.Consumer):com.intellij.tasks.config.TaskRepositoryEditor
- a:createRepository():com.intellij.tasks.TaskRepository

View File

@@ -1,16 +1,13 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// 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.tasks;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.project.Project;
import com.intellij.tasks.config.TaskRepositoryEditor;
import com.intellij.util.Consumer;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Unmodifiable;
import kotlinx.coroutines.CoroutineScope;
import org.jetbrains.annotations.*;
import javax.swing.*;
import java.util.Collections;
@@ -33,8 +30,9 @@ public abstract class TaskRepositoryType<T extends TaskRepository> implements Ta
return ContainerUtil.map(getRepositoryTypes(), TaskRepositoryType::getRepositoryClass);
}
public static <T> void addEPListChangeListener(@NotNull Disposable disposable, @NotNull Runnable listener) {
EP_NAME.addChangeListener(listener, disposable);
@ApiStatus.Internal
public static void addEPListChangeListener(@NotNull CoroutineScope coroutineScope, @NotNull Runnable listener) {
EP_NAME.addChangeListener(coroutineScope, listener);
}
@Override

View File

@@ -134,7 +134,7 @@ public final class TaskManagerImpl extends TaskManager implements PersistentStat
};
// remove repositories pertaining to non-existent types
TaskRepositoryType.addEPListChangeListener(this, () -> {
TaskRepositoryType.addEPListChangeListener(coroutineScope, () -> {
List<Class<?>> possibleRepositoryClasses = TaskRepositoryType.getRepositoryClasses();
List<TaskRepository> repositories = myRepositories;
boolean removed = repositories.removeIf(repository -> {

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
// 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.openapi.vcs.impl.projectlevelman;
import com.intellij.filename.UniqueNameBuilder;
@@ -85,7 +85,7 @@ public final class NewMappings implements Disposable {
scheduleMappedRootsUpdate();
}
};
VcsRootChecker.EXTENSION_POINT_NAME.addChangeListener(() -> scheduleMappedRootsUpdate(), this);
VcsRootChecker.EXTENSION_POINT_NAME.addChangeListener(coroutineScope, () -> scheduleMappedRootsUpdate());
}
@TestOnly

View File

@@ -1,4 +1,4 @@
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// 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.tasks.config;
import com.intellij.openapi.Disposable;
@@ -12,6 +12,7 @@ import com.intellij.util.containers.CollectionFactory;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.HashingStrategy;
import com.intellij.util.xmlb.XmlSerializer;
import kotlinx.coroutines.CoroutineScope;
import org.jdom.Element;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -38,9 +39,9 @@ public final class RecentTaskRepositories implements PersistentStateComponent<El
}
};
public RecentTaskRepositories() {
public RecentTaskRepositories(@NotNull CoroutineScope coroutineScope) {
// remove repositories pertaining to non-existent types
TaskRepositoryType.addEPListChangeListener(this, () -> {
TaskRepositoryType.addEPListChangeListener(coroutineScope, () -> {
List<Class<?>> possibleRepositoryClasses = TaskRepositoryType.getRepositoryClasses();
myRepositories.removeIf(repository -> {
return !ContainerUtil.exists(possibleRepositoryClasses, clazz -> clazz.isAssignableFrom(repository.getClass()));