@difizen/libro-cofine-editor 0.1.18 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/editor-contribution.d.ts.map +1 -1
- package/es/editor-contribution.js +2 -1
- package/es/language/python/data/snippets/python.snippets.json +0 -30
- package/es/libro-e2-editor.d.ts +5 -5
- package/es/libro-e2-editor.d.ts.map +1 -1
- package/es/libro-e2-editor.js +68 -65
- package/es/libro-e2-preload.d.ts.map +1 -1
- package/es/libro-e2-preload.js +1 -3
- package/package.json +7 -7
- package/src/editor-contribution.ts +2 -5
- package/src/language/python/data/snippets/python.snippets.json +0 -30
- package/src/libro-e2-editor.ts +55 -39
- package/src/libro-e2-preload.ts +0 -2
- package/es/language/lsp/completion-provider.d.ts +0 -13
- package/es/language/lsp/completion-provider.d.ts.map +0 -1
- package/es/language/lsp/completion-provider.js +0 -294
- package/es/language/lsp/diagnostic-provider.d.ts +0 -27
- package/es/language/lsp/diagnostic-provider.d.ts.map +0 -1
- package/es/language/lsp/diagnostic-provider.js +0 -230
- package/es/language/lsp/format-provider.d.ts +0 -9
- package/es/language/lsp/format-provider.d.ts.map +0 -1
- package/es/language/lsp/format-provider.js +0 -143
- package/es/language/lsp/hover-provider.d.ts +0 -8
- package/es/language/lsp/hover-provider.d.ts.map +0 -1
- package/es/language/lsp/hover-provider.js +0 -136
- package/es/language/lsp/language-feature-provider.d.ts +0 -22
- package/es/language/lsp/language-feature-provider.d.ts.map +0 -1
- package/es/language/lsp/language-feature-provider.js +0 -194
- package/es/language/lsp/lsp-contribution.d.ts +0 -22
- package/es/language/lsp/lsp-contribution.d.ts.map +0 -1
- package/es/language/lsp/lsp-contribution.js +0 -135
- package/es/language/lsp/module.d.ts +0 -2
- package/es/language/lsp/module.d.ts.map +0 -1
- package/es/language/lsp/module.js +0 -3
- package/es/language/lsp/semantic-highlight-provider.d.ts +0 -9
- package/es/language/lsp/semantic-highlight-provider.d.ts.map +0 -1
- package/es/language/lsp/semantic-highlight-provider.js +0 -41
- package/es/language/lsp/signature-help-provider.d.ts +0 -8
- package/es/language/lsp/signature-help-provider.d.ts.map +0 -1
- package/es/language/lsp/signature-help-provider.js +0 -108
- package/es/language/lsp/type-concerters.d.ts +0 -7
- package/es/language/lsp/type-concerters.d.ts.map +0 -1
- package/es/language/lsp/type-concerters.js +0 -35
- package/src/language/lsp/completion-provider.ts +0 -213
- package/src/language/lsp/diagnostic-provider.ts +0 -168
- package/src/language/lsp/format-provider.ts +0 -88
- package/src/language/lsp/hover-provider.ts +0 -98
- package/src/language/lsp/language-feature-provider.ts +0 -107
- package/src/language/lsp/lsp-contribution.ts +0 -129
- package/src/language/lsp/module.ts +0 -5
- package/src/language/lsp/semantic-highlight-provider.ts +0 -26
- package/src/language/lsp/signature-help-provider.ts +0 -65
- package/src/language/lsp/type-concerters.ts +0 -72
package/src/libro-e2-editor.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
IEditorConfig,
|
|
9
9
|
IEditorOptions,
|
|
10
10
|
IModel,
|
|
11
|
+
IModelContentChange,
|
|
11
12
|
IPosition,
|
|
12
13
|
IRange,
|
|
13
14
|
SearchMatch,
|
|
@@ -16,6 +17,7 @@ import type {
|
|
|
16
17
|
import { defaultConfig } from '@difizen/libro-code-editor';
|
|
17
18
|
import type { E2Editor } from '@difizen/libro-cofine-editor-core';
|
|
18
19
|
import { EditorProvider, MonacoEnvironment } from '@difizen/libro-cofine-editor-core';
|
|
20
|
+
import { MIME } from '@difizen/libro-common';
|
|
19
21
|
import { NotebookCommands } from '@difizen/libro-core';
|
|
20
22
|
import type { LSPProvider } from '@difizen/libro-lsp';
|
|
21
23
|
import {
|
|
@@ -28,12 +30,11 @@ import {
|
|
|
28
30
|
watch,
|
|
29
31
|
} from '@difizen/mana-app';
|
|
30
32
|
import { Disposable, DisposableCollection, Emitter } from '@difizen/mana-app';
|
|
31
|
-
import { editor, Selection } from '@difizen/monaco-editor-core';
|
|
33
|
+
import { editor, KeyCode, Selection } from '@difizen/monaco-editor-core';
|
|
32
34
|
import 'resize-observer-polyfill';
|
|
33
35
|
import * as monaco from '@difizen/monaco-editor-core';
|
|
34
36
|
import { v4 } from 'uuid';
|
|
35
37
|
|
|
36
|
-
import { LSPContribution } from './language/lsp/lsp-contribution.js';
|
|
37
38
|
import { LanguageSpecRegistry } from './language-specs.js';
|
|
38
39
|
import { PlaceholderContentWidget } from './placeholder.js';
|
|
39
40
|
import type { MonacoEditorOptions, MonacoEditorType, MonacoMatch } from './types.js';
|
|
@@ -228,7 +229,7 @@ export const libroE2DefaultConfig: Required<LibroE2EditorConfig> = {
|
|
|
228
229
|
},
|
|
229
230
|
scrollBarHeight: 12,
|
|
230
231
|
mode: 'null',
|
|
231
|
-
mimetype:
|
|
232
|
+
mimetype: MIME.python,
|
|
232
233
|
smartIndent: true,
|
|
233
234
|
electricChars: true,
|
|
234
235
|
keyMap: 'default',
|
|
@@ -278,8 +279,6 @@ export type LibroE2EditorFactory = CodeEditorFactory;
|
|
|
278
279
|
|
|
279
280
|
export const E2EditorClassname = 'libro-e2-editor';
|
|
280
281
|
|
|
281
|
-
export const LibroE2URIScheme = 'libro-e2';
|
|
282
|
-
|
|
283
282
|
export type E2EditorState = monaco.editor.ITextModel | null;
|
|
284
283
|
|
|
285
284
|
export const e2StateFactory: (
|
|
@@ -288,10 +287,8 @@ export const e2StateFactory: (
|
|
|
288
287
|
const spec = languageSpecRegistry.languageSpecs.find(
|
|
289
288
|
(item) => item.mime === options.model.mimeType,
|
|
290
289
|
);
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
path: `${options.uuid}${spec?.ext[0]}`,
|
|
294
|
-
});
|
|
290
|
+
|
|
291
|
+
const uri = MonacoUri.parse(options.uuid);
|
|
295
292
|
const monacoModel = monaco.editor.createModel(
|
|
296
293
|
options.model.value,
|
|
297
294
|
spec?.language,
|
|
@@ -317,7 +314,6 @@ export class LibroE2Editor implements IEditor {
|
|
|
317
314
|
|
|
318
315
|
protected readonly languageSpecRegistry: LanguageSpecRegistry;
|
|
319
316
|
@inject(CommandRegistry) protected readonly commandRegistry: CommandRegistry;
|
|
320
|
-
@inject(LSPContribution) protected lspContribution: LSPContribution;
|
|
321
317
|
|
|
322
318
|
protected defaultLineHeight = 20;
|
|
323
319
|
|
|
@@ -376,6 +372,9 @@ export class LibroE2Editor implements IEditor {
|
|
|
376
372
|
return this.monacoEditor?.getModel()?.getLineCount() || 0;
|
|
377
373
|
}
|
|
378
374
|
|
|
375
|
+
protected onModelContentChangedEmitter = new Emitter<IModelContentChange[]>();
|
|
376
|
+
onModelContentChanged = this.onModelContentChangedEmitter.event;
|
|
377
|
+
|
|
379
378
|
lspProvider?: LSPProvider;
|
|
380
379
|
|
|
381
380
|
completionProvider?: CompletionProvider;
|
|
@@ -463,7 +462,7 @@ export class LibroE2Editor implements IEditor {
|
|
|
463
462
|
*
|
|
464
463
|
*/
|
|
465
464
|
// overflowWidgetsDomNode: document.getElementById('monaco-editor-overflow-widgets-root')!,
|
|
466
|
-
|
|
465
|
+
fixedOverflowWidgets: true,
|
|
467
466
|
suggest: { snippetsPreventQuickSuggestions: false },
|
|
468
467
|
autoClosingQuotes: editorConfig.autoClosingBrackets ? 'always' : 'never',
|
|
469
468
|
autoDetectHighContrast: false,
|
|
@@ -529,10 +528,19 @@ export class LibroE2Editor implements IEditor {
|
|
|
529
528
|
|
|
530
529
|
this._editor = editorPorvider.create(host, options);
|
|
531
530
|
this.toDispose.push(
|
|
532
|
-
this.monacoEditor?.onDidChangeModelContent(() => {
|
|
531
|
+
this.monacoEditor?.onDidChangeModelContent((e) => {
|
|
533
532
|
const value = this.monacoEditor?.getValue();
|
|
534
533
|
this.model.value = value ?? '';
|
|
535
|
-
|
|
534
|
+
this.onModelContentChangedEmitter.fire(
|
|
535
|
+
e.changes.map((item) => {
|
|
536
|
+
return {
|
|
537
|
+
range: this.toEditorRange(item.range),
|
|
538
|
+
rangeLength: item.rangeLength,
|
|
539
|
+
rangeOffset: item.rangeOffset,
|
|
540
|
+
text: item.text,
|
|
541
|
+
};
|
|
542
|
+
}),
|
|
543
|
+
);
|
|
536
544
|
}) ?? Disposable.NONE,
|
|
537
545
|
);
|
|
538
546
|
this.toDispose.push(
|
|
@@ -561,11 +569,6 @@ export class LibroE2Editor implements IEditor {
|
|
|
561
569
|
// this.monacoEditor._themeService,
|
|
562
570
|
// this.monacoEditor._themeService.getColorTheme(),
|
|
563
571
|
// );
|
|
564
|
-
|
|
565
|
-
// setTimeout(() => {
|
|
566
|
-
// this.monacoEditor?.trigger('editor', 'editor.action.formatDocument');
|
|
567
|
-
// console.log('trigger format');
|
|
568
|
-
// }, 5000);
|
|
569
572
|
}
|
|
570
573
|
|
|
571
574
|
protected inspectResize() {
|
|
@@ -612,22 +615,23 @@ export class LibroE2Editor implements IEditor {
|
|
|
612
615
|
*/
|
|
613
616
|
protected handleCommand(commandRegistry: CommandRegistry) {
|
|
614
617
|
// need monaco 0.34
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
618
|
+
editor.addKeybindingRules([
|
|
619
|
+
{
|
|
620
|
+
// disable show command center
|
|
621
|
+
keybinding: KeyCode.F1,
|
|
622
|
+
command: null,
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
// disable show error command
|
|
626
|
+
keybinding: KeyCode.F8,
|
|
627
|
+
command: null,
|
|
628
|
+
},
|
|
629
|
+
{
|
|
630
|
+
// disable toggle debugger breakpoint
|
|
631
|
+
keybinding: KeyCode.F9,
|
|
632
|
+
command: null,
|
|
633
|
+
},
|
|
634
|
+
]);
|
|
631
635
|
this.monacoEditor?.addCommand(
|
|
632
636
|
9,
|
|
633
637
|
() => {
|
|
@@ -817,6 +821,19 @@ export class LibroE2Editor implements IEditor {
|
|
|
817
821
|
return monacoSelection;
|
|
818
822
|
}
|
|
819
823
|
|
|
824
|
+
protected toEditorRange(range: monaco.IRange): IRange {
|
|
825
|
+
return {
|
|
826
|
+
start: {
|
|
827
|
+
line: range.startLineNumber - 1,
|
|
828
|
+
column: range.startColumn - 1,
|
|
829
|
+
},
|
|
830
|
+
end: {
|
|
831
|
+
line: range.endLineNumber - 1,
|
|
832
|
+
column: range.endColumn - 1,
|
|
833
|
+
},
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
|
|
820
837
|
getSelectionValue = (range?: IRange | undefined) => {
|
|
821
838
|
const selection = range ?? this.getSelection();
|
|
822
839
|
return this.monacoEditor
|
|
@@ -960,6 +977,10 @@ export class LibroE2Editor implements IEditor {
|
|
|
960
977
|
}
|
|
961
978
|
};
|
|
962
979
|
|
|
980
|
+
format = () => {
|
|
981
|
+
this.monacoEditor?.trigger('libro-format', 'editor.action.formatDocument', '');
|
|
982
|
+
};
|
|
983
|
+
|
|
963
984
|
protected _isDisposed = false;
|
|
964
985
|
/**
|
|
965
986
|
* Tests whether the editor is disposed.
|
|
@@ -973,15 +994,10 @@ export class LibroE2Editor implements IEditor {
|
|
|
973
994
|
}
|
|
974
995
|
this.placeholder.dispose();
|
|
975
996
|
this.disposeResizeObserver();
|
|
976
|
-
this.disposeLSP();
|
|
977
997
|
this.toDispose.dispose();
|
|
978
998
|
this._isDisposed = true;
|
|
979
999
|
};
|
|
980
1000
|
|
|
981
|
-
disposeLSP() {
|
|
982
|
-
this.lspContribution.disposeLanguageFeature();
|
|
983
|
-
}
|
|
984
|
-
|
|
985
1001
|
disposeResizeObserver = () => {
|
|
986
1002
|
if (this.intersectionObserver) {
|
|
987
1003
|
getOrigin(this.intersectionObserver).disconnect();
|
package/src/libro-e2-preload.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { MonacoEnvironment } from '@difizen/libro-cofine-editor-core';
|
|
|
2
2
|
import type { Syringe } from '@difizen/mana-app';
|
|
3
3
|
import { Deferred } from '@difizen/mana-app';
|
|
4
4
|
|
|
5
|
-
import { LSPFeatureModule } from './language/lsp/module.js';
|
|
6
5
|
import { PythonLanguageFeature } from './language/python/module.js';
|
|
7
6
|
import { LibroE2ThemeModule } from './theme/module.js';
|
|
8
7
|
|
|
@@ -16,7 +15,6 @@ export const loadE2 = async (libroContainer: Syringe.Container) => {
|
|
|
16
15
|
container.load(textmate.TextmateModule);
|
|
17
16
|
container.load(PythonLanguageFeature);
|
|
18
17
|
container.load(LibroE2ThemeModule);
|
|
19
|
-
container.load(LSPFeatureModule);
|
|
20
18
|
});
|
|
21
19
|
await MonacoEnvironment.init();
|
|
22
20
|
E2LoadedDeferred.resolve();
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { languages } from '@difizen/monaco-editor-core';
|
|
2
|
-
import type monaco from '@difizen/monaco-editor-core';
|
|
3
|
-
import * as lsp from 'vscode-languageserver-protocol';
|
|
4
|
-
import { LangaugeFeatureProvider } from './language-feature-provider.js';
|
|
5
|
-
export declare class CompletionProvider extends LangaugeFeatureProvider implements monaco.languages.CompletionItemProvider {
|
|
6
|
-
triggerCharacters: ['.', '[', '"', "'"];
|
|
7
|
-
provideCompletionItems: (model: monaco.editor.ITextModel, position: monaco.Position) => Promise<monaco.languages.CompletionList | undefined>;
|
|
8
|
-
protected provideCompletionItemsFromKernel: (model: monaco.editor.ITextModel, position: monaco.Position) => Promise<monaco.languages.CompletionList | undefined>;
|
|
9
|
-
protected provideCompletionItemsFromLSPServer: (model: monaco.editor.ITextModel, position: monaco.Position) => Promise<monaco.languages.CompletionList | undefined>;
|
|
10
|
-
resolveCompletionItem: (item: monaco.languages.CompletionItem, token: monaco.CancellationToken) => Promise<monaco.languages.CompletionItem | undefined>;
|
|
11
|
-
transformCompletion(item: lsp.CompletionItem, range: monaco.IRange | monaco.languages.CompletionItemRanges): monaco.languages.CompletionItem;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=completion-provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"completion-provider.d.ts","sourceRoot":"","sources":["../../../src/language/lsp/completion-provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AACtD,OAAO,KAAK,GAAG,MAAM,gCAAgC,CAAC;AAGtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,qBAAa,kBACX,SAAQ,uBACR,YAAW,MAAM,CAAC,SAAS,CAAC,sBAAsB;IAElD,iBAAiB,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAEjC,sBAAsB,UACpB,OAAO,MAAM,CAAC,UAAU,YACrB,OAAO,QAAQ,KACxB,QAAQ,gBAAgB,CAAC,cAAc,GAAG,SAAS,CAAC,CAGrD;IAEF,SAAS,CAAC,gCAAgC,UACjC,OAAO,MAAM,CAAC,UAAU,YACrB,OAAO,QAAQ,KACxB,QAAQ,gBAAgB,CAAC,cAAc,GAAG,SAAS,CAAC,CAuCrD;IAEF,SAAS,CAAC,mCAAmC,UACpC,OAAO,MAAM,CAAC,UAAU,YACrB,OAAO,QAAQ,KACxB,QAAQ,gBAAgB,CAAC,cAAc,GAAG,SAAS,CAAC,CA8DrD;IAEF,qBAAqB,SACb,gBAAgB,CAAC,cAAc,SAC9B,OAAO,iBAAiB,KAC9B,QAAQ,gBAAgB,CAAC,cAAc,GAAG,SAAS,CAAC,CAarD;IAEF,mBAAmB,CACjB,IAAI,EAAE,GAAG,CAAC,cAAc,EACxB,KAAK,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,oBAAoB,GAC3D,MAAM,CAAC,SAAS,CAAC,cAAc;CAgDnC"}
|
|
@@ -1,294 +0,0 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
6
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
7
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
8
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
9
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
10
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
11
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
14
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
15
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
16
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
17
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
18
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
19
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
20
|
-
import { CompletionTriggerKind } from '@difizen/libro-lsp';
|
|
21
|
-
import { languages } from '@difizen/monaco-editor-core';
|
|
22
|
-
import * as lsp from 'vscode-languageserver-protocol';
|
|
23
|
-
import { InsertReplaceEdit } from 'vscode-languageserver-protocol';
|
|
24
|
-
import { LangaugeFeatureProvider } from "./language-feature-provider.js";
|
|
25
|
-
import { CompletionItemKind } from "./type-concerters.js";
|
|
26
|
-
export var CompletionProvider = /*#__PURE__*/function (_LangaugeFeatureProvi) {
|
|
27
|
-
_inherits(CompletionProvider, _LangaugeFeatureProvi);
|
|
28
|
-
var _super = _createSuper(CompletionProvider);
|
|
29
|
-
function CompletionProvider() {
|
|
30
|
-
var _this;
|
|
31
|
-
_classCallCheck(this, CompletionProvider);
|
|
32
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
33
|
-
args[_key] = arguments[_key];
|
|
34
|
-
}
|
|
35
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
36
|
-
_this.provideCompletionItems = /*#__PURE__*/function () {
|
|
37
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(model, position) {
|
|
38
|
-
var result;
|
|
39
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
40
|
-
while (1) switch (_context.prev = _context.next) {
|
|
41
|
-
case 0:
|
|
42
|
-
_context.next = 2;
|
|
43
|
-
return _this.provideCompletionItemsFromLSPServer(model, position);
|
|
44
|
-
case 2:
|
|
45
|
-
result = _context.sent;
|
|
46
|
-
return _context.abrupt("return", result);
|
|
47
|
-
case 4:
|
|
48
|
-
case "end":
|
|
49
|
-
return _context.stop();
|
|
50
|
-
}
|
|
51
|
-
}, _callee);
|
|
52
|
-
}));
|
|
53
|
-
return function (_x, _x2) {
|
|
54
|
-
return _ref.apply(this, arguments);
|
|
55
|
-
};
|
|
56
|
-
}();
|
|
57
|
-
_this.provideCompletionItemsFromKernel = /*#__PURE__*/function () {
|
|
58
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(model, position) {
|
|
59
|
-
var _editor$completionPro, _reply$matches;
|
|
60
|
-
var editor, reply, start, end, suggestion;
|
|
61
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
62
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
63
|
-
case 0:
|
|
64
|
-
editor = _this.getEditorByModel(model);
|
|
65
|
-
if (!(!editor || editor.getOption('lspEnabled') !== true)) {
|
|
66
|
-
_context2.next = 3;
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
return _context2.abrupt("return");
|
|
70
|
-
case 3:
|
|
71
|
-
_context2.next = 5;
|
|
72
|
-
return (_editor$completionPro = editor.completionProvider) === null || _editor$completionPro === void 0 ? void 0 : _editor$completionPro.call(editor, {
|
|
73
|
-
cursorPosition: editor.getOffsetAt({
|
|
74
|
-
column: position.column,
|
|
75
|
-
line: position.lineNumber
|
|
76
|
-
})
|
|
77
|
-
});
|
|
78
|
-
case 5:
|
|
79
|
-
reply = _context2.sent;
|
|
80
|
-
start = reply !== null && reply !== void 0 && reply.cursor_start ? editor.getPositionAt(reply === null || reply === void 0 ? void 0 : reply.cursor_start) : editor.getCursorPosition();
|
|
81
|
-
end = reply !== null && reply !== void 0 && reply.cursor_end ? editor.getPositionAt(reply === null || reply === void 0 ? void 0 : reply.cursor_end) : editor.getCursorPosition();
|
|
82
|
-
suggestion = ((_reply$matches = reply === null || reply === void 0 ? void 0 : reply.matches) !== null && _reply$matches !== void 0 ? _reply$matches : []).map(function (match) {
|
|
83
|
-
return {
|
|
84
|
-
label: match,
|
|
85
|
-
kind: languages.CompletionItemKind.Text,
|
|
86
|
-
insertText: match,
|
|
87
|
-
range: {
|
|
88
|
-
startColumn: start === null || start === void 0 ? void 0 : start.column,
|
|
89
|
-
startLineNumber: start === null || start === void 0 ? void 0 : start.line,
|
|
90
|
-
endColumn: end === null || end === void 0 ? void 0 : end.column,
|
|
91
|
-
endLineNumber: end === null || end === void 0 ? void 0 : end.line
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
});
|
|
95
|
-
return _context2.abrupt("return", {
|
|
96
|
-
suggestions: suggestion
|
|
97
|
-
});
|
|
98
|
-
case 10:
|
|
99
|
-
case "end":
|
|
100
|
-
return _context2.stop();
|
|
101
|
-
}
|
|
102
|
-
}, _callee2);
|
|
103
|
-
}));
|
|
104
|
-
return function (_x3, _x4) {
|
|
105
|
-
return _ref2.apply(this, arguments);
|
|
106
|
-
};
|
|
107
|
-
}();
|
|
108
|
-
_this.provideCompletionItemsFromLSPServer = /*#__PURE__*/function () {
|
|
109
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(model, position) {
|
|
110
|
-
var provider, editor, lspConnection, docEditor, doc, virtualPos, result, items, word, range, suggestions;
|
|
111
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
112
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
113
|
-
case 0:
|
|
114
|
-
_context3.next = 2;
|
|
115
|
-
return _this.getProvider(model);
|
|
116
|
-
case 2:
|
|
117
|
-
provider = _context3.sent;
|
|
118
|
-
if (provider) {
|
|
119
|
-
_context3.next = 5;
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
return _context3.abrupt("return");
|
|
123
|
-
case 5:
|
|
124
|
-
editor = _this.getEditorByModel(model);
|
|
125
|
-
if (!(!editor || editor.getOption('lspEnabled') !== true)) {
|
|
126
|
-
_context3.next = 8;
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
return _context3.abrupt("return");
|
|
130
|
-
case 8:
|
|
131
|
-
lspConnection = provider.lspConnection, docEditor = provider.editor, doc = provider.virtualDocument;
|
|
132
|
-
if (!(!lspConnection.isReady || !lspConnection.provides('completionProvider'))) {
|
|
133
|
-
_context3.next = 11;
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
return _context3.abrupt("return");
|
|
137
|
-
case 11:
|
|
138
|
-
virtualPos = doc.transformEditorToVirtual(docEditor, {
|
|
139
|
-
line: position.lineNumber - 1,
|
|
140
|
-
ch: position.column,
|
|
141
|
-
isEditor: true
|
|
142
|
-
});
|
|
143
|
-
if (virtualPos) {
|
|
144
|
-
_context3.next = 14;
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
return _context3.abrupt("return");
|
|
148
|
-
case 14:
|
|
149
|
-
_context3.next = 16;
|
|
150
|
-
return lspConnection.clientRequests['textDocument/completion'].request({
|
|
151
|
-
position: {
|
|
152
|
-
line: virtualPos.line,
|
|
153
|
-
character: virtualPos.ch
|
|
154
|
-
},
|
|
155
|
-
textDocument: {
|
|
156
|
-
uri: doc.documentInfo.uri
|
|
157
|
-
},
|
|
158
|
-
context: {
|
|
159
|
-
triggerKind: CompletionTriggerKind.Invoked
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
case 16:
|
|
163
|
-
result = _context3.sent;
|
|
164
|
-
items = 'items' in result ? result.items : result;
|
|
165
|
-
word = model.getWordUntilPosition(position);
|
|
166
|
-
range = {
|
|
167
|
-
startLineNumber: position.lineNumber,
|
|
168
|
-
endLineNumber: position.lineNumber,
|
|
169
|
-
startColumn: word.startColumn,
|
|
170
|
-
endColumn: position.column
|
|
171
|
-
};
|
|
172
|
-
suggestions = items.map(function (item) {
|
|
173
|
-
return _this.transformCompletion(item, range);
|
|
174
|
-
});
|
|
175
|
-
if (!Array.isArray(result)) {
|
|
176
|
-
_context3.next = 23;
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
return _context3.abrupt("return", {
|
|
180
|
-
suggestions: suggestions
|
|
181
|
-
});
|
|
182
|
-
case 23:
|
|
183
|
-
return _context3.abrupt("return", {
|
|
184
|
-
incomplete: result.isIncomplete,
|
|
185
|
-
suggestions: suggestions
|
|
186
|
-
});
|
|
187
|
-
case 24:
|
|
188
|
-
case "end":
|
|
189
|
-
return _context3.stop();
|
|
190
|
-
}
|
|
191
|
-
}, _callee3);
|
|
192
|
-
}));
|
|
193
|
-
return function (_x5, _x6) {
|
|
194
|
-
return _ref3.apply(this, arguments);
|
|
195
|
-
};
|
|
196
|
-
}();
|
|
197
|
-
_this.resolveCompletionItem = /*#__PURE__*/function () {
|
|
198
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(item, token) {
|
|
199
|
-
var original, lspConnection, itemResult, resolve;
|
|
200
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
201
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
202
|
-
case 0:
|
|
203
|
-
original = item.__original;
|
|
204
|
-
if (original) {
|
|
205
|
-
_context4.next = 3;
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
return _context4.abrupt("return");
|
|
209
|
-
case 3:
|
|
210
|
-
_context4.next = 5;
|
|
211
|
-
return _this.getLSPConnection();
|
|
212
|
-
case 5:
|
|
213
|
-
lspConnection = _context4.sent;
|
|
214
|
-
_context4.next = 8;
|
|
215
|
-
return lspConnection.clientRequests['completionItem/resolve'].request(original);
|
|
216
|
-
case 8:
|
|
217
|
-
itemResult = _context4.sent;
|
|
218
|
-
if (!token.isCancellationRequested) {
|
|
219
|
-
_context4.next = 11;
|
|
220
|
-
break;
|
|
221
|
-
}
|
|
222
|
-
return _context4.abrupt("return");
|
|
223
|
-
case 11:
|
|
224
|
-
resolve = _this.transformCompletion(itemResult, item.range);
|
|
225
|
-
return _context4.abrupt("return", resolve);
|
|
226
|
-
case 13:
|
|
227
|
-
case "end":
|
|
228
|
-
return _context4.stop();
|
|
229
|
-
}
|
|
230
|
-
}, _callee4);
|
|
231
|
-
}));
|
|
232
|
-
return function (_x7, _x8) {
|
|
233
|
-
return _ref4.apply(this, arguments);
|
|
234
|
-
};
|
|
235
|
-
}();
|
|
236
|
-
return _this;
|
|
237
|
-
}
|
|
238
|
-
_createClass(CompletionProvider, [{
|
|
239
|
-
key: "transformCompletion",
|
|
240
|
-
value: function transformCompletion(item, range) {
|
|
241
|
-
var _item$kind, _item$command;
|
|
242
|
-
var converted = _objectSpread(_objectSpread({}, item), {}, {
|
|
243
|
-
label: item.label,
|
|
244
|
-
sortText: item.sortText,
|
|
245
|
-
filterText: item.filterText,
|
|
246
|
-
insertText: item.insertText ? item.insertText : item.label,
|
|
247
|
-
kind: CompletionItemKind.from((_item$kind = item.kind) !== null && _item$kind !== void 0 ? _item$kind : lsp.CompletionItemKind.Property),
|
|
248
|
-
detail: item.detail,
|
|
249
|
-
documentation: item.documentation,
|
|
250
|
-
command: item.command ? {
|
|
251
|
-
id: item.command.command,
|
|
252
|
-
title: item.command.title,
|
|
253
|
-
arguments: (_item$command = item.command) === null || _item$command === void 0 ? void 0 : _item$command.arguments
|
|
254
|
-
} : undefined,
|
|
255
|
-
range: range,
|
|
256
|
-
additionalTextEdits: undefined
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
// FIXME: text edit 生成的range有可能在其他的editor上,这里似乎无法处理
|
|
260
|
-
if (item.textEdit) {
|
|
261
|
-
converted.insertText = item.textEdit.newText;
|
|
262
|
-
if (InsertReplaceEdit.is(item.textEdit)) {
|
|
263
|
-
converted.range = {
|
|
264
|
-
insert: convertRange(item.textEdit.insert),
|
|
265
|
-
replace: convertRange(item.textEdit.replace)
|
|
266
|
-
};
|
|
267
|
-
} else {
|
|
268
|
-
converted.range = convertRange(item.textEdit.range);
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
if (item.additionalTextEdits) {
|
|
272
|
-
converted.additionalTextEdits = item.additionalTextEdits.map(function (edit) {
|
|
273
|
-
return {
|
|
274
|
-
range: convertRange(edit.range),
|
|
275
|
-
text: edit.newText
|
|
276
|
-
};
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
// Stash a few additional pieces of information.
|
|
281
|
-
converted.__original = item;
|
|
282
|
-
return converted;
|
|
283
|
-
}
|
|
284
|
-
}]);
|
|
285
|
-
return CompletionProvider;
|
|
286
|
-
}(LangaugeFeatureProvider);
|
|
287
|
-
function convertRange(range) {
|
|
288
|
-
return {
|
|
289
|
-
startLineNumber: range.start.line + 1,
|
|
290
|
-
startColumn: range.start.character + 1,
|
|
291
|
-
endLineNumber: range.end.line + 1,
|
|
292
|
-
endColumn: range.end.character + 1
|
|
293
|
-
};
|
|
294
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { LibroService } from '@difizen/libro-core';
|
|
2
|
-
import type { ILSPDocumentConnectionManager } from '@difizen/libro-lsp';
|
|
3
|
-
import { DisposableCollection } from '@difizen/mana-app';
|
|
4
|
-
import type { Disposable } from '@difizen/mana-app';
|
|
5
|
-
import * as monaco from '@difizen/monaco-editor-core';
|
|
6
|
-
import { LangaugeFeatureProvider } from './language-feature-provider.js';
|
|
7
|
-
export declare enum MarkerSeverity {
|
|
8
|
-
Hint = 1,
|
|
9
|
-
Info = 2,
|
|
10
|
-
Warning = 4,
|
|
11
|
-
Error = 8
|
|
12
|
-
}
|
|
13
|
-
export declare class DiagnosticProvider extends LangaugeFeatureProvider implements Disposable {
|
|
14
|
-
protected toDispose: DisposableCollection;
|
|
15
|
-
constructor(libroService: LibroService, lspDocumentConnectionManager: ILSPDocumentConnectionManager);
|
|
16
|
-
protected diagnosticList: {
|
|
17
|
-
model: monaco.editor.ITextModel;
|
|
18
|
-
markers: monaco.editor.IMarkerData[];
|
|
19
|
-
}[];
|
|
20
|
-
protected addDiagnostic(model: monaco.editor.ITextModel, marker: monaco.editor.IMarkerData): void;
|
|
21
|
-
protected clearDiagnostic(): void;
|
|
22
|
-
protected displayDiagnostic(): void;
|
|
23
|
-
processDiagnostic(): Promise<void>;
|
|
24
|
-
disposed: boolean;
|
|
25
|
-
dispose(): void;
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=diagnostic-provider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostic-provider.d.ts","sourceRoot":"","sources":["../../../src/language/lsp/diagnostic-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,KAAK,MAAM,MAAM,6BAA6B,CAAC;AAKtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAEzE,oBAAY,cAAc;IACxB,IAAI,IAAI;IACR,IAAI,IAAI;IACR,OAAO,IAAI;IACX,KAAK,IAAI;CACV;AASD,qBAAa,kBAAmB,SAAQ,uBAAwB,YAAW,UAAU;IACnF,SAAS,CAAC,SAAS,uBAA8B;gBAE/C,YAAY,EAAE,YAAY,EAC1B,4BAA4B,EAAE,6BAA6B;IAM7D,SAAS,CAAC,cAAc,EAAE;QACxB,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;QAChC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;KACtC,EAAE,CAAM;IAET,SAAS,CAAC,aAAa,CACrB,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,EAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW;IAgBnC,SAAS,CAAC,eAAe;IAazB,SAAS,CAAC,iBAAiB;IAOrB,iBAAiB;IA+EvB,QAAQ,UAAS;IACjB,OAAO;CAQR"}
|