@volar/monaco 1.4.0-alpha.0 → 1.4.0-alpha.1
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/out/editor.js +58 -74
- package/out/languages.js +27 -38
- package/out/utils/protocol2monaco.js +28 -23
- package/out/utils/provider.js +284 -353
- package/out/worker.d.ts +1 -1
- package/out/worker.js +38 -66
- package/package.json +3 -4
package/out/utils/provider.js
CHANGED
|
@@ -1,362 +1,293 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
2
|
exports.createLanguageFeaturesProvider = void 0;
|
|
12
3
|
const language_service_1 = require("@volar/language-service");
|
|
13
4
|
const markers_1 = require("./markers");
|
|
14
5
|
const monaco2protocol = require("./monaco2protocol");
|
|
15
6
|
const protocol2monaco = require("./protocol2monaco");
|
|
16
|
-
function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
return
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
301
|
-
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
302
|
-
const codeResults = yield Promise.all(positions.map((position) => languageService.getSelectionRanges(model.uri.toString(), [monaco2protocol.asPosition(position)], token)));
|
|
303
|
-
return codeResults.map((codeResult) => { var _a; return (_a = codeResult === null || codeResult === void 0 ? void 0 : codeResult.map(protocol2monaco.asSelectionRange)) !== null && _a !== void 0 ? _a : []; });
|
|
304
|
-
});
|
|
305
|
-
},
|
|
306
|
-
provideSignatureHelp(model, position, token, context) {
|
|
307
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
308
|
-
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
309
|
-
const codeResult = yield languageService.getSignatureHelp(model.uri.toString(), monaco2protocol.asPosition(position), monaco2protocol.asSignatureHelpContext(context), token);
|
|
310
|
-
if (codeResult) {
|
|
311
|
-
return {
|
|
312
|
-
value: protocol2monaco.asSignatureHelp(codeResult),
|
|
313
|
-
dispose: () => { },
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
},
|
|
318
|
-
provideRenameEdits(model, position, newName, token) {
|
|
319
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
320
|
-
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
321
|
-
const codeResult = yield languageService.doRename(model.uri.toString(), monaco2protocol.asPosition(position), newName, token);
|
|
322
|
-
if (codeResult) {
|
|
323
|
-
return protocol2monaco.asWorkspaceEdit(codeResult);
|
|
324
|
-
}
|
|
325
|
-
});
|
|
326
|
-
},
|
|
327
|
-
provideReferences(model, position, _context, token) {
|
|
328
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
329
|
-
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
330
|
-
const codeResult = yield languageService.findReferences(model.uri.toString(), monaco2protocol.asPosition(position), token);
|
|
331
|
-
// TODO: can't show if only one result from libs
|
|
332
|
-
if (codeResult) {
|
|
333
|
-
return codeResult.map(protocol2monaco.asLocation);
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
},
|
|
337
|
-
provideInlayHints(model, range, token) {
|
|
338
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
339
|
-
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
340
|
-
const codeResult = yield languageService.getInlayHints(model.uri.toString(), monaco2protocol.asRange(range), token);
|
|
341
|
-
if (codeResult) {
|
|
342
|
-
return {
|
|
343
|
-
hints: codeResult.map(protocol2monaco.asInlayHint),
|
|
344
|
-
dispose: () => { },
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
},
|
|
349
|
-
provideHover(model, position, token) {
|
|
350
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
351
|
-
const languageService = yield worker.withSyncedResources(getSyncUris());
|
|
352
|
-
const codeResult = yield languageService.doHover(model.uri.toString(), monaco2protocol.asPosition(position), token);
|
|
353
|
-
if (codeResult) {
|
|
354
|
-
return protocol2monaco.asHover(codeResult);
|
|
355
|
-
}
|
|
356
|
-
});
|
|
357
|
-
},
|
|
358
|
-
};
|
|
359
|
-
});
|
|
7
|
+
async function createLanguageFeaturesProvider(worker, getSyncUris) {
|
|
8
|
+
const completionItems = new WeakMap();
|
|
9
|
+
const codeLens = new WeakMap();
|
|
10
|
+
const codeActions = new WeakMap();
|
|
11
|
+
const colorInfos = new WeakMap();
|
|
12
|
+
const languageService = await worker.getProxy();
|
|
13
|
+
return {
|
|
14
|
+
triggerCharacters: await languageService.triggerCharacters(),
|
|
15
|
+
autoFormatTriggerCharacters: await languageService.triggerCharacters(),
|
|
16
|
+
signatureHelpTriggerCharacters: await languageService.triggerCharacters(),
|
|
17
|
+
signatureHelpRetriggerCharacters: await languageService.triggerCharacters(),
|
|
18
|
+
getLegend() {
|
|
19
|
+
return language_service_1.standardSemanticTokensLegend;
|
|
20
|
+
},
|
|
21
|
+
async provideDocumentSemanticTokens(model, _lastResultId, token) {
|
|
22
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
23
|
+
const codeResult = await languageService.getSemanticTokens(model.uri.toString(), undefined, language_service_1.standardSemanticTokensLegend, token);
|
|
24
|
+
if (codeResult) {
|
|
25
|
+
return {
|
|
26
|
+
resultId: codeResult.resultId,
|
|
27
|
+
data: Uint32Array.from(codeResult.data),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
async provideDocumentRangeSemanticTokens(model, range, token) {
|
|
32
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
33
|
+
const codeResult = await languageService.getSemanticTokens(model.uri.toString(), monaco2protocol.asRange(range), language_service_1.standardSemanticTokensLegend, token);
|
|
34
|
+
if (codeResult) {
|
|
35
|
+
return {
|
|
36
|
+
resultId: codeResult.resultId,
|
|
37
|
+
data: Uint32Array.from(codeResult.data),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
releaseDocumentSemanticTokens() { },
|
|
42
|
+
async provideDocumentSymbols(model, token) {
|
|
43
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
44
|
+
const codeResult = await languageService.findDocumentSymbols(model.uri.toString(), token);
|
|
45
|
+
if (codeResult) {
|
|
46
|
+
return codeResult.map(protocol2monaco.asDocumentSymbol);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
async provideDocumentHighlights(model, position, token) {
|
|
50
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
51
|
+
const codeResult = await languageService.findDocumentHighlights(model.uri.toString(), monaco2protocol.asPosition(position), token);
|
|
52
|
+
if (codeResult) {
|
|
53
|
+
return codeResult.map(protocol2monaco.asDocumentHighlight);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
async provideLinkedEditingRanges(model, position, token) {
|
|
57
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
58
|
+
const codeResult = await languageService.findLinkedEditingRanges(model.uri.toString(), monaco2protocol.asPosition(position), token);
|
|
59
|
+
if (codeResult) {
|
|
60
|
+
return {
|
|
61
|
+
ranges: codeResult.ranges.map(protocol2monaco.asRange),
|
|
62
|
+
wordPattern: codeResult.wordPattern
|
|
63
|
+
? new RegExp(codeResult.wordPattern)
|
|
64
|
+
: undefined,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
async provideDefinition(model, position, token) {
|
|
69
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
70
|
+
const codeResult = await languageService.findDefinition(model.uri.toString(), monaco2protocol.asPosition(position), token);
|
|
71
|
+
if (codeResult) {
|
|
72
|
+
return codeResult.map(protocol2monaco.asLocation);
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
async provideImplementation(model, position, token) {
|
|
76
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
77
|
+
const codeResult = await languageService.findImplementations(model.uri.toString(), monaco2protocol.asPosition(position), token);
|
|
78
|
+
if (codeResult) {
|
|
79
|
+
return codeResult.map(protocol2monaco.asLocation);
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
async provideTypeDefinition(model, position, token) {
|
|
83
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
84
|
+
const codeResult = await languageService.findTypeDefinition(model.uri.toString(), monaco2protocol.asPosition(position), token);
|
|
85
|
+
if (codeResult) {
|
|
86
|
+
return codeResult.map(protocol2monaco.asLocation);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
async provideCodeLenses(model, token) {
|
|
90
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
91
|
+
const codeResult = await languageService.doCodeLens(model.uri.toString(), token);
|
|
92
|
+
if (codeResult) {
|
|
93
|
+
const monacoResult = codeResult.map(protocol2monaco.asCodeLens);
|
|
94
|
+
for (let i = 0; i < monacoResult.length; i++) {
|
|
95
|
+
codeLens.set(monacoResult[i], codeResult[i]);
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
lenses: monacoResult,
|
|
99
|
+
dispose: () => { },
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
async resolveCodeLens(_, monacoResult, token) {
|
|
104
|
+
let codeResult = codeLens.get(monacoResult);
|
|
105
|
+
if (codeResult) {
|
|
106
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
107
|
+
codeResult = await languageService.doCodeLensResolve(codeResult, token);
|
|
108
|
+
if (codeResult) {
|
|
109
|
+
monacoResult = protocol2monaco.asCodeLens(codeResult);
|
|
110
|
+
codeLens.set(monacoResult, codeResult);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return monacoResult;
|
|
114
|
+
},
|
|
115
|
+
async provideCodeActions(model, range, context, token) {
|
|
116
|
+
const diagnostics = [];
|
|
117
|
+
for (const marker of context.markers) {
|
|
118
|
+
const diagnostic = markers_1.markers.get(marker);
|
|
119
|
+
if (diagnostic) {
|
|
120
|
+
diagnostics.push(diagnostic);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
124
|
+
const codeResult = await languageService.doCodeActions(model.uri.toString(), monaco2protocol.asRange(range), {
|
|
125
|
+
diagnostics: diagnostics,
|
|
126
|
+
only: context.only ? [context.only] : undefined,
|
|
127
|
+
}, token);
|
|
128
|
+
if (codeResult) {
|
|
129
|
+
const monacoResult = codeResult.map(protocol2monaco.asCodeAction);
|
|
130
|
+
for (let i = 0; i < monacoResult.length; i++) {
|
|
131
|
+
codeActions.set(monacoResult[i], codeResult[i]);
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
actions: monacoResult,
|
|
135
|
+
dispose: () => { },
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
async resolveCodeAction(monacoResult, token) {
|
|
140
|
+
let codeResult = codeActions.get(monacoResult);
|
|
141
|
+
if (codeResult) {
|
|
142
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
143
|
+
codeResult = await languageService.doCodeActionResolve(codeResult, token);
|
|
144
|
+
if (codeResult) {
|
|
145
|
+
monacoResult = protocol2monaco.asCodeAction(codeResult);
|
|
146
|
+
codeActions.set(monacoResult, codeResult);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return monacoResult;
|
|
150
|
+
},
|
|
151
|
+
async provideDocumentFormattingEdits(model, options, token) {
|
|
152
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
153
|
+
const codeResult = await languageService.format(model.uri.toString(), monaco2protocol.asFormattingOptions(options), undefined, undefined, token);
|
|
154
|
+
if (codeResult) {
|
|
155
|
+
return codeResult.map(protocol2monaco.asTextEdit);
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
async provideDocumentRangeFormattingEdits(model, range, options, token) {
|
|
159
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
160
|
+
const codeResult = await languageService.format(model.uri.toString(), monaco2protocol.asFormattingOptions(options), monaco2protocol.asRange(range), undefined, token);
|
|
161
|
+
if (codeResult) {
|
|
162
|
+
return codeResult.map(protocol2monaco.asTextEdit);
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
async provideOnTypeFormattingEdits(model, position, ch, options, token) {
|
|
166
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
167
|
+
const codeResult = await languageService.format(model.uri.toString(), monaco2protocol.asFormattingOptions(options), undefined, {
|
|
168
|
+
ch: ch,
|
|
169
|
+
position: monaco2protocol.asPosition(position),
|
|
170
|
+
}, token);
|
|
171
|
+
if (codeResult) {
|
|
172
|
+
return codeResult.map(protocol2monaco.asTextEdit);
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
async provideLinks(model, token) {
|
|
176
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
177
|
+
const codeResult = await languageService.findDocumentLinks(model.uri.toString(), token);
|
|
178
|
+
if (codeResult) {
|
|
179
|
+
return {
|
|
180
|
+
links: codeResult.map(protocol2monaco.asLink),
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
async provideCompletionItems(model, position, context, token) {
|
|
185
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
186
|
+
const codeResult = await languageService.doComplete(model.uri.toString(), monaco2protocol.asPosition(position), monaco2protocol.asCompletionContext(context), token);
|
|
187
|
+
const fallbackRange = {
|
|
188
|
+
start: monaco2protocol.asPosition(position),
|
|
189
|
+
end: monaco2protocol.asPosition(position),
|
|
190
|
+
};
|
|
191
|
+
const monacoResult = protocol2monaco.asCompletionList(codeResult, fallbackRange);
|
|
192
|
+
for (let i = 0; i < codeResult.items.length; i++) {
|
|
193
|
+
completionItems.set(monacoResult.suggestions[i], codeResult.items[i]);
|
|
194
|
+
}
|
|
195
|
+
return monacoResult;
|
|
196
|
+
},
|
|
197
|
+
async resolveCompletionItem(monacoItem, token) {
|
|
198
|
+
let codeItem = completionItems.get(monacoItem);
|
|
199
|
+
if (codeItem) {
|
|
200
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
201
|
+
codeItem = await languageService.doCompletionResolve(codeItem, token);
|
|
202
|
+
const fallbackRange = 'replace' in monacoItem.range
|
|
203
|
+
? monaco2protocol.asRange(monacoItem.range.replace)
|
|
204
|
+
: monaco2protocol.asRange(monacoItem.range);
|
|
205
|
+
monacoItem = protocol2monaco.asCompletionItem(codeItem, fallbackRange);
|
|
206
|
+
completionItems.set(monacoItem, codeItem);
|
|
207
|
+
}
|
|
208
|
+
return monacoItem;
|
|
209
|
+
},
|
|
210
|
+
async provideDocumentColors(model, token) {
|
|
211
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
212
|
+
const codeResult = await languageService.findDocumentColors(model.uri.toString(), token);
|
|
213
|
+
if (codeResult) {
|
|
214
|
+
return codeResult.map(protocol2monaco.asColorInformation);
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
async provideColorPresentations(model, monacoResult, token) {
|
|
218
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
219
|
+
const codeResult = colorInfos.get(monacoResult);
|
|
220
|
+
if (codeResult) {
|
|
221
|
+
const codeColors = await languageService.getColorPresentations(model.uri.toString(), codeResult.color, {
|
|
222
|
+
start: monaco2protocol.asPosition(model.getPositionAt(0)),
|
|
223
|
+
end: monaco2protocol.asPosition(model.getPositionAt(model.getValueLength())),
|
|
224
|
+
}, token);
|
|
225
|
+
if (codeColors) {
|
|
226
|
+
return codeColors.map(protocol2monaco.asColorPresentation);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
},
|
|
230
|
+
async provideFoldingRanges(model, _context, token) {
|
|
231
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
232
|
+
const codeResult = await languageService.getFoldingRanges(model.uri.toString(), token);
|
|
233
|
+
if (codeResult) {
|
|
234
|
+
return codeResult.map(protocol2monaco.asFoldingRange);
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
async provideDeclaration(model, position, token) {
|
|
238
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
239
|
+
const codeResult = await languageService.findDefinition(model.uri.toString(), monaco2protocol.asPosition(position), token);
|
|
240
|
+
if (codeResult) {
|
|
241
|
+
return codeResult.map(protocol2monaco.asLocation);
|
|
242
|
+
}
|
|
243
|
+
},
|
|
244
|
+
async provideSelectionRanges(model, positions, token) {
|
|
245
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
246
|
+
const codeResults = await Promise.all(positions.map((position) => languageService.getSelectionRanges(model.uri.toString(), [monaco2protocol.asPosition(position)], token)));
|
|
247
|
+
return codeResults.map((codeResult) => codeResult?.map(protocol2monaco.asSelectionRange) ?? []);
|
|
248
|
+
},
|
|
249
|
+
async provideSignatureHelp(model, position, token, context) {
|
|
250
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
251
|
+
const codeResult = await languageService.getSignatureHelp(model.uri.toString(), monaco2protocol.asPosition(position), monaco2protocol.asSignatureHelpContext(context), token);
|
|
252
|
+
if (codeResult) {
|
|
253
|
+
return {
|
|
254
|
+
value: protocol2monaco.asSignatureHelp(codeResult),
|
|
255
|
+
dispose: () => { },
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
},
|
|
259
|
+
async provideRenameEdits(model, position, newName, token) {
|
|
260
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
261
|
+
const codeResult = await languageService.doRename(model.uri.toString(), monaco2protocol.asPosition(position), newName, token);
|
|
262
|
+
if (codeResult) {
|
|
263
|
+
return protocol2monaco.asWorkspaceEdit(codeResult);
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
async provideReferences(model, position, _context, token) {
|
|
267
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
268
|
+
const codeResult = await languageService.findReferences(model.uri.toString(), monaco2protocol.asPosition(position), token);
|
|
269
|
+
if (codeResult) {
|
|
270
|
+
return codeResult.map(protocol2monaco.asLocation);
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
async provideInlayHints(model, range, token) {
|
|
274
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
275
|
+
const codeResult = await languageService.getInlayHints(model.uri.toString(), monaco2protocol.asRange(range), token);
|
|
276
|
+
if (codeResult) {
|
|
277
|
+
return {
|
|
278
|
+
hints: codeResult.map(protocol2monaco.asInlayHint),
|
|
279
|
+
dispose: () => { },
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
},
|
|
283
|
+
async provideHover(model, position, token) {
|
|
284
|
+
const languageService = await worker.withSyncedResources(getSyncUris());
|
|
285
|
+
const codeResult = await languageService.doHover(model.uri.toString(), monaco2protocol.asPosition(position), token);
|
|
286
|
+
if (codeResult) {
|
|
287
|
+
return protocol2monaco.asHover(codeResult);
|
|
288
|
+
}
|
|
289
|
+
},
|
|
290
|
+
};
|
|
360
291
|
}
|
|
361
292
|
exports.createLanguageFeaturesProvider = createLanguageFeaturesProvider;
|
|
362
293
|
//# sourceMappingURL=provider.js.map
|