volar-service-typescript 0.0.26 → 0.0.27-patch.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/index.js +35 -23
- package/lib/features/diagnostics.js +1 -1
- package/lib/features/semanticTokens.js +2 -2
- package/package.json +4 -5
package/index.js
CHANGED
|
@@ -185,10 +185,10 @@ function create(ts) {
|
|
|
185
185
|
fileVersion: 0,
|
|
186
186
|
snapshot: ts.ScriptSnapshot.fromString(''),
|
|
187
187
|
};
|
|
188
|
-
if (!context.typescript) {
|
|
188
|
+
if (!context.language.typescript) {
|
|
189
189
|
return syntacticService;
|
|
190
190
|
}
|
|
191
|
-
const { sys, languageServiceHost } = context.typescript;
|
|
191
|
+
const { sys, languageServiceHost } = context.language.typescript;
|
|
192
192
|
const created = tsFaster.createLanguageService(ts, sys, languageServiceHost, proxiedHost => ts.createLanguageService(proxiedHost, (0, typescript_1.getDocumentRegistry)(ts, sys.useCaseSensitiveFileNames, languageServiceHost.getCurrentDirectory())));
|
|
193
193
|
const { languageService } = created;
|
|
194
194
|
if (created.setPreferences && context.env.getConfiguration) {
|
|
@@ -223,7 +223,7 @@ function create(ts) {
|
|
|
223
223
|
sourceScriptNames.clear();
|
|
224
224
|
for (const fileName of languageServiceHost.getScriptFileNames()) {
|
|
225
225
|
const uri = context.env.typescript.fileNameToUri(fileName);
|
|
226
|
-
const sourceFile = context.files.get(uri);
|
|
226
|
+
const sourceFile = context.language.files.get(uri);
|
|
227
227
|
if (sourceFile?.generated) {
|
|
228
228
|
const tsCode = sourceFile.generated.languagePlugin.typescript?.getScript(sourceFile.generated.code);
|
|
229
229
|
if (tsCode) {
|
|
@@ -252,7 +252,7 @@ function create(ts) {
|
|
|
252
252
|
},
|
|
253
253
|
fileNameToUri: fileName => {
|
|
254
254
|
const uri = context.env.typescript.fileNameToUri(fileName);
|
|
255
|
-
const file = context.files.get(uri);
|
|
255
|
+
const file = context.language.files.get(uri);
|
|
256
256
|
if (file?.generated) {
|
|
257
257
|
const script = file.generated.languagePlugin.typescript?.getScript(file.generated.code);
|
|
258
258
|
if (script) {
|
|
@@ -266,7 +266,7 @@ function create(ts) {
|
|
|
266
266
|
if (virtualCode) {
|
|
267
267
|
return context.documents.get(uri, virtualCode.languageId, virtualCode.snapshot);
|
|
268
268
|
}
|
|
269
|
-
const sourceFile = context.files.get(uri);
|
|
269
|
+
const sourceFile = context.language.files.get(uri);
|
|
270
270
|
if (sourceFile) {
|
|
271
271
|
return context.documents.get(uri, sourceFile.languageId, sourceFile.snapshot);
|
|
272
272
|
}
|
|
@@ -306,7 +306,7 @@ function create(ts) {
|
|
|
306
306
|
languageService.dispose();
|
|
307
307
|
},
|
|
308
308
|
async provideCompletionItems(document, position, completeContext, token) {
|
|
309
|
-
if (!(
|
|
309
|
+
if (!isSemanticDocument(document))
|
|
310
310
|
return;
|
|
311
311
|
const enable = await context.env.getConfiguration?.((0, shared_1.getConfigTitle)(document) + '.suggest.enabled') ?? true;
|
|
312
312
|
if (!enable) {
|
|
@@ -348,21 +348,21 @@ function create(ts) {
|
|
|
348
348
|
});
|
|
349
349
|
},
|
|
350
350
|
provideRenameRange(document, position, token) {
|
|
351
|
-
if (!(
|
|
351
|
+
if (!isSemanticDocument(document))
|
|
352
352
|
return;
|
|
353
353
|
return worker(token, () => {
|
|
354
354
|
return doPrepareRename(document.uri, position);
|
|
355
355
|
});
|
|
356
356
|
},
|
|
357
357
|
provideRenameEdits(document, position, newName, token) {
|
|
358
|
-
if (!(
|
|
358
|
+
if (!isSemanticDocument(document, true))
|
|
359
359
|
return;
|
|
360
360
|
return worker(token, () => {
|
|
361
361
|
return doRename(document.uri, position, newName);
|
|
362
362
|
});
|
|
363
363
|
},
|
|
364
364
|
provideCodeActions(document, range, context, token) {
|
|
365
|
-
if (!(
|
|
365
|
+
if (!isSemanticDocument(document))
|
|
366
366
|
return;
|
|
367
367
|
return worker(token, () => {
|
|
368
368
|
return getCodeActions(document.uri, range, context);
|
|
@@ -374,14 +374,14 @@ function create(ts) {
|
|
|
374
374
|
});
|
|
375
375
|
},
|
|
376
376
|
provideInlayHints(document, range, token) {
|
|
377
|
-
if (!(
|
|
377
|
+
if (!isSemanticDocument(document))
|
|
378
378
|
return;
|
|
379
379
|
return worker(token, () => {
|
|
380
380
|
return getInlayHints(document.uri, range);
|
|
381
381
|
});
|
|
382
382
|
},
|
|
383
383
|
provideCallHierarchyItems(document, position, token) {
|
|
384
|
-
if (!(
|
|
384
|
+
if (!isSemanticDocument(document))
|
|
385
385
|
return;
|
|
386
386
|
return worker(token, () => {
|
|
387
387
|
return callHierarchy.doPrepare(document.uri, position);
|
|
@@ -398,21 +398,21 @@ function create(ts) {
|
|
|
398
398
|
});
|
|
399
399
|
},
|
|
400
400
|
provideDefinition(document, position, token) {
|
|
401
|
-
if (!(
|
|
401
|
+
if (!isSemanticDocument(document))
|
|
402
402
|
return;
|
|
403
403
|
return worker(token, () => {
|
|
404
404
|
return findDefinition(document.uri, position);
|
|
405
405
|
});
|
|
406
406
|
},
|
|
407
407
|
provideTypeDefinition(document, position, token) {
|
|
408
|
-
if (!(
|
|
408
|
+
if (!isSemanticDocument(document))
|
|
409
409
|
return;
|
|
410
410
|
return worker(token, () => {
|
|
411
411
|
return findTypeDefinition(document.uri, position);
|
|
412
412
|
});
|
|
413
413
|
},
|
|
414
414
|
async provideDiagnostics(document, token) {
|
|
415
|
-
if (!(
|
|
415
|
+
if (!isSemanticDocument(document))
|
|
416
416
|
return;
|
|
417
417
|
const enable = await context.env.getConfiguration?.((0, shared_1.getConfigTitle)(document) + '.validate.enable') ?? true;
|
|
418
418
|
if (!enable) {
|
|
@@ -423,49 +423,49 @@ function create(ts) {
|
|
|
423
423
|
});
|
|
424
424
|
},
|
|
425
425
|
provideSemanticDiagnostics(document, token) {
|
|
426
|
-
if (!(
|
|
426
|
+
if (!isSemanticDocument(document))
|
|
427
427
|
return;
|
|
428
428
|
return worker(token, () => {
|
|
429
429
|
return doValidation(document.uri, { semantic: true, declaration: true });
|
|
430
430
|
});
|
|
431
431
|
},
|
|
432
432
|
provideHover(document, position, token) {
|
|
433
|
-
if (!(
|
|
433
|
+
if (!isSemanticDocument(document))
|
|
434
434
|
return;
|
|
435
435
|
return worker(token, () => {
|
|
436
436
|
return doHover(document.uri, position);
|
|
437
437
|
});
|
|
438
438
|
},
|
|
439
439
|
provideImplementation(document, position, token) {
|
|
440
|
-
if (!(
|
|
440
|
+
if (!isSemanticDocument(document))
|
|
441
441
|
return;
|
|
442
442
|
return worker(token, () => {
|
|
443
443
|
return findImplementations(document.uri, position);
|
|
444
444
|
});
|
|
445
445
|
},
|
|
446
446
|
provideReferences(document, position, referenceContext, token) {
|
|
447
|
-
if (!(
|
|
447
|
+
if (!isSemanticDocument(document, true))
|
|
448
448
|
return;
|
|
449
449
|
return worker(token, () => {
|
|
450
450
|
return findReferences(document.uri, position, referenceContext);
|
|
451
451
|
});
|
|
452
452
|
},
|
|
453
453
|
provideFileReferences(document, token) {
|
|
454
|
-
if (!(
|
|
454
|
+
if (!isSemanticDocument(document, true))
|
|
455
455
|
return;
|
|
456
456
|
return worker(token, () => {
|
|
457
457
|
return findFileReferences(document.uri);
|
|
458
458
|
});
|
|
459
459
|
},
|
|
460
460
|
provideDocumentHighlights(document, position, token) {
|
|
461
|
-
if (!(
|
|
461
|
+
if (!isSemanticDocument(document))
|
|
462
462
|
return;
|
|
463
463
|
return worker(token, () => {
|
|
464
464
|
return findDocumentHighlights(document.uri, position);
|
|
465
465
|
});
|
|
466
466
|
},
|
|
467
467
|
provideDocumentSemanticTokens(document, range, legend, token) {
|
|
468
|
-
if (!(
|
|
468
|
+
if (!isSemanticDocument(document))
|
|
469
469
|
return;
|
|
470
470
|
return worker(token, () => {
|
|
471
471
|
return getDocumentSemanticTokens(document.uri, range, legend);
|
|
@@ -482,20 +482,32 @@ function create(ts) {
|
|
|
482
482
|
});
|
|
483
483
|
},
|
|
484
484
|
provideSelectionRanges(document, positions, token) {
|
|
485
|
-
if (!(
|
|
485
|
+
if (!isSemanticDocument(document))
|
|
486
486
|
return;
|
|
487
487
|
return worker(token, () => {
|
|
488
488
|
return getSelectionRanges(document.uri, positions);
|
|
489
489
|
});
|
|
490
490
|
},
|
|
491
491
|
provideSignatureHelp(document, position, context, token) {
|
|
492
|
-
if (!(
|
|
492
|
+
if (!isSemanticDocument(document))
|
|
493
493
|
return;
|
|
494
494
|
return worker(token, () => {
|
|
495
495
|
return getSignatureHelp(document.uri, position, context);
|
|
496
496
|
});
|
|
497
497
|
},
|
|
498
498
|
};
|
|
499
|
+
function isSemanticDocument(document, withJson = false) {
|
|
500
|
+
const [virtualCode, sourceFile] = context.documents.getVirtualCodeByUri(document.uri);
|
|
501
|
+
if (virtualCode) {
|
|
502
|
+
return sourceFile.generated?.languagePlugin.typescript?.getScript(sourceFile.generated.code)?.code === virtualCode;
|
|
503
|
+
}
|
|
504
|
+
else if (withJson) {
|
|
505
|
+
return (0, shared_1.isTsDocument)(document) || (0, shared_1.isJsonDocument)(document);
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
return (0, shared_1.isTsDocument)(document);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
499
511
|
async function worker(token, callback) {
|
|
500
512
|
let oldSysVersion = await sys.sync?.();
|
|
501
513
|
let result = await callback();
|
|
@@ -15,7 +15,7 @@ function register(ctx) {
|
|
|
15
15
|
return [];
|
|
16
16
|
const token = {
|
|
17
17
|
isCancellationRequested() {
|
|
18
|
-
return ctx.typescript?.languageServiceHost.getCancellationToken?.().isCancellationRequested() ?? false;
|
|
18
|
+
return ctx.language.typescript?.languageServiceHost.getCancellationToken?.().isCancellationRequested() ?? false;
|
|
19
19
|
},
|
|
20
20
|
throwIfCancellationRequested() { },
|
|
21
21
|
};
|
|
@@ -11,12 +11,12 @@ function register(ctx) {
|
|
|
11
11
|
const file = ctx.uriToFileName(uri);
|
|
12
12
|
const start = range ? document.offsetAt(range.start) : 0;
|
|
13
13
|
const length = range ? (document.offsetAt(range.end) - start) : document.getText().length;
|
|
14
|
-
if (ctx.typescript?.languageServiceHost.getCancellationToken?.().isCancellationRequested())
|
|
14
|
+
if (ctx.language.typescript?.languageServiceHost.getCancellationToken?.().isCancellationRequested())
|
|
15
15
|
return;
|
|
16
16
|
const response2 = (0, shared_1.safeCall)(() => ctx.languageService.getEncodedSyntacticClassifications(file, { start, length }));
|
|
17
17
|
if (!response2)
|
|
18
18
|
return;
|
|
19
|
-
if (ctx.typescript?.languageServiceHost.getCancellationToken?.().isCancellationRequested())
|
|
19
|
+
if (ctx.language.typescript?.languageServiceHost.getCancellationToken?.().isCancellationRequested())
|
|
20
20
|
return;
|
|
21
21
|
const response1 = (0, shared_1.safeCall)(() => ctx.languageService.getEncodedSemanticClassifications(file, { start, length }, ts.SemanticClassificationFormat.TwentyTwenty));
|
|
22
22
|
if (!response1)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volar-service-typescript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.27-patch.1",
|
|
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",
|
|
@@ -37,13 +37,12 @@
|
|
|
37
37
|
"vscode-uri": "^3.0.8"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"@volar/language-service": "
|
|
41
|
-
"@volar/typescript": "
|
|
40
|
+
"@volar/language-service": "~2.0.0",
|
|
41
|
+
"@volar/typescript": "~2.0.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependenciesMeta": {
|
|
44
44
|
"@volar/language-service": {
|
|
45
45
|
"optional": true
|
|
46
46
|
}
|
|
47
|
-
}
|
|
48
|
-
"gitHead": "876051c97aedf04531033784019b4344cdd48881"
|
|
47
|
+
}
|
|
49
48
|
}
|