@volar/language-server 2.4.1 → 2.4.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/lib/features/languageFeatures.js +76 -38
- package/package.json +5 -5
|
@@ -5,6 +5,7 @@ const language_service_1 = require("@volar/language-service");
|
|
|
5
5
|
const vscode = require("vscode-languageserver");
|
|
6
6
|
const vscode_uri_1 = require("vscode-uri");
|
|
7
7
|
const protocol_1 = require("../../protocol");
|
|
8
|
+
const reportedCapabilities = new Set();
|
|
8
9
|
function register(server, documents, configurations) {
|
|
9
10
|
// Diagnostics support
|
|
10
11
|
let refreshReq = 0;
|
|
@@ -192,8 +193,15 @@ function register(server, documents, configurations) {
|
|
|
192
193
|
if (languageServicePlugins.some(({ capabilities }) => capabilities.workspaceSymbolProvider)) {
|
|
193
194
|
serverCapabilities.workspaceSymbolProvider = {};
|
|
194
195
|
server.connection.onWorkspaceSymbol(async (params, token) => {
|
|
196
|
+
let languageServices = await project.getExistingLanguageServices();
|
|
197
|
+
if (!languageServices.length) {
|
|
198
|
+
for (const document of documents.all()) {
|
|
199
|
+
await project.getLanguageService(vscode_uri_1.URI.parse(document.uri));
|
|
200
|
+
}
|
|
201
|
+
languageServices = await project.getExistingLanguageServices();
|
|
202
|
+
}
|
|
195
203
|
const symbols = [];
|
|
196
|
-
for (const languageService of
|
|
204
|
+
for (const languageService of languageServices) {
|
|
197
205
|
if (token.isCancellationRequested) {
|
|
198
206
|
return;
|
|
199
207
|
}
|
|
@@ -296,14 +304,14 @@ function register(server, documents, configurations) {
|
|
|
296
304
|
return await lastInlayHintLs?.resolveInlayHint(hint, token) ?? hint;
|
|
297
305
|
});
|
|
298
306
|
}
|
|
299
|
-
|
|
300
|
-
|
|
307
|
+
refreshHandlers.push(() => {
|
|
308
|
+
if (initializeParams.capabilities.workspace?.inlayHint?.refreshSupport) {
|
|
301
309
|
server.connection.languages.inlayHint.refresh();
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
wranCapabilitiesNotSupported('workspace.inlayHint.refreshSupport');
|
|
313
|
+
}
|
|
314
|
+
});
|
|
307
315
|
}
|
|
308
316
|
if (languageServicePlugins.some(({ capabilities }) => capabilities.signatureHelpProvider)) {
|
|
309
317
|
serverCapabilities.signatureHelpProvider = {
|
|
@@ -363,14 +371,14 @@ function register(server, documents, configurations) {
|
|
|
363
371
|
return await languageService?.getSemanticTokens(uri, params.range, serverCapabilities.semanticTokensProvider.legend, tokens => resultProgress?.report(tokens), token);
|
|
364
372
|
}) ?? { data: [] };
|
|
365
373
|
});
|
|
366
|
-
|
|
367
|
-
|
|
374
|
+
refreshHandlers.push(() => {
|
|
375
|
+
if (initializeParams.capabilities.workspace?.semanticTokens?.refreshSupport) {
|
|
368
376
|
server.connection.languages.semanticTokens.refresh();
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
wranCapabilitiesNotSupported('workspace.semanticTokens.refreshSupport');
|
|
380
|
+
}
|
|
381
|
+
});
|
|
374
382
|
}
|
|
375
383
|
if (languageServicePlugins.some(({ capabilities }) => capabilities.codeActionProvider)) {
|
|
376
384
|
serverCapabilities.codeActionProvider = {
|
|
@@ -391,8 +399,10 @@ function register(server, documents, configurations) {
|
|
|
391
399
|
codeAction.data = { uri: params.textDocument.uri };
|
|
392
400
|
}
|
|
393
401
|
}
|
|
394
|
-
if (!initializeParams.capabilities.textDocument?.codeAction?.disabledSupport
|
|
402
|
+
if (!initializeParams.capabilities.textDocument?.codeAction?.disabledSupport
|
|
403
|
+
&& codeActions.some(codeAction => !codeAction.disabled)) {
|
|
395
404
|
codeActions = codeActions.filter(codeAction => !codeAction.disabled);
|
|
405
|
+
wranCapabilitiesNotSupported('textDocument.codeAction.disabledSupport');
|
|
396
406
|
}
|
|
397
407
|
return codeActions;
|
|
398
408
|
});
|
|
@@ -421,7 +431,14 @@ function register(server, documents, configurations) {
|
|
|
421
431
|
commands: [...new Set(languageServicePlugins.map(({ capabilities }) => capabilities.executeCommandProvider?.commands ?? []).flat())],
|
|
422
432
|
};
|
|
423
433
|
server.connection.onExecuteCommand(async (params, token) => {
|
|
424
|
-
|
|
434
|
+
let languageServices = await project.getExistingLanguageServices();
|
|
435
|
+
if (!languageServices.length) {
|
|
436
|
+
for (const document of documents.all()) {
|
|
437
|
+
await project.getLanguageService(vscode_uri_1.URI.parse(document.uri));
|
|
438
|
+
}
|
|
439
|
+
languageServices = await project.getExistingLanguageServices();
|
|
440
|
+
}
|
|
441
|
+
for (const languageService of languageServices) {
|
|
425
442
|
if (languageService.executeCommand && languageService.commands.includes(params.command)) {
|
|
426
443
|
try {
|
|
427
444
|
return await languageService.executeCommand(params.command, params.arguments ?? [], token);
|
|
@@ -448,14 +465,14 @@ function register(server, documents, configurations) {
|
|
|
448
465
|
return languageService.getInlineValue(uri, params.range, params.context, token);
|
|
449
466
|
});
|
|
450
467
|
});
|
|
451
|
-
|
|
452
|
-
|
|
468
|
+
refreshHandlers.push(() => {
|
|
469
|
+
if (initializeParams.capabilities.workspace?.inlineValue?.refreshSupport) {
|
|
453
470
|
server.connection.languages.inlineValue.refresh();
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
}
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
wranCapabilitiesNotSupported('workspace.inlineValue.refreshSupport');
|
|
474
|
+
}
|
|
475
|
+
});
|
|
459
476
|
}
|
|
460
477
|
if (languageServicePlugins.some(({ capabilities }) => capabilities.autoInsertionProvider)) {
|
|
461
478
|
const triggerCharacterToConfigurationSections = new Map();
|
|
@@ -578,14 +595,14 @@ function register(server, documents, configurations) {
|
|
|
578
595
|
interFileDependencies: false,
|
|
579
596
|
workspaceDiagnostics,
|
|
580
597
|
};
|
|
581
|
-
|
|
582
|
-
|
|
598
|
+
refreshHandlers.push(() => {
|
|
599
|
+
if (initializeParams.capabilities.workspace?.diagnostics?.refreshSupport) {
|
|
583
600
|
server.connection.languages.diagnostics.refresh();
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
}
|
|
601
|
+
}
|
|
602
|
+
else {
|
|
603
|
+
wranCapabilitiesNotSupported('workspace.diagnostics.refreshSupport');
|
|
604
|
+
}
|
|
605
|
+
});
|
|
589
606
|
}
|
|
590
607
|
else {
|
|
591
608
|
documents.onDidChangeContent(({ document }) => {
|
|
@@ -637,8 +654,15 @@ function register(server, documents, configurations) {
|
|
|
637
654
|
}
|
|
638
655
|
if (workspaceDiagnostics) {
|
|
639
656
|
server.connection.languages.diagnostics.onWorkspace(async (_params, token) => {
|
|
657
|
+
let languageServices = await project.getExistingLanguageServices();
|
|
658
|
+
if (!languageServices.length) {
|
|
659
|
+
for (const document of documents.all()) {
|
|
660
|
+
await project.getLanguageService(vscode_uri_1.URI.parse(document.uri));
|
|
661
|
+
}
|
|
662
|
+
languageServices = await project.getExistingLanguageServices();
|
|
663
|
+
}
|
|
640
664
|
const items = [];
|
|
641
|
-
for (const languageService of
|
|
665
|
+
for (const languageService of languageServices) {
|
|
642
666
|
if (token.isCancellationRequested) {
|
|
643
667
|
break;
|
|
644
668
|
}
|
|
@@ -703,26 +727,40 @@ function register(server, documents, configurations) {
|
|
|
703
727
|
});
|
|
704
728
|
}
|
|
705
729
|
function handleCompletionItem(initializeParams, item) {
|
|
730
|
+
const snippetSupport = initializeParams.capabilities.textDocument?.completion?.completionItem?.snippetSupport ?? false;
|
|
706
731
|
const insertReplaceSupport = initializeParams.capabilities.textDocument?.completion?.completionItem?.insertReplaceSupport ?? false;
|
|
707
|
-
if (!
|
|
708
|
-
|
|
709
|
-
|
|
732
|
+
if (!snippetSupport && item.insertTextFormat === vscode.InsertTextFormat.Snippet) {
|
|
733
|
+
item.insertTextFormat = vscode.InsertTextFormat.PlainText;
|
|
734
|
+
if (item.insertText) {
|
|
735
|
+
item.insertText = item.insertText.replace(/\$\d+/g, '');
|
|
736
|
+
item.insertText = item.insertText.replace(/\${\d+:([^}]*)}/g, '');
|
|
710
737
|
}
|
|
738
|
+
wranCapabilitiesNotSupported('textDocument.completion.completionItem.snippetSupport');
|
|
739
|
+
}
|
|
740
|
+
if (!insertReplaceSupport && item.textEdit && vscode.InsertReplaceEdit.is(item.textEdit)) {
|
|
741
|
+
item.textEdit = vscode.TextEdit.replace(item.textEdit.insert, item.textEdit.newText);
|
|
742
|
+
wranCapabilitiesNotSupported('textDocument.completion.completionItem.insertReplaceSupport');
|
|
711
743
|
}
|
|
712
744
|
return item;
|
|
713
745
|
}
|
|
714
746
|
function handleDefinitions(initializeParams, type, items) {
|
|
715
747
|
const linkSupport = initializeParams.capabilities.textDocument?.[type]?.linkSupport ?? false;
|
|
716
748
|
if (!linkSupport) {
|
|
749
|
+
wranCapabilitiesNotSupported(`textDocument.${type}.linkSupport`);
|
|
717
750
|
return items.map(item => ({
|
|
718
751
|
uri: item.targetUri,
|
|
719
752
|
range: item.targetRange,
|
|
720
753
|
}));
|
|
721
754
|
}
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
755
|
+
return items;
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
function wranCapabilitiesNotSupported(path) {
|
|
759
|
+
if (reportedCapabilities.has(path)) {
|
|
760
|
+
return;
|
|
725
761
|
}
|
|
762
|
+
reportedCapabilities.add(path);
|
|
763
|
+
console.warn(`${path} is not supported by the client but could be used by the server.`);
|
|
726
764
|
}
|
|
727
765
|
function sleep(ms) {
|
|
728
766
|
return new Promise(resolve => setTimeout(resolve, ms));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-server",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"directory": "packages/language-server"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/language-core": "2.4.
|
|
16
|
-
"@volar/language-service": "2.4.
|
|
17
|
-
"@volar/typescript": "2.4.
|
|
15
|
+
"@volar/language-core": "2.4.3",
|
|
16
|
+
"@volar/language-service": "2.4.3",
|
|
17
|
+
"@volar/typescript": "2.4.3",
|
|
18
18
|
"path-browserify": "^1.0.1",
|
|
19
19
|
"request-light": "^0.7.0",
|
|
20
20
|
"vscode-languageserver": "^9.0.1",
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@types/path-browserify": "latest"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "74d897fa2e2b81aa2a71e7c95c869cd8415b50b7"
|
|
29
29
|
}
|