@volar/monaco 1.3.0-alpha.2-patch.1 → 1.3.0-alpha.3
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/README.md +9 -1
- package/out/editor.d.ts +2 -1
- package/out/editor.js +85 -0
- package/out/utils/provider.js +53 -59
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -89,7 +89,15 @@ languages.onLanguage('my-lang', () => {
|
|
|
89
89
|
worker,
|
|
90
90
|
['my-lang'],
|
|
91
91
|
'my-lang-markers-owner',
|
|
92
|
-
//
|
|
92
|
+
// sync files
|
|
93
|
+
() => [Uri.file('/Foo.my-lang'), Uri.file('/Bar.my-lang')],
|
|
94
|
+
editor
|
|
95
|
+
);
|
|
96
|
+
// auto close tags
|
|
97
|
+
VolarMonaco.editor.activateAutoInsertion(
|
|
98
|
+
worker,
|
|
99
|
+
['my-lang'],
|
|
100
|
+
// sync files
|
|
93
101
|
() => [Uri.file('/Foo.my-lang'), Uri.file('/Bar.my-lang')],
|
|
94
102
|
editor
|
|
95
103
|
);
|
package/out/editor.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LanguageService } from '@volar/language-service';
|
|
2
|
-
import
|
|
2
|
+
import { editor as _editor, IDisposable, Uri } from 'monaco-editor-core';
|
|
3
3
|
export declare namespace editor {
|
|
4
4
|
function activateMarkers(worker: _editor.MonacoWebWorker<LanguageService>, languages: string[], markersOwn: string, getSyncUris: () => Uri[], editor: typeof import('monaco-editor-core').editor): IDisposable;
|
|
5
|
+
function activateAutoInsertion(worker: _editor.MonacoWebWorker<LanguageService>, languages: string[], getSyncUris: () => Uri[], editor: typeof import('monaco-editor-core').editor): IDisposable;
|
|
5
6
|
}
|
package/out/editor.js
CHANGED
|
@@ -9,8 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.editor = void 0;
|
|
12
|
+
const monaco_editor_core_1 = require("monaco-editor-core");
|
|
12
13
|
const markers_1 = require("./utils/markers");
|
|
13
14
|
const protocol2monaco = require("./utils/protocol2monaco");
|
|
15
|
+
const monaco2protocol = require("./utils/monaco2protocol");
|
|
14
16
|
var editor;
|
|
15
17
|
(function (editor_1) {
|
|
16
18
|
function activateMarkers(worker, languages, markersOwn, getSyncUris, editor) {
|
|
@@ -85,5 +87,88 @@ var editor;
|
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
editor_1.activateMarkers = activateMarkers;
|
|
90
|
+
function activateAutoInsertion(worker, languages, getSyncUris, editor) {
|
|
91
|
+
const disposables = [];
|
|
92
|
+
const listener = new Map();
|
|
93
|
+
let timeout;
|
|
94
|
+
disposables.push(editor.onDidCreateModel((model) => hostingAutoInsertion(model)), editor.onWillDisposeModel(stopHostingAutoInsertion), editor.onDidChangeModelLanguage((event) => {
|
|
95
|
+
stopHostingAutoInsertion(event.model);
|
|
96
|
+
hostingAutoInsertion(event.model);
|
|
97
|
+
}), {
|
|
98
|
+
dispose: () => {
|
|
99
|
+
for (const disposable of listener.values()) {
|
|
100
|
+
disposable.dispose();
|
|
101
|
+
}
|
|
102
|
+
listener.clear();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
for (const model of editor.getModels()) {
|
|
106
|
+
hostingAutoInsertion(model);
|
|
107
|
+
}
|
|
108
|
+
return { dispose: () => disposables.forEach((d) => d.dispose()) };
|
|
109
|
+
function stopHostingAutoInsertion(model) {
|
|
110
|
+
var _a;
|
|
111
|
+
if (listener.has(model)) {
|
|
112
|
+
(_a = listener.get(model)) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
113
|
+
listener.delete(model);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function hostingAutoInsertion(model) {
|
|
117
|
+
if (!languages.includes(model.getLanguageId())) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
listener.set(model, model.onDidChangeContent((e) => {
|
|
121
|
+
if (model.isDisposed()) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
if (!model.isAttachedToEditor()) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (e.changes.length === 0 || e.isUndoing || e.isRedoing) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
const lastChange = e.changes[e.changes.length - 1];
|
|
131
|
+
doAutoInsert(model, lastChange);
|
|
132
|
+
}));
|
|
133
|
+
}
|
|
134
|
+
function doAutoInsert(model, lastChange) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
if (timeout) {
|
|
137
|
+
clearTimeout(timeout);
|
|
138
|
+
timeout = undefined;
|
|
139
|
+
}
|
|
140
|
+
const version = model.getVersionId();
|
|
141
|
+
timeout = setTimeout(() => {
|
|
142
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
var _a;
|
|
144
|
+
if (model.getVersionId() !== version) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const position = new monaco_editor_core_1.Position(lastChange.range.startLineNumber, lastChange.range.startColumn + lastChange.text.length);
|
|
148
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
149
|
+
const edit = yield languageService.doAutoInsert(model.uri.toString(), monaco2protocol.asPosition(position), {
|
|
150
|
+
lastChange: {
|
|
151
|
+
range: monaco2protocol.asRange(lastChange.range),
|
|
152
|
+
rangeLength: lastChange.rangeLength,
|
|
153
|
+
text: lastChange.text,
|
|
154
|
+
rangeOffset: lastChange.rangeOffset,
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
const codeEditor = editor.getEditors().find((e) => e.getModel() === model);
|
|
158
|
+
if (codeEditor && edit && model.getVersionId() === version) {
|
|
159
|
+
if (typeof edit === 'string') {
|
|
160
|
+
(_a = codeEditor === null || codeEditor === void 0 ? void 0 : codeEditor.getContribution('snippetController2')) === null || _a === void 0 ? void 0 : _a.insert(edit);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
model.pushEditOperations([], [protocol2monaco.asTextEdit(edit)], () => []);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}))();
|
|
167
|
+
timeout = undefined;
|
|
168
|
+
}, 100);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
editor_1.activateAutoInsertion = activateAutoInsertion;
|
|
88
173
|
})(editor = exports.editor || (exports.editor = {}));
|
|
89
174
|
//# sourceMappingURL=editor.js.map
|
package/out/utils/provider.js
CHANGED
|
@@ -26,8 +26,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
26
26
|
signatureHelpTriggerCharacters: ['(', ','],
|
|
27
27
|
provideDocumentSymbols(model, _token) {
|
|
28
28
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const
|
|
30
|
-
const codeResult = yield
|
|
29
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
30
|
+
const codeResult = yield languageService.findDocumentSymbols(model.uri.toString());
|
|
31
31
|
if (codeResult) {
|
|
32
32
|
return codeResult.map(protocol2monaco.asDocumentSymbol);
|
|
33
33
|
}
|
|
@@ -35,8 +35,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
35
35
|
},
|
|
36
36
|
provideDocumentHighlights(model, position, _token) {
|
|
37
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
const
|
|
39
|
-
const codeResult = yield
|
|
38
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
39
|
+
const codeResult = yield languageService.findDocumentHighlights(model.uri.toString(), monaco2protocol.asPosition(position));
|
|
40
40
|
if (codeResult) {
|
|
41
41
|
return codeResult.map(protocol2monaco.asDocumentHighlight);
|
|
42
42
|
}
|
|
@@ -44,8 +44,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
44
44
|
},
|
|
45
45
|
provideLinkedEditingRanges(model, position, _token) {
|
|
46
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
const
|
|
48
|
-
const codeResult = yield
|
|
47
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
48
|
+
const codeResult = yield languageService.findLinkedEditingRanges(model.uri.toString(), monaco2protocol.asPosition(position));
|
|
49
49
|
if (codeResult) {
|
|
50
50
|
return {
|
|
51
51
|
ranges: codeResult.ranges.map(protocol2monaco.asRange),
|
|
@@ -58,8 +58,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
58
58
|
},
|
|
59
59
|
provideDefinition(model, position, _token) {
|
|
60
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
|
-
const
|
|
62
|
-
const codeResult = yield
|
|
61
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
62
|
+
const codeResult = yield languageService.findDefinition(model.uri.toString(), monaco2protocol.asPosition(position));
|
|
63
63
|
// TODO: can't show if only one result from libs
|
|
64
64
|
if (codeResult) {
|
|
65
65
|
return codeResult.map(protocol2monaco.asLocation);
|
|
@@ -68,8 +68,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
68
68
|
},
|
|
69
69
|
provideImplementation(model, position, _token) {
|
|
70
70
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
-
const
|
|
72
|
-
const codeResult = yield
|
|
71
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
72
|
+
const codeResult = yield languageService.findImplementations(model.uri.toString(), monaco2protocol.asPosition(position));
|
|
73
73
|
if (codeResult) {
|
|
74
74
|
return codeResult.map(protocol2monaco.asLocation);
|
|
75
75
|
}
|
|
@@ -77,8 +77,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
77
77
|
},
|
|
78
78
|
provideTypeDefinition(model, position, _token) {
|
|
79
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
const
|
|
81
|
-
const codeResult = yield
|
|
80
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
81
|
+
const codeResult = yield languageService.findTypeDefinition(model.uri.toString(), monaco2protocol.asPosition(position));
|
|
82
82
|
if (codeResult) {
|
|
83
83
|
return codeResult.map(protocol2monaco.asLocation);
|
|
84
84
|
}
|
|
@@ -86,8 +86,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
86
86
|
},
|
|
87
87
|
provideCodeLenses(model, _token) {
|
|
88
88
|
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
-
const
|
|
90
|
-
const codeResult = yield
|
|
89
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
90
|
+
const codeResult = yield languageService.doCodeLens(model.uri.toString());
|
|
91
91
|
if (codeResult) {
|
|
92
92
|
const monacoResult = codeResult.map(protocol2monaco.asCodeLens);
|
|
93
93
|
for (let i = 0; i < monacoResult.length; i++) {
|
|
@@ -100,12 +100,12 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
102
|
},
|
|
103
|
-
resolveCodeLens(
|
|
103
|
+
resolveCodeLens(_, monacoResult) {
|
|
104
104
|
return __awaiter(this, void 0, void 0, function* () {
|
|
105
105
|
let codeResult = codeLens.get(monacoResult);
|
|
106
106
|
if (codeResult) {
|
|
107
|
-
const
|
|
108
|
-
codeResult = yield
|
|
107
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
108
|
+
codeResult = yield languageService.doCodeLensResolve(codeResult);
|
|
109
109
|
if (codeResult) {
|
|
110
110
|
monacoResult = protocol2monaco.asCodeLens(codeResult);
|
|
111
111
|
codeLens.set(monacoResult, codeResult);
|
|
@@ -123,8 +123,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
123
123
|
diagnostics.push(diagnostic);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
const
|
|
127
|
-
const codeResult = yield
|
|
126
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
127
|
+
const codeResult = yield languageService.doCodeActions(model.uri.toString(), monaco2protocol.asRange(range), {
|
|
128
128
|
diagnostics: diagnostics,
|
|
129
129
|
only: context.only ? [context.only] : undefined,
|
|
130
130
|
});
|
|
@@ -144,8 +144,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
144
144
|
return __awaiter(this, void 0, void 0, function* () {
|
|
145
145
|
let codeResult = codeActions.get(monacoResult);
|
|
146
146
|
if (codeResult) {
|
|
147
|
-
const
|
|
148
|
-
codeResult = yield
|
|
147
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
148
|
+
codeResult = yield languageService.doCodeActionResolve(codeResult);
|
|
149
149
|
if (codeResult) {
|
|
150
150
|
monacoResult = protocol2monaco.asCodeAction(codeResult);
|
|
151
151
|
codeActions.set(monacoResult, codeResult);
|
|
@@ -156,8 +156,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
156
156
|
},
|
|
157
157
|
provideDocumentFormattingEdits(model, options, _token) {
|
|
158
158
|
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
-
const
|
|
160
|
-
const codeResult = yield
|
|
159
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
160
|
+
const codeResult = yield languageService.format(model.uri.toString(), monaco2protocol.asFormattingOptions(options));
|
|
161
161
|
if (codeResult) {
|
|
162
162
|
return codeResult.map(protocol2monaco.asTextEdit);
|
|
163
163
|
}
|
|
@@ -165,8 +165,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
165
165
|
},
|
|
166
166
|
provideDocumentRangeFormattingEdits(model, range, options, _token) {
|
|
167
167
|
return __awaiter(this, void 0, void 0, function* () {
|
|
168
|
-
const
|
|
169
|
-
const codeResult = yield
|
|
168
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
169
|
+
const codeResult = yield languageService.format(model.uri.toString(), monaco2protocol.asFormattingOptions(options), monaco2protocol.asRange(range));
|
|
170
170
|
if (codeResult) {
|
|
171
171
|
return codeResult.map(protocol2monaco.asTextEdit);
|
|
172
172
|
}
|
|
@@ -174,8 +174,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
174
174
|
},
|
|
175
175
|
provideOnTypeFormattingEdits(model, position, ch, options, _token) {
|
|
176
176
|
return __awaiter(this, void 0, void 0, function* () {
|
|
177
|
-
const
|
|
178
|
-
const codeResult = yield
|
|
177
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
178
|
+
const codeResult = yield languageService.format(model.uri.toString(), monaco2protocol.asFormattingOptions(options), undefined, {
|
|
179
179
|
ch: ch,
|
|
180
180
|
position: monaco2protocol.asPosition(position),
|
|
181
181
|
});
|
|
@@ -186,8 +186,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
186
186
|
},
|
|
187
187
|
provideLinks(model, _token) {
|
|
188
188
|
return __awaiter(this, void 0, void 0, function* () {
|
|
189
|
-
const
|
|
190
|
-
const codeResult = yield
|
|
189
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
190
|
+
const codeResult = yield languageService.findDocumentLinks(model.uri.toString());
|
|
191
191
|
if (codeResult) {
|
|
192
192
|
return {
|
|
193
193
|
links: codeResult.map(protocol2monaco.asLink),
|
|
@@ -197,8 +197,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
197
197
|
},
|
|
198
198
|
provideCompletionItems(model, position, context, _token) {
|
|
199
199
|
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
-
const
|
|
201
|
-
const codeResult = yield
|
|
200
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
201
|
+
const codeResult = yield languageService.doComplete(model.uri.toString(), monaco2protocol.asPosition(position), monaco2protocol.asCompletionContext(context));
|
|
202
202
|
const fallbackRange = {
|
|
203
203
|
start: monaco2protocol.asPosition(position),
|
|
204
204
|
end: monaco2protocol.asPosition(position),
|
|
@@ -214,8 +214,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
214
214
|
return __awaiter(this, void 0, void 0, function* () {
|
|
215
215
|
let codeItem = completionItems.get(monacoItem);
|
|
216
216
|
if (codeItem) {
|
|
217
|
-
const
|
|
218
|
-
codeItem = yield
|
|
217
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
218
|
+
codeItem = yield languageService.doCompletionResolve(codeItem);
|
|
219
219
|
const fallbackRange = 'replace' in monacoItem.range
|
|
220
220
|
? monaco2protocol.asRange(monacoItem.range.replace)
|
|
221
221
|
: monaco2protocol.asRange(monacoItem.range);
|
|
@@ -227,8 +227,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
227
227
|
},
|
|
228
228
|
provideDocumentColors(model, _token) {
|
|
229
229
|
return __awaiter(this, void 0, void 0, function* () {
|
|
230
|
-
const
|
|
231
|
-
const codeResult = yield
|
|
230
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
231
|
+
const codeResult = yield languageService.findDocumentColors(model.uri.toString());
|
|
232
232
|
if (codeResult) {
|
|
233
233
|
return codeResult.map(protocol2monaco.asColorInformation);
|
|
234
234
|
}
|
|
@@ -236,10 +236,10 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
236
236
|
},
|
|
237
237
|
provideColorPresentations(model, monacoResult) {
|
|
238
238
|
return __awaiter(this, void 0, void 0, function* () {
|
|
239
|
-
const
|
|
239
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
240
240
|
const codeResult = colorInfos.get(monacoResult);
|
|
241
241
|
if (codeResult) {
|
|
242
|
-
const codeColors = yield
|
|
242
|
+
const codeColors = yield languageService.getColorPresentations(model.uri.toString(), codeResult.color, {
|
|
243
243
|
start: monaco2protocol.asPosition(model.getPositionAt(0)),
|
|
244
244
|
end: monaco2protocol.asPosition(model.getPositionAt(model.getValueLength())),
|
|
245
245
|
});
|
|
@@ -251,8 +251,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
251
251
|
},
|
|
252
252
|
provideFoldingRanges(model, _context, _token) {
|
|
253
253
|
return __awaiter(this, void 0, void 0, function* () {
|
|
254
|
-
const
|
|
255
|
-
const codeResult = yield
|
|
254
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
255
|
+
const codeResult = yield languageService.getFoldingRanges(model.uri.toString());
|
|
256
256
|
if (codeResult) {
|
|
257
257
|
return codeResult.map(protocol2monaco.asFoldingRange);
|
|
258
258
|
}
|
|
@@ -260,8 +260,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
260
260
|
},
|
|
261
261
|
provideDeclaration(model, position, _token) {
|
|
262
262
|
return __awaiter(this, void 0, void 0, function* () {
|
|
263
|
-
const
|
|
264
|
-
const codeResult = yield
|
|
263
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
264
|
+
const codeResult = yield languageService.findDefinition(model.uri.toString(), monaco2protocol.asPosition(position));
|
|
265
265
|
if (codeResult) {
|
|
266
266
|
return codeResult.map(protocol2monaco.asLocation);
|
|
267
267
|
}
|
|
@@ -269,8 +269,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
269
269
|
},
|
|
270
270
|
provideSelectionRanges(model, positions, _token) {
|
|
271
271
|
return __awaiter(this, void 0, void 0, function* () {
|
|
272
|
-
const
|
|
273
|
-
const codeResults = yield Promise.all(positions.map((position) =>
|
|
272
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
273
|
+
const codeResults = yield Promise.all(positions.map((position) => languageService.getSelectionRanges(model.uri.toString(), [
|
|
274
274
|
monaco2protocol.asPosition(position),
|
|
275
275
|
])));
|
|
276
276
|
return codeResults.map((codeResult) => { var _a; return (_a = codeResult === null || codeResult === void 0 ? void 0 : codeResult.map(protocol2monaco.asSelectionRange)) !== null && _a !== void 0 ? _a : []; });
|
|
@@ -278,8 +278,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
278
278
|
},
|
|
279
279
|
provideSignatureHelp(model, position, _token, _context) {
|
|
280
280
|
return __awaiter(this, void 0, void 0, function* () {
|
|
281
|
-
const
|
|
282
|
-
const codeResult = yield
|
|
281
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
282
|
+
const codeResult = yield languageService.getSignatureHelp(model.uri.toString(), monaco2protocol.asPosition(position));
|
|
283
283
|
if (codeResult) {
|
|
284
284
|
return {
|
|
285
285
|
value: protocol2monaco.asSignatureHelp(codeResult),
|
|
@@ -290,8 +290,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
290
290
|
},
|
|
291
291
|
provideRenameEdits(model, position, newName, _token) {
|
|
292
292
|
return __awaiter(this, void 0, void 0, function* () {
|
|
293
|
-
const
|
|
294
|
-
const codeResult = yield
|
|
293
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
294
|
+
const codeResult = yield languageService.doRename(model.uri.toString(), monaco2protocol.asPosition(position), newName);
|
|
295
295
|
if (codeResult) {
|
|
296
296
|
return protocol2monaco.asWorkspaceEdit(codeResult);
|
|
297
297
|
}
|
|
@@ -299,8 +299,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
299
299
|
},
|
|
300
300
|
provideReferences(model, position, _context, _token) {
|
|
301
301
|
return __awaiter(this, void 0, void 0, function* () {
|
|
302
|
-
const
|
|
303
|
-
const codeResult = yield
|
|
302
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
303
|
+
const codeResult = yield languageService.findReferences(model.uri.toString(), monaco2protocol.asPosition(position));
|
|
304
304
|
// TODO: can't show if only one result from libs
|
|
305
305
|
if (codeResult) {
|
|
306
306
|
return codeResult.map(protocol2monaco.asLocation);
|
|
@@ -309,8 +309,8 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
309
309
|
},
|
|
310
310
|
provideInlayHints(model, range, _token) {
|
|
311
311
|
return __awaiter(this, void 0, void 0, function* () {
|
|
312
|
-
const
|
|
313
|
-
const codeResult = yield
|
|
312
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
313
|
+
const codeResult = yield languageService.getInlayHints(model.uri.toString(), monaco2protocol.asRange(range));
|
|
314
314
|
if (codeResult) {
|
|
315
315
|
return {
|
|
316
316
|
hints: codeResult.map(protocol2monaco.asInlayHint),
|
|
@@ -321,20 +321,14 @@ function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
|
321
321
|
},
|
|
322
322
|
provideHover(model, position, _token) {
|
|
323
323
|
return __awaiter(this, void 0, void 0, function* () {
|
|
324
|
-
const
|
|
325
|
-
const codeResult = yield
|
|
324
|
+
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
325
|
+
const codeResult = yield languageService.doHover(model.uri.toString(), monaco2protocol.asPosition(position));
|
|
326
326
|
if (codeResult) {
|
|
327
327
|
return protocol2monaco.asHover(codeResult);
|
|
328
328
|
}
|
|
329
329
|
});
|
|
330
330
|
},
|
|
331
331
|
};
|
|
332
|
-
function getLanguageService(..._uris) {
|
|
333
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
334
|
-
yield worker.withSyncedResources(getSyncUris());
|
|
335
|
-
return worker.getProxy();
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
332
|
});
|
|
339
333
|
}
|
|
340
334
|
exports.createLanguageFeaturesProvider = createLanguageFeaturesProvider;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/monaco",
|
|
3
|
-
"version": "1.3.0-alpha.
|
|
3
|
+
"version": "1.3.0-alpha.3",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -15,10 +15,11 @@
|
|
|
15
15
|
"directory": "packages/monaco"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@volar/language-service": "1.3.0-alpha.
|
|
18
|
+
"@volar/language-service": "1.3.0-alpha.3",
|
|
19
19
|
"axios": "^1.3.4",
|
|
20
20
|
"monaco-editor-core": "^0.36.0",
|
|
21
21
|
"vscode-languageserver-protocol": "^3.17.3",
|
|
22
22
|
"vscode-uri": "^3.0.7"
|
|
23
|
-
}
|
|
23
|
+
},
|
|
24
|
+
"gitHead": "03c8fff84531d8740863da5f9350e0d9382b5784"
|
|
24
25
|
}
|