Commit 15993df1 authored by Mike Greiling's avatar Mike Greiling

remove need to pass monaco around through DI

parent 2729205b
import * as monaco from 'monaco-editor';
import Disposable from './disposable'; import Disposable from './disposable';
import eventHub from '../../eventhub'; import eventHub from '../../eventhub';
export default class Model { export default class Model {
constructor(monaco, file, head = null) { constructor(file, head = null) {
this.monaco = monaco; this.monaco = monaco;
this.disposable = new Disposable(); this.disposable = new Disposable();
this.file = file; this.file = file;
......
...@@ -3,8 +3,7 @@ import Disposable from './disposable'; ...@@ -3,8 +3,7 @@ import Disposable from './disposable';
import Model from './model'; import Model from './model';
export default class ModelManager { export default class ModelManager {
constructor(monaco) { constructor() {
this.monaco = monaco;
this.disposable = new Disposable(); this.disposable = new Disposable();
this.models = new Map(); this.models = new Map();
} }
...@@ -22,7 +21,7 @@ export default class ModelManager { ...@@ -22,7 +21,7 @@ export default class ModelManager {
return this.getModel(file.key); 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.models.set(model.path, model);
this.disposable.add(model); this.disposable.add(model);
......
...@@ -31,7 +31,7 @@ export default class Editor { ...@@ -31,7 +31,7 @@ export default class Editor {
this.instance = null; this.instance = null;
this.dirtyDiffController = null; this.dirtyDiffController = null;
this.disposable = new Disposable(); this.disposable = new Disposable();
this.modelManager = new ModelManager(this.monaco); this.modelManager = new ModelManager();
this.decorationsController = new DecorationsController(this); this.decorationsController = new DecorationsController(this);
this.setupMonacoTheme(); this.setupMonacoTheme();
......
import * as monaco from 'monaco-editor';
import eventHub from '~/ide/eventhub'; import eventHub from '~/ide/eventhub';
import ModelManager from '~/ide/lib/common/model_manager'; import ModelManager from '~/ide/lib/common/model_manager';
import { file } from '../../helpers'; import { file } from '../../helpers';
...@@ -7,7 +6,7 @@ describe('Multi-file editor library model manager', () => { ...@@ -7,7 +6,7 @@ describe('Multi-file editor library model manager', () => {
let instance; let instance;
beforeEach(() => { beforeEach(() => {
instance = new ModelManager(monaco); instance = new ModelManager();
}); });
afterEach(() => { afterEach(() => {
......
import * as monaco from 'monaco-editor';
import eventHub from '~/ide/eventhub'; import eventHub from '~/ide/eventhub';
import Model from '~/ide/lib/common/model'; import Model from '~/ide/lib/common/model';
import { file } from '../../helpers'; import { file } from '../../helpers';
...@@ -12,7 +11,7 @@ describe('Multi-file editor library model', () => { ...@@ -12,7 +11,7 @@ describe('Multi-file editor library model', () => {
const f = file('path'); const f = file('path');
f.mrChange = { diff: 'ABC' }; f.mrChange = { diff: 'ABC' };
f.baseRaw = 'test'; f.baseRaw = 'test';
model = new Model(monaco, f); model = new Model(f);
}); });
afterEach(() => { afterEach(() => {
...@@ -33,7 +32,7 @@ describe('Multi-file editor library model', () => { ...@@ -33,7 +32,7 @@ describe('Multi-file editor library model', () => {
const f = file('path'); const f = file('path');
model.dispose(); model.dispose();
model = new Model(monaco, f, { model = new Model(f, {
...f, ...f,
content: '123 testing', content: '123 testing',
}); });
......
import * as monaco from 'monaco-editor';
import Editor from '~/ide/lib/editor'; import Editor from '~/ide/lib/editor';
import DecorationsController from '~/ide/lib/decorations/controller'; import DecorationsController from '~/ide/lib/decorations/controller';
import Model from '~/ide/lib/common/model'; import Model from '~/ide/lib/common/model';
...@@ -14,7 +13,7 @@ describe('Multi-file editor library decorations controller', () => { ...@@ -14,7 +13,7 @@ describe('Multi-file editor library decorations controller', () => {
editorInstance.createInstance(document.createElement('div')); editorInstance.createInstance(document.createElement('div'));
controller = new DecorationsController(editorInstance); controller = new DecorationsController(editorInstance);
model = new Model(monaco, file('path')); model = new Model(file('path'));
}); });
afterEach(() => { afterEach(() => {
......
import * as monaco from 'monaco-editor'; import { Range } from 'monaco-editor';
import Editor from '~/ide/lib/editor'; import Editor from '~/ide/lib/editor';
import ModelManager from '~/ide/lib/common/model_manager'; import ModelManager from '~/ide/lib/common/model_manager';
import DecorationsController from '~/ide/lib/decorations/controller'; import DecorationsController from '~/ide/lib/decorations/controller';
...@@ -17,7 +17,7 @@ describe('Multi-file editor library dirty diff controller', () => { ...@@ -17,7 +17,7 @@ describe('Multi-file editor library dirty diff controller', () => {
editorInstance = Editor.create(); editorInstance = Editor.create();
editorInstance.createInstance(document.createElement('div')); editorInstance.createInstance(document.createElement('div'));
modelManager = new ModelManager(monaco); modelManager = new ModelManager();
decorationsController = new DecorationsController(editorInstance); decorationsController = new DecorationsController(editorInstance);
model = modelManager.addModel(file('path')); model = modelManager.addModel(file('path'));
...@@ -165,7 +165,7 @@ describe('Multi-file editor library dirty diff controller', () => { ...@@ -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: { options: {
isWholeLine: true, isWholeLine: true,
linesDecorationsClassName: 'dirty-diff dirty-diff-modified', linesDecorationsClassName: 'dirty-diff dirty-diff-modified',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment