@volar/language-service 2.3.3 → 2.3.5-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/lib/features/provideDocumentFormattingEdits.js +1 -1
- package/lib/features/provideDocumentSymbols.js +9 -1
- package/lib/features/provideWorkspaceSymbols.d.ts +4 -0
- package/lib/features/provideWorkspaceSymbols.js +8 -0
- package/lib/features/resolveInlayHint copy.d.ts +3 -0
- package/lib/features/resolveInlayHint copy.js +19 -0
- package/lib/features/resolveWorkspaceSymbol.d.ts +3 -0
- package/lib/features/resolveWorkspaceSymbol.js +19 -0
- package/lib/languageService.d.ts +6 -0
- package/lib/languageService.js +15 -0
- package/lib/types.d.ts +10 -1
- package/lib/utils/dedupe.d.ts +1 -1
- package/package.json +3 -3
|
@@ -27,7 +27,7 @@ function register(context) {
|
|
|
27
27
|
continue;
|
|
28
28
|
}
|
|
29
29
|
results[i] = results[i].filter(child => {
|
|
30
|
-
for (const parent of results[j]) {
|
|
30
|
+
for (const parent of forEachSymbol(results[j])) {
|
|
31
31
|
if ((0, common_1.isInsideRange)(parent.range, child.range)) {
|
|
32
32
|
parent.children ??= [];
|
|
33
33
|
parent.children.push(child);
|
|
@@ -42,4 +42,12 @@ function register(context) {
|
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
+
function* forEachSymbol(symbols) {
|
|
46
|
+
for (const symbol of symbols) {
|
|
47
|
+
if (symbol.children) {
|
|
48
|
+
yield* forEachSymbol(symbol.children);
|
|
49
|
+
}
|
|
50
|
+
yield symbol;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
45
53
|
//# sourceMappingURL=provideDocumentSymbols.js.map
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServiceContext } from '../types';
|
|
3
|
+
export interface WorkspaceSymbolData {
|
|
4
|
+
original: Pick<vscode.WorkspaceSymbol, 'data'>;
|
|
5
|
+
pluginIndex: number;
|
|
6
|
+
}
|
|
3
7
|
export declare function register(context: LanguageServiceContext): (query: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol[]>;
|
|
@@ -43,6 +43,14 @@ function register(context) {
|
|
|
43
43
|
}
|
|
44
44
|
}))
|
|
45
45
|
.filter(symbol => !!symbol);
|
|
46
|
+
symbols?.forEach(symbol => {
|
|
47
|
+
symbol.data = {
|
|
48
|
+
original: {
|
|
49
|
+
data: symbol.data,
|
|
50
|
+
},
|
|
51
|
+
pluginIndex: context.plugins.indexOf(plugin),
|
|
52
|
+
};
|
|
53
|
+
});
|
|
46
54
|
symbolsList.push(symbols);
|
|
47
55
|
}
|
|
48
56
|
return symbolsList.flat();
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
+
import type { LanguageServiceContext } from '../types';
|
|
3
|
+
export declare function register(context: LanguageServiceContext): (item: vscode.InlayHint, token?: vscode.CancellationToken) => Promise<vscode.InlayHint>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.register = register;
|
|
4
|
+
const cancellation_1 = require("../utils/cancellation");
|
|
5
|
+
function register(context) {
|
|
6
|
+
return async (item, token = cancellation_1.NoneCancellationToken) => {
|
|
7
|
+
const data = item.data;
|
|
8
|
+
if (data) {
|
|
9
|
+
const plugin = context.plugins[data.pluginIndex];
|
|
10
|
+
if (!plugin[1].resolveInlayHint) {
|
|
11
|
+
return item;
|
|
12
|
+
}
|
|
13
|
+
Object.assign(item, data.original);
|
|
14
|
+
item = await plugin[1].resolveInlayHint(item, token);
|
|
15
|
+
}
|
|
16
|
+
return item;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=resolveInlayHint%20copy.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
+
import type { LanguageServiceContext } from '../types';
|
|
3
|
+
export declare function register(context: LanguageServiceContext): (symbol: vscode.WorkspaceSymbol, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.register = register;
|
|
4
|
+
const cancellation_1 = require("../utils/cancellation");
|
|
5
|
+
function register(context) {
|
|
6
|
+
return async (symbol, token = cancellation_1.NoneCancellationToken) => {
|
|
7
|
+
const data = symbol.data;
|
|
8
|
+
if (data) {
|
|
9
|
+
const plugin = context.plugins[data.pluginIndex];
|
|
10
|
+
if (!plugin[1].resolveWorkspaceSymbol) {
|
|
11
|
+
return symbol;
|
|
12
|
+
}
|
|
13
|
+
Object.assign(symbol, data.original);
|
|
14
|
+
symbol = await plugin[1].resolveWorkspaceSymbol(symbol, token);
|
|
15
|
+
}
|
|
16
|
+
return symbol;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=resolveWorkspaceSymbol.js.map
|
package/lib/languageService.d.ts
CHANGED
|
@@ -14,10 +14,12 @@ export declare function createLanguageService(language: Language<URI>, plugins:
|
|
|
14
14
|
tokenModifiers: string[];
|
|
15
15
|
tokenTypes: string[];
|
|
16
16
|
};
|
|
17
|
+
getCommands: () => string[];
|
|
17
18
|
getTriggerCharacters: () => string[];
|
|
18
19
|
getAutoFormatTriggerCharacters: () => string[];
|
|
19
20
|
getSignatureHelpTriggerCharacters: () => string[];
|
|
20
21
|
getSignatureHelpRetriggerCharacters: () => string[];
|
|
22
|
+
executeCommand(command: string, args: any[], token?: vscode.CancellationToken): any;
|
|
21
23
|
getDocumentFormattingEdits: (uri: URI, options: vscode.FormattingOptions, range: vscode.Range | undefined, onTypeParams: {
|
|
22
24
|
ch: string;
|
|
23
25
|
position: vscode.Position;
|
|
@@ -64,6 +66,7 @@ export declare function createLanguageService(language: Language<URI>, plugins:
|
|
|
64
66
|
resolveCodeLens: (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
|
|
65
67
|
resolveDocumentLink: (item: vscode.DocumentLink, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink>;
|
|
66
68
|
resolveInlayHint: (item: vscode.InlayHint, token?: vscode.CancellationToken) => Promise<vscode.InlayHint>;
|
|
69
|
+
resolveWorkspaceSymbol: (symbol: vscode.WorkspaceSymbol, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol>;
|
|
67
70
|
};
|
|
68
71
|
export declare function decodeEmbeddedDocumentUri(maybeEmbeddedContentUri: URI): [
|
|
69
72
|
documentUri: URI,
|
|
@@ -80,10 +83,12 @@ declare function createLanguageServiceBase(plugins: LanguageServicePlugin[], con
|
|
|
80
83
|
tokenModifiers: string[];
|
|
81
84
|
tokenTypes: string[];
|
|
82
85
|
};
|
|
86
|
+
getCommands: () => string[];
|
|
83
87
|
getTriggerCharacters: () => string[];
|
|
84
88
|
getAutoFormatTriggerCharacters: () => string[];
|
|
85
89
|
getSignatureHelpTriggerCharacters: () => string[];
|
|
86
90
|
getSignatureHelpRetriggerCharacters: () => string[];
|
|
91
|
+
executeCommand(command: string, args: any[], token?: vscode.CancellationToken): any;
|
|
87
92
|
getDocumentFormattingEdits: (uri: URI, options: vscode.FormattingOptions, range: vscode.Range | undefined, onTypeParams: {
|
|
88
93
|
ch: string;
|
|
89
94
|
position: vscode.Position;
|
|
@@ -130,5 +135,6 @@ declare function createLanguageServiceBase(plugins: LanguageServicePlugin[], con
|
|
|
130
135
|
resolveCodeLens: (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
|
|
131
136
|
resolveDocumentLink: (item: vscode.DocumentLink, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink>;
|
|
132
137
|
resolveInlayHint: (item: vscode.InlayHint, token?: vscode.CancellationToken) => Promise<vscode.InlayHint>;
|
|
138
|
+
resolveWorkspaceSymbol: (symbol: vscode.WorkspaceSymbol, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol>;
|
|
133
139
|
};
|
|
134
140
|
export {};
|
package/lib/languageService.js
CHANGED
|
@@ -40,6 +40,8 @@ const codeLensResolve = require("./features/resolveCodeLens");
|
|
|
40
40
|
const completionResolve = require("./features/resolveCompletionItem");
|
|
41
41
|
const documentLinkResolve = require("./features/resolveDocumentLink");
|
|
42
42
|
const inlayHintResolve = require("./features/resolveInlayHint");
|
|
43
|
+
const workspaceSymbolResolve = require("./features/resolveWorkspaceSymbol");
|
|
44
|
+
const cancellation_1 = require("./utils/cancellation");
|
|
43
45
|
const uriMap_1 = require("./utils/uriMap");
|
|
44
46
|
exports.embeddedContentScheme = 'volar-embedded-content';
|
|
45
47
|
function createLanguageService(language, plugins, env) {
|
|
@@ -168,10 +170,22 @@ function createLanguageServiceBase(plugins, context) {
|
|
|
168
170
|
tokenTypes: [...new Set(tokenTypes)],
|
|
169
171
|
};
|
|
170
172
|
},
|
|
173
|
+
getCommands: () => plugins.map(plugin => plugin.capabilities.executeCommandProvider?.commands ?? []).flat(),
|
|
171
174
|
getTriggerCharacters: () => plugins.map(plugin => plugin.capabilities.completionProvider?.triggerCharacters ?? []).flat(),
|
|
172
175
|
getAutoFormatTriggerCharacters: () => plugins.map(plugin => plugin.capabilities.documentOnTypeFormattingProvider?.triggerCharacters ?? []).flat(),
|
|
173
176
|
getSignatureHelpTriggerCharacters: () => plugins.map(plugin => plugin.capabilities.signatureHelpProvider?.triggerCharacters ?? []).flat(),
|
|
174
177
|
getSignatureHelpRetriggerCharacters: () => plugins.map(plugin => plugin.capabilities.signatureHelpProvider?.retriggerCharacters ?? []).flat(),
|
|
178
|
+
executeCommand(command, args, token = cancellation_1.NoneCancellationToken) {
|
|
179
|
+
for (const plugin of context.plugins) {
|
|
180
|
+
if (context.disabledServicePlugins.has(plugin[1])) {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
if (!plugin[1].executeCommand || !plugin[0].capabilities.executeCommandProvider?.commands.includes(command)) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
return plugin[1].executeCommand(command, args, token);
|
|
187
|
+
}
|
|
188
|
+
},
|
|
175
189
|
getDocumentFormattingEdits: format.register(context),
|
|
176
190
|
getFoldingRanges: foldingRanges.register(context),
|
|
177
191
|
getSelectionRanges: selectionRanges.register(context),
|
|
@@ -206,6 +220,7 @@ function createLanguageServiceBase(plugins, context) {
|
|
|
206
220
|
resolveCodeLens: codeLensResolve.register(context),
|
|
207
221
|
resolveDocumentLink: documentLinkResolve.register(context),
|
|
208
222
|
resolveInlayHint: inlayHintResolve.register(context),
|
|
223
|
+
resolveWorkspaceSymbol: workspaceSymbolResolve.register(context),
|
|
209
224
|
...callHierarchy.register(context),
|
|
210
225
|
dispose: () => context.plugins.forEach(plugin => plugin[1].dispose?.()),
|
|
211
226
|
context,
|
package/lib/types.d.ts
CHANGED
|
@@ -71,6 +71,9 @@ export type SemanticToken = [
|
|
|
71
71
|
export interface LanguageServicePlugin<P = any> {
|
|
72
72
|
name?: string;
|
|
73
73
|
capabilities: {
|
|
74
|
+
executeCommandProvider?: {
|
|
75
|
+
commands: string[];
|
|
76
|
+
};
|
|
74
77
|
selectionRangeProvider?: boolean;
|
|
75
78
|
foldingRangeProvider?: boolean;
|
|
76
79
|
linkedEditingRangeProvider?: boolean;
|
|
@@ -84,7 +87,9 @@ export interface LanguageServicePlugin<P = any> {
|
|
|
84
87
|
callHierarchyProvider?: boolean;
|
|
85
88
|
hoverProvider?: boolean;
|
|
86
89
|
documentHighlightProvider?: boolean;
|
|
87
|
-
workspaceSymbolProvider?:
|
|
90
|
+
workspaceSymbolProvider?: {
|
|
91
|
+
resolveProvider?: boolean;
|
|
92
|
+
};
|
|
88
93
|
renameProvider?: {
|
|
89
94
|
prepareProvider?: boolean;
|
|
90
95
|
};
|
|
@@ -122,6 +127,8 @@ export interface LanguageServicePlugin<P = any> {
|
|
|
122
127
|
diagnosticProvider?: {
|
|
123
128
|
workspaceDiagnostics?: boolean;
|
|
124
129
|
};
|
|
130
|
+
fileReferencesProvider?: boolean;
|
|
131
|
+
fileRenameProvider?: boolean;
|
|
125
132
|
};
|
|
126
133
|
create(context: LanguageServiceContext): LanguageServicePluginInstance<P>;
|
|
127
134
|
}
|
|
@@ -132,6 +139,7 @@ export interface EmbeddedCodeFormattingOptions {
|
|
|
132
139
|
export interface LanguageServicePluginInstance<P = any> {
|
|
133
140
|
provide?: P;
|
|
134
141
|
isAdditionalCompletion?: boolean;
|
|
142
|
+
executeCommand?(command: string, args: any[], token: vscode.CancellationToken): ProviderResult<any>;
|
|
135
143
|
provideHover?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableProviderResult<vscode.Hover>;
|
|
136
144
|
provideDocumentSymbols?(document: TextDocument, token: vscode.CancellationToken): NullableProviderResult<vscode.DocumentSymbol[]>;
|
|
137
145
|
provideDocumentHighlights?(document: TextDocument, position: vscode.Position, token: vscode.CancellationToken): NullableProviderResult<vscode.DocumentHighlight[]>;
|
|
@@ -181,6 +189,7 @@ export interface LanguageServicePluginInstance<P = any> {
|
|
|
181
189
|
resolveCompletionItem?(item: vscode.CompletionItem, token: vscode.CancellationToken): ProviderResult<vscode.CompletionItem>;
|
|
182
190
|
resolveDocumentLink?(link: vscode.DocumentLink, token: vscode.CancellationToken): ProviderResult<vscode.DocumentLink>;
|
|
183
191
|
resolveInlayHint?(inlayHint: vscode.InlayHint, token: vscode.CancellationToken): ProviderResult<vscode.InlayHint>;
|
|
192
|
+
resolveWorkspaceSymbol?(symbol: vscode.WorkspaceSymbol, token: vscode.CancellationToken): ProviderResult<vscode.WorkspaceSymbol>;
|
|
184
193
|
resolveEmbeddedCodeFormattingOptions?(sourceScript: SourceScript<URI>, embeddedCode: VirtualCode, options: EmbeddedCodeFormattingOptions, token: vscode.CancellationToken): NullableProviderResult<EmbeddedCodeFormattingOptions>;
|
|
185
194
|
transformCompletionItem?(item: vscode.CompletionItem): vscode.CompletionItem | undefined;
|
|
186
195
|
transformCodeAction?(item: vscode.CodeAction): vscode.CodeAction | undefined;
|
package/lib/utils/dedupe.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare function createLocationSet(): {
|
|
|
5
5
|
};
|
|
6
6
|
export declare function withCodeAction<T extends vscode.CodeAction>(items: T[]): T[];
|
|
7
7
|
export declare function withTextEdits<T extends vscode.TextEdit>(items: T[]): T[];
|
|
8
|
-
export declare function withDocumentChanges(items: NonNullable<vscode.WorkspaceEdit['documentChanges']>): (vscode.
|
|
8
|
+
export declare function withDocumentChanges(items: NonNullable<vscode.WorkspaceEdit['documentChanges']>): (vscode.TextDocumentEdit | vscode.CreateFile | vscode.RenameFile | vscode.DeleteFile)[];
|
|
9
9
|
export declare function withDiagnostics<T extends vscode.Diagnostic>(items: T[]): T[];
|
|
10
10
|
export declare function withLocations<T extends vscode.Location>(items: T[]): T[];
|
|
11
11
|
export declare function withLocationLinks<T extends vscode.LocationLink>(items: T[]): T[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.5-alpha.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"directory": "packages/language-service"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@volar/language-core": "2.3.
|
|
15
|
+
"@volar/language-core": "2.3.5-alpha.1",
|
|
16
16
|
"vscode-languageserver-protocol": "^3.17.5",
|
|
17
17
|
"vscode-languageserver-textdocument": "^1.0.11",
|
|
18
18
|
"vscode-uri": "^3.0.8"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "111bfae316c66a087a497e12740d46fc2c74cab0"
|
|
21
21
|
}
|