From 15993df1d6849bd487855cf4926e2e01e44e54df Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Thu, 7 Jun 2018 23:53:45 -0500 Subject: [PATCH] remove need to pass monaco around through DI --- app/assets/javascripts/ide/lib/common/model.js | 3 ++- app/assets/javascripts/ide/lib/common/model_manager.js | 5 ++--- app/assets/javascripts/ide/lib/editor.js | 2 +- spec/javascripts/ide/lib/common/model_manager_spec.js | 3 +-- spec/javascripts/ide/lib/common/model_spec.js | 5 ++--- spec/javascripts/ide/lib/decorations/controller_spec.js | 3 +-- spec/javascripts/ide/lib/diff/controller_spec.js | 6 +++--- 7 files changed, 12 insertions(+), 15 deletions(-) diff --git a/app/assets/javascripts/ide/lib/common/model.js b/app/assets/javascripts/ide/lib/common/model.js index ecacc11d77c..a1940321acf 100644 --- a/app/assets/javascripts/ide/lib/common/model.js +++ b/app/assets/javascripts/ide/lib/common/model.js @@ -1,8 +1,9 @@ +import * as monaco from 'monaco-editor'; import Disposable from './disposable'; import eventHub from '../../eventhub'; export default class Model { - constructor(monaco, file, head = null) { + constructor(file, head = null) { this.monaco = monaco; this.disposable = new Disposable(); this.file = file; diff --git a/app/assets/javascripts/ide/lib/common/model_manager.js b/app/assets/javascripts/ide/lib/common/model_manager.js index 7f643969480..bd9b8fc3fcc 100644 --- a/app/assets/javascripts/ide/lib/common/model_manager.js +++ b/app/assets/javascripts/ide/lib/common/model_manager.js @@ -3,8 +3,7 @@ import Disposable from './disposable'; import Model from './model'; export default class ModelManager { - constructor(monaco) { - this.monaco = monaco; + constructor() { this.disposable = new Disposable(); this.models = new Map(); } @@ -22,7 +21,7 @@ export default class ModelManager { return this.getModel(file.key); } - const model = new Model(this.monaco, file, head); + const model = new Model(file, head); this.models.set(model.path, model); this.disposable.add(model); diff --git a/app/assets/javascripts/ide/lib/editor.js b/app/assets/javascripts/ide/lib/editor.js index 3d336fe63f6..30254b25c1e 100644 --- a/app/assets/javascripts/ide/lib/editor.js +++ b/app/assets/javascripts/ide/lib/editor.js @@ -31,7 +31,7 @@ export default class Editor { this.instance = null; this.dirtyDiffController = null; this.disposable = new Disposable(); - this.modelManager = new ModelManager(this.monaco); + this.modelManager = new ModelManager(); this.decorationsController = new DecorationsController(this); this.setupMonacoTheme(); diff --git a/spec/javascripts/ide/lib/common/model_manager_spec.js b/spec/javascripts/ide/lib/common/model_manager_spec.js index e3886f06f5a..38ffa317e8e 100644 --- a/spec/javascripts/ide/lib/common/model_manager_spec.js +++ b/spec/javascripts/ide/lib/common/model_manager_spec.js @@ -1,4 +1,3 @@ -import * as monaco from 'monaco-editor'; import eventHub from '~/ide/eventhub'; import ModelManager from '~/ide/lib/common/model_manager'; import { file } from '../../helpers'; @@ -7,7 +6,7 @@ describe('Multi-file editor library model manager', () => { let instance; beforeEach(() => { - instance = new ModelManager(monaco); + instance = new ModelManager(); }); afterEach(() => { diff --git a/spec/javascripts/ide/lib/common/model_spec.js b/spec/javascripts/ide/lib/common/model_spec.js index ab753a7e5e2..f096e06f43c 100644 --- a/spec/javascripts/ide/lib/common/model_spec.js +++ b/spec/javascripts/ide/lib/common/model_spec.js @@ -1,4 +1,3 @@ -import * as monaco from 'monaco-editor'; import eventHub from '~/ide/eventhub'; import Model from '~/ide/lib/common/model'; import { file } from '../../helpers'; @@ -12,7 +11,7 @@ describe('Multi-file editor library model', () => { const f = file('path'); f.mrChange = { diff: 'ABC' }; f.baseRaw = 'test'; - model = new Model(monaco, f); + model = new Model(f); }); afterEach(() => { @@ -33,7 +32,7 @@ describe('Multi-file editor library model', () => { const f = file('path'); model.dispose(); - model = new Model(monaco, f, { + model = new Model(f, { ...f, content: '123 testing', }); diff --git a/spec/javascripts/ide/lib/decorations/controller_spec.js b/spec/javascripts/ide/lib/decorations/controller_spec.js index 6f50056be73..a112361e0d1 100644 --- a/spec/javascripts/ide/lib/decorations/controller_spec.js +++ b/spec/javascripts/ide/lib/decorations/controller_spec.js @@ -1,4 +1,3 @@ -import * as monaco from 'monaco-editor'; import Editor from '~/ide/lib/editor'; import DecorationsController from '~/ide/lib/decorations/controller'; import Model from '~/ide/lib/common/model'; @@ -14,7 +13,7 @@ describe('Multi-file editor library decorations controller', () => { editorInstance.createInstance(document.createElement('div')); controller = new DecorationsController(editorInstance); - model = new Model(monaco, file('path')); + model = new Model(file('path')); }); afterEach(() => { diff --git a/spec/javascripts/ide/lib/diff/controller_spec.js b/spec/javascripts/ide/lib/diff/controller_spec.js index 2438fb22036..96abd1dcd9e 100644 --- a/spec/javascripts/ide/lib/diff/controller_spec.js +++ b/spec/javascripts/ide/lib/diff/controller_spec.js @@ -1,4 +1,4 @@ -import * as monaco from 'monaco-editor'; +import { Range } from 'monaco-editor'; import Editor from '~/ide/lib/editor'; import ModelManager from '~/ide/lib/common/model_manager'; import DecorationsController from '~/ide/lib/decorations/controller'; @@ -17,7 +17,7 @@ describe('Multi-file editor library dirty diff controller', () => { editorInstance = Editor.create(); editorInstance.createInstance(document.createElement('div')); - modelManager = new ModelManager(monaco); + modelManager = new ModelManager(); decorationsController = new DecorationsController(editorInstance); model = modelManager.addModel(file('path')); @@ -165,7 +165,7 @@ describe('Multi-file editor library dirty diff controller', () => { [], [ { - range: new monaco.Range(1, 1, 1, 1), + range: new Range(1, 1, 1, 1), options: { isWholeLine: true, linesDecorationsClassName: 'dirty-diff dirty-diff-modified',