volar-service-typescript 0.0.56 → 0.0.57
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/lib/plugins/semantic.js +438 -421
- package/package.json +4 -4
package/lib/plugins/semantic.js
CHANGED
|
@@ -100,7 +100,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
100
100
|
console.warn(`[volar] typescript-semantic requires typescript project.`);
|
|
101
101
|
return {};
|
|
102
102
|
}
|
|
103
|
-
const { sys, languageServiceHost,
|
|
103
|
+
const { sys, languageServiceHost, uriConverter, getExtraServiceScript } = context.project.typescript;
|
|
104
104
|
const created = tsWithImportCache.createLanguageService(ts, sys, languageServiceHost, proxiedHost => ts.createLanguageService(proxiedHost, getDocumentRegistry(ts, sys.useCaseSensitiveFileNames, languageServiceHost.getCurrentDirectory())));
|
|
105
105
|
const { languageService } = created;
|
|
106
106
|
const ctx = {
|
|
@@ -112,7 +112,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
112
112
|
if (virtualScript) {
|
|
113
113
|
return virtualScript.fileName;
|
|
114
114
|
}
|
|
115
|
-
return asFileName(uri);
|
|
115
|
+
return uriConverter.asFileName(uri);
|
|
116
116
|
},
|
|
117
117
|
fileNameToUri(fileName) {
|
|
118
118
|
const extraServiceScript = getExtraServiceScript(fileName);
|
|
@@ -120,7 +120,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
120
120
|
const sourceScript = context.language.scripts.fromVirtualCode(extraServiceScript.code);
|
|
121
121
|
return context.encodeEmbeddedDocumentUri(sourceScript.id, extraServiceScript.code.id);
|
|
122
122
|
}
|
|
123
|
-
const uri = asUri(fileName);
|
|
123
|
+
const uri = uriConverter.asUri(fileName);
|
|
124
124
|
const sourceScript = context.language.scripts.get(uri);
|
|
125
125
|
const serviceScript = sourceScript?.generated?.languagePlugin.typescript?.getServiceScript(sourceScript.generated.root);
|
|
126
126
|
if (sourceScript && serviceScript) {
|
|
@@ -173,7 +173,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
173
173
|
updateSourceScriptFileNames();
|
|
174
174
|
}
|
|
175
175
|
for (const change of params.changes) {
|
|
176
|
-
const fileName = asFileName(vscode_uri_1.URI.parse(change.uri));
|
|
176
|
+
const fileName = uriConverter.asFileName(vscode_uri_1.URI.parse(change.uri));
|
|
177
177
|
if (sourceScriptNames.has(normalizeFileName(fileName))) {
|
|
178
178
|
created.projectUpdated?.(languageServiceHost.getCurrentDirectory());
|
|
179
179
|
}
|
|
@@ -224,282 +224,294 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
224
224
|
if (!await isSuggestionsEnabled(document, context)) {
|
|
225
225
|
return;
|
|
226
226
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
227
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const preferences = await (0, getUserPreferences_1.getUserPreferences)(ctx, document);
|
|
231
|
+
const fileName = ctx.uriToFileName(uri);
|
|
232
|
+
const offset = document.offsetAt(position);
|
|
233
|
+
const info = (0, shared_1.safeCall)(() => ctx.languageService.getCompletionsAtPosition(fileName, offset, {
|
|
234
|
+
...preferences,
|
|
235
|
+
triggerCharacter: completeContext.triggerCharacter,
|
|
236
|
+
triggerKind: completeContext.triggerKind,
|
|
237
|
+
}));
|
|
238
|
+
if (info) {
|
|
239
|
+
return (0, lspConverters_1.convertCompletionInfo)(ts, info, document, position, tsEntry => ({
|
|
240
|
+
uri: document.uri,
|
|
241
|
+
fileName,
|
|
242
|
+
offset,
|
|
243
|
+
originalItem: {
|
|
244
|
+
name: tsEntry.name,
|
|
245
|
+
source: tsEntry.source,
|
|
246
|
+
data: tsEntry.data,
|
|
247
|
+
labelDetails: tsEntry.labelDetails,
|
|
248
|
+
},
|
|
235
249
|
}));
|
|
236
|
-
|
|
237
|
-
return (0, lspConverters_1.convertCompletionInfo)(ts, info, document, position, tsEntry => ({
|
|
238
|
-
uri: document.uri,
|
|
239
|
-
fileName,
|
|
240
|
-
offset,
|
|
241
|
-
originalItem: {
|
|
242
|
-
name: tsEntry.name,
|
|
243
|
-
source: tsEntry.source,
|
|
244
|
-
data: tsEntry.data,
|
|
245
|
-
labelDetails: tsEntry.labelDetails,
|
|
246
|
-
},
|
|
247
|
-
}));
|
|
248
|
-
}
|
|
249
|
-
});
|
|
250
|
+
}
|
|
250
251
|
},
|
|
251
252
|
async resolveCompletionItem(item, token) {
|
|
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
|
-
item.
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
253
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
254
|
+
return item;
|
|
255
|
+
}
|
|
256
|
+
const data = item.data;
|
|
257
|
+
if (!data) {
|
|
258
|
+
return item;
|
|
259
|
+
}
|
|
260
|
+
const { fileName, offset } = data;
|
|
261
|
+
const uri = vscode_uri_1.URI.parse(data.uri);
|
|
262
|
+
const document = ctx.getTextDocument(uri);
|
|
263
|
+
const [formatOptions, preferences] = await Promise.all([
|
|
264
|
+
(0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document, formattingOptions),
|
|
265
|
+
(0, getUserPreferences_1.getUserPreferences)(ctx, document),
|
|
266
|
+
]);
|
|
267
|
+
const details = (0, shared_1.safeCall)(() => ctx.languageService.getCompletionEntryDetails(fileName, offset, data.originalItem.name, formatOptions, data.originalItem.source, preferences, data.originalItem.data));
|
|
268
|
+
if (!details) {
|
|
269
|
+
return item;
|
|
270
|
+
}
|
|
271
|
+
if (data.originalItem.labelDetails) {
|
|
272
|
+
item.labelDetails ??= {};
|
|
273
|
+
Object.assign(item.labelDetails, data.originalItem.labelDetails);
|
|
274
|
+
}
|
|
275
|
+
(0, lspConverters_1.applyCompletionEntryDetails)(ts, item, details, document, ctx.fileNameToUri, ctx.getTextDocument);
|
|
276
|
+
const useCodeSnippetsOnMethodSuggest = await ctx.env.getConfiguration?.((0, shared_1.getConfigTitle)(document) + '.suggest.completeFunctionCalls') ?? false;
|
|
277
|
+
const useCodeSnippet = useCodeSnippetsOnMethodSuggest
|
|
278
|
+
&& (item.kind === 3
|
|
279
|
+
|| item.kind === 2);
|
|
280
|
+
if (useCodeSnippet) {
|
|
281
|
+
const shouldCompleteFunction = isValidFunctionCompletionContext(ctx.languageService, fileName, offset, document);
|
|
282
|
+
if (shouldCompleteFunction) {
|
|
283
|
+
const { snippet, parameterCount } = (0, snippetForFunctionCall_1.snippetForFunctionCall)({
|
|
284
|
+
insertText: item.insertText ?? item.textEdit?.newText, // insertText is dropped by LSP in some case: https://github.com/microsoft/vscode-languageserver-node/blob/9b742021fb04ad081aa3676a9eecf4fa612084b4/client/src/common/codeConverter.ts#L659-L664
|
|
285
|
+
label: item.label,
|
|
286
|
+
}, details.displayParts);
|
|
287
|
+
if (item.textEdit) {
|
|
288
|
+
item.textEdit.newText = snippet;
|
|
289
|
+
}
|
|
290
|
+
if (item.insertText) {
|
|
291
|
+
item.insertText = snippet;
|
|
292
|
+
}
|
|
293
|
+
item.insertTextFormat = 2;
|
|
294
|
+
if (parameterCount > 0) {
|
|
295
|
+
//Fix for https://github.com/microsoft/vscode/issues/104059
|
|
296
|
+
//Don't show parameter hints if "editor.parameterHints.enabled": false
|
|
297
|
+
// if (await getConfiguration('editor.parameterHints.enabled', document.uri)) {
|
|
298
|
+
// item.command = {
|
|
299
|
+
// title: 'triggerParameterHints',
|
|
300
|
+
// command: 'editor.action.triggerParameterHints',
|
|
301
|
+
// };
|
|
302
|
+
// }
|
|
301
303
|
}
|
|
302
304
|
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
305
|
+
}
|
|
306
|
+
return item;
|
|
307
|
+
function isValidFunctionCompletionContext(client, filepath, offset, document) {
|
|
308
|
+
// Workaround for https://github.com/microsoft/TypeScript/issues/12677
|
|
309
|
+
// Don't complete function calls inside of destructive assignments or imports
|
|
310
|
+
try {
|
|
311
|
+
const response = client.getQuickInfoAtPosition(filepath, offset);
|
|
312
|
+
if (response) {
|
|
313
|
+
switch (response.kind) {
|
|
314
|
+
case 'var':
|
|
315
|
+
case 'let':
|
|
316
|
+
case 'const':
|
|
317
|
+
case 'alias':
|
|
318
|
+
return false;
|
|
317
319
|
}
|
|
318
320
|
}
|
|
319
|
-
catch {
|
|
320
|
-
// Noop
|
|
321
|
-
}
|
|
322
|
-
// Don't complete function call if there is already something that looks like a function call
|
|
323
|
-
// https://github.com/microsoft/vscode/issues/18131
|
|
324
|
-
const position = document.positionAt(offset);
|
|
325
|
-
const after = (0, lspConverters_1.getLineText)(document, position.line).slice(position.character);
|
|
326
|
-
return after.match(/^[a-z_$0-9]*\s*\(/gi) === null;
|
|
327
321
|
}
|
|
328
|
-
|
|
322
|
+
catch {
|
|
323
|
+
// Noop
|
|
324
|
+
}
|
|
325
|
+
// Don't complete function call if there is already something that looks like a function call
|
|
326
|
+
// https://github.com/microsoft/vscode/issues/18131
|
|
327
|
+
const position = document.positionAt(offset);
|
|
328
|
+
const after = (0, lspConverters_1.getLineText)(document, position.line).slice(position.character);
|
|
329
|
+
return after.match(/^[a-z_$0-9]*\s*\(/gi) === null;
|
|
330
|
+
}
|
|
329
331
|
},
|
|
330
|
-
provideRenameRange(document, position, token) {
|
|
332
|
+
async provideRenameRange(document, position, token) {
|
|
331
333
|
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
332
334
|
if (!isSemanticDocument(uri, document)) {
|
|
333
335
|
return;
|
|
334
336
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
return
|
|
346
|
-
}
|
|
337
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
const fileName = ctx.uriToFileName(uri);
|
|
341
|
+
const offset = document.offsetAt(position);
|
|
342
|
+
const renameInfo = (0, shared_1.safeCall)(() => ctx.languageService.getRenameInfo(fileName, offset, renameInfoOptions));
|
|
343
|
+
if (!renameInfo) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
if (!renameInfo.canRename) {
|
|
347
|
+
return { message: renameInfo.localizedErrorMessage };
|
|
348
|
+
}
|
|
349
|
+
return (0, lspConverters_1.convertTextSpan)(renameInfo.triggerSpan, document);
|
|
347
350
|
},
|
|
348
|
-
provideRenameEdits(document, position, newName, token) {
|
|
351
|
+
async provideRenameEdits(document, position, newName, token) {
|
|
349
352
|
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
350
353
|
if (!isSemanticDocument(uri, document, true)) {
|
|
351
354
|
return;
|
|
352
355
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
356
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
const fileName = ctx.uriToFileName(uri);
|
|
360
|
+
const offset = document.offsetAt(position);
|
|
361
|
+
const renameInfo = (0, shared_1.safeCall)(() => ctx.languageService.getRenameInfo(fileName, offset, renameInfoOptions));
|
|
362
|
+
if (!renameInfo?.canRename) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
if (renameInfo.fileToRename) {
|
|
366
|
+
const [formatOptions, preferences] = await Promise.all([
|
|
367
|
+
(0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document, formattingOptions),
|
|
368
|
+
(0, getUserPreferences_1.getUserPreferences)(ctx, document),
|
|
369
|
+
]);
|
|
370
|
+
return renameFile(renameInfo.fileToRename, newName, formatOptions, preferences);
|
|
371
|
+
}
|
|
372
|
+
const { providePrefixAndSuffixTextForRename } = await (0, getUserPreferences_1.getUserPreferences)(ctx, document);
|
|
373
|
+
const entries = ctx.languageService.findRenameLocations(fileName, offset, false, false, providePrefixAndSuffixTextForRename);
|
|
374
|
+
if (!entries) {
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
return (0, lspConverters_1.convertRenameLocations)(newName, entries, ctx.fileNameToUri, ctx.getTextDocument);
|
|
378
|
+
function renameFile(fileToRename, newName, formatOptions, preferences) {
|
|
379
|
+
// Make sure we preserve file extension if none provided
|
|
380
|
+
if (!path.extname(newName)) {
|
|
381
|
+
newName += path.extname(fileToRename);
|
|
366
382
|
}
|
|
367
|
-
const
|
|
368
|
-
const
|
|
369
|
-
|
|
383
|
+
const dirname = path.dirname(fileToRename);
|
|
384
|
+
const newFilePath = path.join(dirname, newName);
|
|
385
|
+
const response = (0, shared_1.safeCall)(() => ctx.languageService.getEditsForFileRename(fileToRename, newFilePath, formatOptions, preferences));
|
|
386
|
+
if (!response) {
|
|
370
387
|
return;
|
|
371
388
|
}
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
if (!path.extname(newName)) {
|
|
376
|
-
newName += path.extname(fileToRename);
|
|
377
|
-
}
|
|
378
|
-
const dirname = path.dirname(fileToRename);
|
|
379
|
-
const newFilePath = path.join(dirname, newName);
|
|
380
|
-
const response = (0, shared_1.safeCall)(() => ctx.languageService.getEditsForFileRename(fileToRename, newFilePath, formatOptions, preferences));
|
|
381
|
-
if (!response) {
|
|
382
|
-
return;
|
|
383
|
-
}
|
|
384
|
-
const edits = (0, lspConverters_1.convertFileTextChanges)(response, ctx.fileNameToUri, ctx.getTextDocument);
|
|
385
|
-
if (!edits.documentChanges) {
|
|
386
|
-
edits.documentChanges = [];
|
|
387
|
-
}
|
|
388
|
-
edits.documentChanges.push({
|
|
389
|
-
kind: 'rename',
|
|
390
|
-
oldUri: ctx.fileNameToUri(fileToRename).toString(),
|
|
391
|
-
newUri: ctx.fileNameToUri(newFilePath).toString(),
|
|
392
|
-
});
|
|
393
|
-
return edits;
|
|
389
|
+
const edits = (0, lspConverters_1.convertFileTextChanges)(response, ctx.fileNameToUri, ctx.getTextDocument);
|
|
390
|
+
if (!edits.documentChanges) {
|
|
391
|
+
edits.documentChanges = [];
|
|
394
392
|
}
|
|
395
|
-
|
|
393
|
+
edits.documentChanges.push({
|
|
394
|
+
kind: 'rename',
|
|
395
|
+
oldUri: ctx.fileNameToUri(fileToRename).toString(),
|
|
396
|
+
newUri: ctx.fileNameToUri(newFilePath).toString(),
|
|
397
|
+
});
|
|
398
|
+
return edits;
|
|
399
|
+
}
|
|
396
400
|
},
|
|
397
|
-
provideCodeActions(document, range, context, token) {
|
|
401
|
+
async provideCodeActions(document, range, context, token) {
|
|
398
402
|
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
399
403
|
if (!isSemanticDocument(uri, document)) {
|
|
400
404
|
return;
|
|
401
405
|
}
|
|
402
|
-
|
|
403
|
-
return
|
|
404
|
-
}
|
|
406
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
return getCodeActions(uri, document, range, context, formattingOptions);
|
|
405
410
|
},
|
|
406
411
|
async resolveCodeAction(codeAction, token) {
|
|
407
|
-
|
|
408
|
-
return
|
|
409
|
-
}
|
|
412
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
413
|
+
return codeAction;
|
|
414
|
+
}
|
|
415
|
+
return doCodeActionResolve(codeAction, formattingOptions);
|
|
410
416
|
},
|
|
411
|
-
provideInlayHints(document, range, token) {
|
|
417
|
+
async provideInlayHints(document, range, token) {
|
|
412
418
|
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
413
419
|
if (!isSemanticDocument(uri, document)) {
|
|
414
420
|
return;
|
|
415
421
|
}
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
return
|
|
428
|
-
}
|
|
422
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
const preferences = await (0, getUserPreferences_1.getUserPreferences)(ctx, document);
|
|
426
|
+
const fileName = ctx.uriToFileName(uri);
|
|
427
|
+
const start = document.offsetAt(range.start);
|
|
428
|
+
const end = document.offsetAt(range.end);
|
|
429
|
+
const inlayHints = (0, shared_1.safeCall)(() => 'provideInlayHints' in ctx.languageService
|
|
430
|
+
? ctx.languageService.provideInlayHints(fileName, { start, length: end - start }, preferences)
|
|
431
|
+
: []);
|
|
432
|
+
if (!inlayHints) {
|
|
433
|
+
return [];
|
|
434
|
+
}
|
|
435
|
+
return inlayHints.map(hint => (0, lspConverters_1.convertInlayHint)(hint, document));
|
|
429
436
|
},
|
|
430
|
-
provideCallHierarchyItems(document, position, token) {
|
|
437
|
+
async provideCallHierarchyItems(document, position, token) {
|
|
431
438
|
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
432
439
|
if (!isSemanticDocument(uri, document)) {
|
|
433
440
|
return;
|
|
434
441
|
}
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
442
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
443
|
+
return;
|
|
444
|
+
}
|
|
445
|
+
const fileName = ctx.uriToFileName(uri);
|
|
446
|
+
const offset = document.offsetAt(position);
|
|
447
|
+
const calls = (0, shared_1.safeCall)(() => ctx.languageService.prepareCallHierarchy(fileName, offset));
|
|
448
|
+
if (!calls) {
|
|
449
|
+
return [];
|
|
450
|
+
}
|
|
451
|
+
const items = Array.isArray(calls) ? calls : [calls];
|
|
452
|
+
return items.map(item => (0, lspConverters_1.convertCallHierarchyItem)(item, ctx));
|
|
445
453
|
},
|
|
446
454
|
async provideCallHierarchyIncomingCalls(item, token) {
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
455
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
456
|
+
return [];
|
|
457
|
+
}
|
|
458
|
+
const uri = vscode_uri_1.URI.parse(item.uri);
|
|
459
|
+
const document = ctx.getTextDocument(uri);
|
|
460
|
+
const fileName = ctx.uriToFileName(uri);
|
|
461
|
+
const offset = document.offsetAt(item.selectionRange.start);
|
|
462
|
+
const calls = (0, shared_1.safeCall)(() => ctx.languageService.provideCallHierarchyIncomingCalls(fileName, offset));
|
|
463
|
+
if (!calls) {
|
|
464
|
+
return [];
|
|
465
|
+
}
|
|
466
|
+
const items = Array.isArray(calls) ? calls : [calls];
|
|
467
|
+
return items.map(item => (0, lspConverters_1.convertCallHierarchyIncomingCall)(item, ctx));
|
|
459
468
|
},
|
|
460
469
|
async provideCallHierarchyOutgoingCalls(item, token) {
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
470
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
471
|
+
return [];
|
|
472
|
+
}
|
|
473
|
+
const uri = vscode_uri_1.URI.parse(item.uri);
|
|
474
|
+
const document = ctx.getTextDocument(uri);
|
|
475
|
+
const fileName = ctx.uriToFileName(uri);
|
|
476
|
+
const offset = document.offsetAt(item.selectionRange.start);
|
|
477
|
+
const calls = (0, shared_1.safeCall)(() => ctx.languageService.provideCallHierarchyOutgoingCalls(fileName, offset));
|
|
478
|
+
if (!calls) {
|
|
479
|
+
return [];
|
|
480
|
+
}
|
|
481
|
+
const items = Array.isArray(calls) ? calls : [calls];
|
|
482
|
+
return items.map(item => (0, lspConverters_1.convertCallHierarchyOutgoingCall)(item, document, ctx));
|
|
473
483
|
},
|
|
474
|
-
provideDefinition(document, position, token) {
|
|
484
|
+
async provideDefinition(document, position, token) {
|
|
475
485
|
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
476
486
|
if (!isSemanticDocument(uri, document)) {
|
|
477
487
|
return;
|
|
478
488
|
}
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
return
|
|
487
|
-
}
|
|
489
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
const fileName = ctx.uriToFileName(uri);
|
|
493
|
+
const offset = document.offsetAt(position);
|
|
494
|
+
const info = (0, shared_1.safeCall)(() => ctx.languageService.getDefinitionAndBoundSpan(fileName, offset));
|
|
495
|
+
if (!info) {
|
|
496
|
+
return [];
|
|
497
|
+
}
|
|
498
|
+
return (0, lspConverters_1.convertDefinitionInfoAndBoundSpan)(info, document, ctx);
|
|
488
499
|
},
|
|
489
|
-
provideTypeDefinition(document, position, token) {
|
|
500
|
+
async provideTypeDefinition(document, position, token) {
|
|
490
501
|
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
491
502
|
if (!isSemanticDocument(uri, document)) {
|
|
492
503
|
return;
|
|
493
504
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
return
|
|
502
|
-
}
|
|
505
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
506
|
+
return;
|
|
507
|
+
}
|
|
508
|
+
const fileName = ctx.uriToFileName(uri);
|
|
509
|
+
const offset = document.offsetAt(position);
|
|
510
|
+
const entries = (0, shared_1.safeCall)(() => ctx.languageService.getTypeDefinitionAtPosition(fileName, offset));
|
|
511
|
+
if (!entries) {
|
|
512
|
+
return [];
|
|
513
|
+
}
|
|
514
|
+
return entries.map(entry => (0, lspConverters_1.convertDocumentSpantoLocationLink)(entry, ctx));
|
|
503
515
|
},
|
|
504
516
|
provideDiagnostics(document, token) {
|
|
505
517
|
return provideDiagnosticsWorker(document, token, 'syntactic');
|
|
@@ -507,195 +519,204 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
507
519
|
provideSemanticDiagnostics(document, token) {
|
|
508
520
|
return provideDiagnosticsWorker(document, token, 'semantic');
|
|
509
521
|
},
|
|
510
|
-
provideHover(document, position, token) {
|
|
522
|
+
async provideHover(document, position, token) {
|
|
511
523
|
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
512
524
|
if (!isSemanticDocument(uri, document)) {
|
|
513
525
|
return;
|
|
514
526
|
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
return
|
|
523
|
-
}
|
|
527
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
const fileName = ctx.uriToFileName(uri);
|
|
531
|
+
const offset = document.offsetAt(position);
|
|
532
|
+
const info = (0, shared_1.safeCall)(() => ctx.languageService.getQuickInfoAtPosition(fileName, offset));
|
|
533
|
+
if (!info) {
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
return (0, lspConverters_1.convertQuickInfo)(ts, info, document, ctx.fileNameToUri, ctx.getTextDocument);
|
|
524
537
|
},
|
|
525
|
-
provideImplementation(document, position, token) {
|
|
538
|
+
async provideImplementation(document, position, token) {
|
|
526
539
|
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
527
540
|
if (!isSemanticDocument(uri, document)) {
|
|
528
541
|
return;
|
|
529
542
|
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
return
|
|
538
|
-
}
|
|
543
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
const fileName = ctx.uriToFileName(uri);
|
|
547
|
+
const offset = document.offsetAt(position);
|
|
548
|
+
const entries = (0, shared_1.safeCall)(() => ctx.languageService.getImplementationAtPosition(fileName, offset));
|
|
549
|
+
if (!entries) {
|
|
550
|
+
return [];
|
|
551
|
+
}
|
|
552
|
+
return entries.map(entry => (0, lspConverters_1.convertDocumentSpantoLocationLink)(entry, ctx));
|
|
539
553
|
},
|
|
540
|
-
provideReferences(document, position, referenceContext, token) {
|
|
554
|
+
async provideReferences(document, position, referenceContext, token) {
|
|
541
555
|
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
542
556
|
if (!isSemanticDocument(uri, document, true)) {
|
|
543
557
|
return;
|
|
544
558
|
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
const fileName = ctx.uriToFileName(uri);
|
|
563
|
+
const offset = document.offsetAt(position);
|
|
564
|
+
const references = (0, shared_1.safeCall)(() => ctx.languageService.findReferences(fileName, offset));
|
|
565
|
+
if (!references) {
|
|
566
|
+
return [];
|
|
567
|
+
}
|
|
568
|
+
const result = [];
|
|
569
|
+
for (const reference of references) {
|
|
570
|
+
if (referenceContext.includeDeclaration) {
|
|
571
|
+
const definition = (0, lspConverters_1.convertDocumentSpanToLocation)(reference.definition, ctx);
|
|
572
|
+
if (definition) {
|
|
573
|
+
result.push(definition);
|
|
559
574
|
}
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
575
|
+
}
|
|
576
|
+
for (const referenceEntry of reference.references) {
|
|
577
|
+
const reference = (0, lspConverters_1.convertDocumentSpanToLocation)(referenceEntry, ctx);
|
|
578
|
+
if (reference) {
|
|
579
|
+
result.push(reference);
|
|
565
580
|
}
|
|
566
581
|
}
|
|
567
|
-
|
|
568
|
-
|
|
582
|
+
}
|
|
583
|
+
return result;
|
|
569
584
|
},
|
|
570
|
-
provideFileReferences(document, token) {
|
|
585
|
+
async provideFileReferences(document, token) {
|
|
571
586
|
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
572
587
|
if (!isSemanticDocument(uri, document, true)) {
|
|
573
588
|
return;
|
|
574
589
|
}
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
return
|
|
582
|
-
}
|
|
590
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
const fileName = ctx.uriToFileName(uri);
|
|
594
|
+
const entries = (0, shared_1.safeCall)(() => ctx.languageService.getFileReferences(fileName));
|
|
595
|
+
if (!entries) {
|
|
596
|
+
return [];
|
|
597
|
+
}
|
|
598
|
+
return entries.map(entry => (0, lspConverters_1.convertDocumentSpanToLocation)(entry, ctx));
|
|
583
599
|
},
|
|
584
|
-
provideDocumentHighlights(document, position, token) {
|
|
600
|
+
async provideDocumentHighlights(document, position, token) {
|
|
585
601
|
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
586
602
|
if (!isSemanticDocument(uri, document)) {
|
|
587
603
|
return;
|
|
588
604
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
605
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
const fileName = ctx.uriToFileName(uri);
|
|
609
|
+
const offset = document.offsetAt(position);
|
|
610
|
+
const highlights = (0, shared_1.safeCall)(() => ctx.languageService.getDocumentHighlights(fileName, offset, [fileName]));
|
|
611
|
+
if (!highlights) {
|
|
612
|
+
return [];
|
|
613
|
+
}
|
|
614
|
+
const results = [];
|
|
615
|
+
for (const highlight of highlights) {
|
|
616
|
+
for (const span of highlight.highlightSpans) {
|
|
617
|
+
results.push((0, lspConverters_1.convertHighlightSpan)(span, document));
|
|
601
618
|
}
|
|
602
|
-
|
|
603
|
-
|
|
619
|
+
}
|
|
620
|
+
return results;
|
|
604
621
|
},
|
|
605
|
-
provideDocumentSemanticTokens(document, range, legend, token) {
|
|
622
|
+
async provideDocumentSemanticTokens(document, range, legend, token) {
|
|
606
623
|
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
607
624
|
if (!isSemanticDocument(uri, document)) {
|
|
608
625
|
return;
|
|
609
626
|
}
|
|
610
|
-
|
|
611
|
-
return
|
|
612
|
-
}
|
|
627
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
return getDocumentSemanticTokens(uri, document, range, legend);
|
|
613
631
|
},
|
|
614
|
-
provideWorkspaceSymbols(query, token) {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
return
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
632
|
+
async provideWorkspaceSymbols(query, token) {
|
|
633
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
const items = (0, shared_1.safeCall)(() => ctx.languageService.getNavigateToItems(query));
|
|
637
|
+
if (!items) {
|
|
638
|
+
return [];
|
|
639
|
+
}
|
|
640
|
+
return items
|
|
641
|
+
.filter(item => item.containerName || item.kind !== 'alias')
|
|
642
|
+
.map(item => (0, lspConverters_1.convertNavigateToItem)(item, ctx.getTextDocument(ctx.fileNameToUri(item.fileName))))
|
|
643
|
+
.filter(item => !!item);
|
|
625
644
|
},
|
|
626
|
-
provideFileRenameEdits(oldUri, newUri, token) {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
return
|
|
640
|
-
}
|
|
645
|
+
async provideFileRenameEdits(oldUri, newUri, token) {
|
|
646
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
647
|
+
return;
|
|
648
|
+
}
|
|
649
|
+
const document = ctx.getTextDocument(oldUri);
|
|
650
|
+
const [formatOptions, preferences] = await Promise.all([
|
|
651
|
+
(0, getFormatCodeSettings_1.getFormatCodeSettings)(ctx, document, formattingOptions),
|
|
652
|
+
(0, getUserPreferences_1.getUserPreferences)(ctx, document),
|
|
653
|
+
]);
|
|
654
|
+
const fileToRename = ctx.uriToFileName(oldUri);
|
|
655
|
+
const newFilePath = ctx.uriToFileName(newUri);
|
|
656
|
+
const response = (0, shared_1.safeCall)(() => ctx.languageService.getEditsForFileRename(fileToRename, newFilePath, formatOptions, preferences));
|
|
657
|
+
if (!response?.length) {
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
return (0, lspConverters_1.convertFileTextChanges)(response, ctx.fileNameToUri, ctx.getTextDocument);
|
|
641
661
|
},
|
|
642
|
-
provideSignatureHelp(document, position, context, token) {
|
|
662
|
+
async provideSignatureHelp(document, position, context, token) {
|
|
643
663
|
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
644
664
|
if (!isSemanticDocument(uri, document)) {
|
|
645
665
|
return;
|
|
646
666
|
}
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
667
|
+
if (await isCancellationRequestedWhileSync(token)) {
|
|
668
|
+
return;
|
|
669
|
+
}
|
|
670
|
+
const options = {};
|
|
671
|
+
if (context?.triggerKind === 1) {
|
|
672
|
+
options.triggerReason = {
|
|
673
|
+
kind: 'invoked'
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
else if (context?.triggerKind === 2) {
|
|
677
|
+
options.triggerReason = {
|
|
678
|
+
kind: 'characterTyped',
|
|
679
|
+
triggerCharacter: context.triggerCharacter,
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
else if (context?.triggerKind === 3) {
|
|
683
|
+
options.triggerReason = {
|
|
684
|
+
kind: 'retrigger',
|
|
685
|
+
triggerCharacter: context.triggerCharacter,
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
const fileName = ctx.uriToFileName(uri);
|
|
689
|
+
const offset = document.offsetAt(position);
|
|
690
|
+
const helpItems = (0, shared_1.safeCall)(() => ctx.languageService.getSignatureHelpItems(fileName, offset, options));
|
|
691
|
+
if (!helpItems) {
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
return {
|
|
695
|
+
activeSignature: helpItems.selectedItemIndex,
|
|
696
|
+
activeParameter: helpItems.argumentIndex,
|
|
697
|
+
signatures: helpItems.items.map(item => {
|
|
698
|
+
const signature = {
|
|
699
|
+
label: '',
|
|
700
|
+
documentation: undefined,
|
|
701
|
+
parameters: []
|
|
664
702
|
};
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
}
|
|
672
|
-
return {
|
|
673
|
-
activeSignature: helpItems.selectedItemIndex,
|
|
674
|
-
activeParameter: helpItems.argumentIndex,
|
|
675
|
-
signatures: helpItems.items.map(item => {
|
|
676
|
-
const signature = {
|
|
677
|
-
label: '',
|
|
678
|
-
documentation: undefined,
|
|
679
|
-
parameters: []
|
|
703
|
+
signature.label += ts.displayPartsToString(item.prefixDisplayParts);
|
|
704
|
+
item.parameters.forEach((p, i, a) => {
|
|
705
|
+
const label = ts.displayPartsToString(p.displayParts);
|
|
706
|
+
const parameter = {
|
|
707
|
+
label,
|
|
708
|
+
documentation: ts.displayPartsToString(p.documentation)
|
|
680
709
|
};
|
|
681
|
-
signature.label +=
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
signature.label += ts.displayPartsToString(item.separatorDisplayParts);
|
|
692
|
-
}
|
|
693
|
-
});
|
|
694
|
-
signature.label += ts.displayPartsToString(item.suffixDisplayParts);
|
|
695
|
-
return signature;
|
|
696
|
-
}),
|
|
697
|
-
};
|
|
698
|
-
});
|
|
710
|
+
signature.label += label;
|
|
711
|
+
signature.parameters.push(parameter);
|
|
712
|
+
if (i < a.length - 1) {
|
|
713
|
+
signature.label += ts.displayPartsToString(item.separatorDisplayParts);
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
signature.label += ts.displayPartsToString(item.suffixDisplayParts);
|
|
717
|
+
return signature;
|
|
718
|
+
}),
|
|
719
|
+
};
|
|
699
720
|
},
|
|
700
721
|
};
|
|
701
722
|
async function provideDiagnosticsWorker(document, token, mode) {
|
|
@@ -706,36 +727,37 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
706
727
|
if (!await isValidationEnabled(document, context)) {
|
|
707
728
|
return;
|
|
708
729
|
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
730
|
+
if (mode === 'semantic' && await isCancellationRequestedWhileSync(token)) {
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
const fileName = ctx.uriToFileName(uri);
|
|
734
|
+
const program = ctx.languageService.getProgram();
|
|
735
|
+
const sourceFile = program?.getSourceFile(fileName);
|
|
736
|
+
if (!program || !sourceFile) {
|
|
737
|
+
return [];
|
|
738
|
+
}
|
|
739
|
+
const tsToken = {
|
|
740
|
+
isCancellationRequested() {
|
|
741
|
+
return ctx.project.typescript?.languageServiceHost.getCancellationToken?.().isCancellationRequested() ?? false;
|
|
742
|
+
},
|
|
743
|
+
throwIfCancellationRequested() { },
|
|
744
|
+
};
|
|
745
|
+
if (mode === 'syntactic') {
|
|
746
|
+
const syntacticDiagnostics = (0, shared_1.safeCall)(() => program.getSyntacticDiagnostics(sourceFile, tsToken)) ?? [];
|
|
747
|
+
const suggestionDiagnostics = (0, shared_1.safeCall)(() => ctx.languageService.getSuggestionDiagnostics(fileName)) ?? [];
|
|
748
|
+
return [...syntacticDiagnostics, ...suggestionDiagnostics]
|
|
749
|
+
.map(diagnostic => (0, lspConverters_1.convertDiagnostic)(diagnostic, document, ctx.fileNameToUri, ctx.getTextDocument))
|
|
750
|
+
.filter(diagnostic => !!diagnostic);
|
|
751
|
+
}
|
|
752
|
+
else if (mode === 'semantic') {
|
|
753
|
+
const semanticDiagnostics = (0, shared_1.safeCall)(() => program.getSemanticDiagnostics(sourceFile, tsToken)) ?? [];
|
|
754
|
+
const declarationDiagnostics = getEmitDeclarations(program.getCompilerOptions())
|
|
755
|
+
? (0, shared_1.safeCall)(() => program.getDeclarationDiagnostics(sourceFile, tsToken)) ?? []
|
|
756
|
+
: [];
|
|
757
|
+
return [...semanticDiagnostics, ...declarationDiagnostics]
|
|
758
|
+
.map(diagnostic => (0, lspConverters_1.convertDiagnostic)(diagnostic, document, ctx.fileNameToUri, ctx.getTextDocument))
|
|
759
|
+
.filter(diagnostic => !!diagnostic);
|
|
760
|
+
}
|
|
739
761
|
}
|
|
740
762
|
function getEmitDeclarations(compilerOptions) {
|
|
741
763
|
return !!(compilerOptions.declaration || compilerOptions.composite);
|
|
@@ -750,22 +772,17 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
750
772
|
}
|
|
751
773
|
return (0, shared_1.isTsDocument)(document);
|
|
752
774
|
}
|
|
753
|
-
async function
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
}
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
break;
|
|
765
|
-
}
|
|
766
|
-
newSysVersion = await sys.sync?.();
|
|
767
|
-
} while (newSysVersion !== oldSysVersion && !token.isCancellationRequested);
|
|
768
|
-
return result;
|
|
775
|
+
async function isCancellationRequestedWhileSync(token) {
|
|
776
|
+
if (sys.sync) {
|
|
777
|
+
let oldSysVersion;
|
|
778
|
+
let newSysVersion = await sys.sync();
|
|
779
|
+
do {
|
|
780
|
+
oldSysVersion = newSysVersion;
|
|
781
|
+
languageService.getProgram(); // trigger sync
|
|
782
|
+
newSysVersion = await sys.sync();
|
|
783
|
+
} while (newSysVersion !== oldSysVersion && !token.isCancellationRequested);
|
|
784
|
+
}
|
|
785
|
+
return token.isCancellationRequested;
|
|
769
786
|
}
|
|
770
787
|
function getVirtualScriptByUri(uri) {
|
|
771
788
|
const decoded = context.decodeEmbeddedDocumentUri(uri);
|
|
@@ -773,7 +790,7 @@ function create(ts, { isValidationEnabled = async (document, context) => {
|
|
|
773
790
|
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
774
791
|
if (virtualCode && sourceScript?.generated?.languagePlugin.typescript) {
|
|
775
792
|
const { getServiceScript, getExtraServiceScripts } = sourceScript.generated?.languagePlugin.typescript;
|
|
776
|
-
const sourceFileName = asFileName(sourceScript.id);
|
|
793
|
+
const sourceFileName = uriConverter.asFileName(sourceScript.id);
|
|
777
794
|
if (getServiceScript(sourceScript.generated.root)?.code === virtualCode) {
|
|
778
795
|
return {
|
|
779
796
|
fileName: sourceFileName,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volar-service-typescript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.57",
|
|
4
4
|
"description": "Integrate TypeScript into Volar",
|
|
5
5
|
"homepage": "https://github.com/volarjs/services/tree/master/packages/typescript",
|
|
6
6
|
"bugs": "https://github.com/volarjs/services/issues",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@types/path-browserify": "latest",
|
|
28
28
|
"@types/semver": "latest",
|
|
29
|
-
"@volar/typescript": "~2.4.0-alpha.
|
|
29
|
+
"@volar/typescript": "~2.4.0-alpha.11"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"path-browserify": "^1.0.1",
|
|
@@ -37,12 +37,12 @@
|
|
|
37
37
|
"vscode-uri": "^3.0.8"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@volar/language-service": "~2.4.0-alpha.
|
|
40
|
+
"@volar/language-service": "~2.4.0-alpha.11"
|
|
41
41
|
},
|
|
42
42
|
"peerDependenciesMeta": {
|
|
43
43
|
"@volar/language-service": {
|
|
44
44
|
"optional": true
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "8ec3487544e6b06d76f66202d222170446c91264"
|
|
48
48
|
}
|