@jupyterlab/lsp
Version:
53 lines • 1.5 kB
JavaScript
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
import { Signal } from '@lumino/signaling';
/**
* The CodeEditor.IEditor adapter.
*/
export class EditorAdapter {
/**
* Instantiate a new EditorAdapter.
*
* @param options The instantiation options for a EditorAdapter.
*/
constructor(options) {
this._widgetAdapter = options.widgetAdapter;
this._extensions = options.extensions;
void options.editor.ready().then(editor => {
this._injectExtensions(options.editor);
});
}
/**
* Dispose the handler.
*/
dispose() {
if (this.isDisposed) {
return;
}
this.isDisposed = true;
Signal.clearData(this);
}
/**
* Setup the editor.
*/
_injectExtensions(editor) {
const codeEditor = editor.getEditor();
if (!codeEditor || codeEditor.isDisposed) {
return;
}
this._extensions.forEach(factory => {
const ext = factory.factory({
path: this._widgetAdapter.widget.context.path,
editor: editor,
widgetAdapter: this._widgetAdapter,
model: codeEditor.model,
inline: true
});
if (!ext) {
return;
}
codeEditor.injectExtension(ext.instance(codeEditor));
});
}
}
//# sourceMappingURL=editorAdapter.js.map