mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
InspectionWidgetActionProvider: update state after extension changes on EDT
InspectionWidgetActionProvider's state is not protected by any locks and should be accessed on EDT only. At the same time, extension point events are delivered on a background thread GitOrigin-RevId: 83b9608c29e19b6d66ac0ac344f5050c39d955d0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
83cd25885f
commit
06271cdaeb
@@ -4,6 +4,7 @@ package com.intellij.openapi.editor.markup
|
||||
import com.intellij.openapi.actionSystem.AnAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
import com.intellij.util.concurrency.annotations.RequiresEdt
|
||||
|
||||
interface InspectionWidgetActionProvider {
|
||||
companion object {
|
||||
@@ -18,5 +19,6 @@ interface InspectionWidgetActionProvider {
|
||||
*
|
||||
* May return null if no action should be created for the given editor.
|
||||
*/
|
||||
@RequiresEdt
|
||||
fun createAction(editor: Editor): AnAction?
|
||||
}
|
||||
@@ -441,19 +441,23 @@ public final class EditorMarkupModelImpl extends MarkupModelImpl
|
||||
InspectionWidgetActionProvider.EP_NAME.addExtensionPointListener(new ExtensionPointListener<>() {
|
||||
@Override
|
||||
public void extensionAdded(@NotNull InspectionWidgetActionProvider extension, @NotNull PluginDescriptor pluginDescriptor) {
|
||||
AnAction action = extension.createAction(myEditor);
|
||||
if (action != null) {
|
||||
extensionActions.put(extension, action);
|
||||
addInspectionWidgetAction(action, null);
|
||||
}
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
AnAction action = extension.createAction(myEditor);
|
||||
if (action != null) {
|
||||
extensionActions.put(extension, action);
|
||||
addInspectionWidgetAction(action, null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void extensionRemoved(@NotNull InspectionWidgetActionProvider extension, @NotNull PluginDescriptor pluginDescriptor) {
|
||||
AnAction action = extensionActions.remove(extension);
|
||||
if (action != null) {
|
||||
removeInspectionWidgetAction(action);
|
||||
}
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
AnAction action = extensionActions.remove(extension);
|
||||
if (action != null) {
|
||||
removeInspectionWidgetAction(action);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, resourcesDisposable);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user