fix code duplication

GitOrigin-RevId: 01dab8785e49fd907eb4191d086d3d05d0c1de3a
This commit is contained in:
anstarovoyt
2019-12-23 16:03:08 +00:00
committed by intellij-monorepo-bot
parent 272f6c8aff
commit de570295b8
@@ -105,10 +105,7 @@ public class EditorNotificationsImpl extends EditorNotifications {
//noinspection unchecked
Key<? extends JComponent> key = extension.getKey();
for (VirtualFile file : FileEditorManager.getInstance(myProject).getOpenFiles()) {
List<FileEditor> editors = ContainerUtil.filter(FileEditorManager.getInstance(myProject).getAllEditors(file), editor -> {
return !(editor instanceof TextEditor) ||
AsyncEditorLoader.isEditorLoaded(((TextEditor)editor).getEditor());
});
List<FileEditor> 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<FileEditor> editors = ContainerUtil.filter(FileEditorManager.getInstance(myProject).getAllEditors(file), editor -> {
return !(editor instanceof TextEditor) ||
AsyncEditorLoader.isEditorLoaded(((TextEditor)editor).getEditor());
});
List<FileEditor> editors = getEditors(file);
if (!ApplicationManager.getApplication().isHeadlessEnvironment()) {
Iterator<FileEditor> it = editors.iterator();
@@ -144,6 +138,14 @@ public class EditorNotificationsImpl extends EditorNotifications {
});
}
@NotNull
private List<FileEditor> 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<FileEditor> editors) {
ReadAction
.nonBlocking(() -> calcNotificationUpdates(file, editors))