From de570295b8a74ff7849f50e8126eb662fb3869b1 Mon Sep 17 00:00:00 2001 From: anstarovoyt Date: Mon, 23 Dec 2019 18:51:27 +0300 Subject: [PATCH] fix code duplication GitOrigin-RevId: 01dab8785e49fd907eb4191d086d3d05d0c1de3a --- .../intellij/ui/EditorNotificationsImpl.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/ui/EditorNotificationsImpl.java b/platform/platform-impl/src/com/intellij/ui/EditorNotificationsImpl.java index 771eccb16caf..b0e4123fbee5 100644 --- a/platform/platform-impl/src/com/intellij/ui/EditorNotificationsImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/EditorNotificationsImpl.java @@ -105,10 +105,7 @@ public class EditorNotificationsImpl extends EditorNotifications { //noinspection unchecked Key key = extension.getKey(); for (VirtualFile file : FileEditorManager.getInstance(myProject).getOpenFiles()) { - List editors = ContainerUtil.filter(FileEditorManager.getInstance(myProject).getAllEditors(file), editor -> { - return !(editor instanceof TextEditor) || - AsyncEditorLoader.isEditorLoaded(((TextEditor)editor).getEditor()); - }); + List editors = getEditors(file); for (FileEditor editor : editors) { updateNotification(editor, key, null, PluginInfoDetectorKt.getPluginInfo(extension.getClass())); @@ -125,10 +122,7 @@ public class EditorNotificationsImpl extends EditorNotifications { return; } - List editors = ContainerUtil.filter(FileEditorManager.getInstance(myProject).getAllEditors(file), editor -> { - return !(editor instanceof TextEditor) || - AsyncEditorLoader.isEditorLoaded(((TextEditor)editor).getEditor()); - }); + List editors = getEditors(file); if (!ApplicationManager.getApplication().isHeadlessEnvironment()) { Iterator it = editors.iterator(); @@ -144,6 +138,14 @@ public class EditorNotificationsImpl extends EditorNotifications { }); } + @NotNull + private List getEditors(@NotNull VirtualFile file) { + return ContainerUtil.filter(FileEditorManager.getInstance(myProject).getAllEditors(file), editor -> { + return !(editor instanceof TextEditor) || + AsyncEditorLoader.isEditorLoaded(((TextEditor)editor).getEditor()); + }); + } + private void updateEditors(@NotNull VirtualFile file, List editors) { ReadAction .nonBlocking(() -> calcNotificationUpdates(file, editors))