From 6691758be76618e5c74f4eda1dcfa3f1c960f44a Mon Sep 17 00:00:00 2001 From: Anatoliy Bazko Date: Wed, 11 Sep 2019 11:49:03 +0300 Subject: [PATCH] refactoring Signed-off-by: Anatoliy Bazko --- packages/java/scripts/.project | 17 ---------------- .../src/main/browser/text-editor-service.ts | 20 ++++++------------- 2 files changed, 6 insertions(+), 31 deletions(-) delete mode 100644 packages/java/scripts/.project diff --git a/packages/java/scripts/.project b/packages/java/scripts/.project deleted file mode 100644 index 7d85e099c45e0..0000000000000 --- a/packages/java/scripts/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - java.package - - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - - diff --git a/packages/plugin-ext/src/main/browser/text-editor-service.ts b/packages/plugin-ext/src/main/browser/text-editor-service.ts index 0638e6f880cec..edf7e35f6c56b 100644 --- a/packages/plugin-ext/src/main/browser/text-editor-service.ts +++ b/packages/plugin-ext/src/main/browser/text-editor-service.ts @@ -13,10 +13,10 @@ * * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 ********************************************************************************/ -import { Event, Emitter } from '@theia/core'; +import { Emitter, Event } from '@theia/core'; import { EditorManager, EditorWidget } from '@theia/editor/lib/browser'; -import { injectable, inject } from 'inversify'; import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor'; +import { inject, injectable } from 'inversify'; export const TextEditorService = Symbol('TextEditorService'); /** @@ -38,15 +38,13 @@ export class TextEditorServiceImpl implements TextEditorService { onTextEditorAdd: Event = this.onTextEditorAddEmitter.event; onTextEditorRemove: Event = this.onTextEditorRemoveEmitter.event; - private editors = new Map(); - constructor(@inject(EditorManager) private editorManager: EditorManager) { editorManager.onCreated(w => this.onEditorCreated(w)); editorManager.all.forEach(w => this.onEditorCreated(w)); } listTextEditors(): MonacoEditor[] { - return Array.from(this.editors.values()); + return this.editorManager.all.map(w => MonacoEditor.get(w)!).filter(editor => editor !== undefined); } getActiveEditor(): EditorWidget | undefined { @@ -62,16 +60,10 @@ export class TextEditorServiceImpl implements TextEditorService { } private onEditorAdded(editor: MonacoEditor): void { - if (!this.editors.has(editor.getControl().getId())) { - this.editors.set(editor.getControl().getId(), editor); - this.onTextEditorAddEmitter.fire(editor); - } + this.onTextEditorAddEmitter.fire(editor); } + private onEditorRemoved(editor: MonacoEditor): void { - if (this.editors.has(editor.getControl().getId())) { - this.editors.delete(editor.getControl().getId()); - this.onTextEditorRemoveEmitter.fire(editor); - } + this.onTextEditorRemoveEmitter.fire(editor); } - }