@volar/language-service 2.3.0-alpha.9 → 2.3.0
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/provideCallHierarchyItems.d.ts +3 -3
- package/lib/features/provideCallHierarchyItems.js +3 -3
- package/lib/features/provideDiagnostics.d.ts +3 -0
- package/lib/features/provideDiagnostics.js +39 -40
- package/lib/features/provideWorkspaceDiagnostics.d.ts +3 -0
- package/lib/features/provideWorkspaceDiagnostics.js +66 -0
- package/lib/languageService.d.ts +94 -33
- package/lib/languageService.js +48 -34
- package/lib/types.d.ts +7 -2
- package/package.json +3 -3
|
@@ -8,7 +8,7 @@ export interface PluginCallHierarchyData {
|
|
|
8
8
|
embeddedDocumentUri: string | undefined;
|
|
9
9
|
}
|
|
10
10
|
export declare function register(context: LanguageServiceContext): {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
getCallHierarchyItems(uri: URI, position: vscode.Position, token?: vscode.CancellationToken): Promise<vscode.CallHierarchyItem[] | undefined>;
|
|
12
|
+
getCallHierarchyIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[]>;
|
|
13
|
+
getCallHierarchyOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[]>;
|
|
14
14
|
};
|
|
@@ -9,7 +9,7 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
9
9
|
const vscode_uri_1 = require("vscode-uri");
|
|
10
10
|
function register(context) {
|
|
11
11
|
return {
|
|
12
|
-
|
|
12
|
+
getCallHierarchyItems(uri, position, token = cancellation_1.NoneCancellationToken) {
|
|
13
13
|
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, map => map.getGeneratedPositions(position, data => (0, language_core_1.isCallHierarchyEnabled)(data)), async (plugin, document, position, map) => {
|
|
14
14
|
if (token.isCancellationRequested) {
|
|
15
15
|
return;
|
|
@@ -35,7 +35,7 @@ function register(context) {
|
|
|
35
35
|
.filter(common_1.notEmpty);
|
|
36
36
|
}, arr => dedupe.withLocations(arr.flat()));
|
|
37
37
|
},
|
|
38
|
-
async
|
|
38
|
+
async getCallHierarchyIncomingCalls(item, token) {
|
|
39
39
|
const data = item.data;
|
|
40
40
|
let incomingItems = [];
|
|
41
41
|
if (data) {
|
|
@@ -76,7 +76,7 @@ function register(context) {
|
|
|
76
76
|
}
|
|
77
77
|
return dedupe.withCallHierarchyIncomingCalls(incomingItems);
|
|
78
78
|
},
|
|
79
|
-
async
|
|
79
|
+
async getCallHierarchyOutgoingCalls(item, token) {
|
|
80
80
|
const data = item.data;
|
|
81
81
|
let items = [];
|
|
82
82
|
if (data) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { type CodeInformation } from '@volar/language-core';
|
|
1
2
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
3
|
import { URI } from 'vscode-uri';
|
|
4
|
+
import type { SourceMapWithDocuments } from '../documents';
|
|
3
5
|
import type { LanguageServiceContext } from '../types';
|
|
4
6
|
export declare function updateRange(range: vscode.Range, change: {
|
|
5
7
|
range: vscode.Range;
|
|
@@ -18,3 +20,4 @@ export declare const errorMarkups: Map<URI, {
|
|
|
18
20
|
markup: vscode.MarkupContent;
|
|
19
21
|
}[]>;
|
|
20
22
|
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken, response?: (result: vscode.Diagnostic[]) => void) => Promise<vscode.Diagnostic[]>;
|
|
23
|
+
export declare function transformDiagnostic(context: LanguageServiceContext, error: vscode.Diagnostic, map: SourceMapWithDocuments | undefined, filter: (data: CodeInformation) => boolean): vscode.Diagnostic | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.register = exports.errorMarkups = exports.updateRange = void 0;
|
|
3
|
+
exports.transformDiagnostic = exports.register = exports.errorMarkups = exports.updateRange = void 0;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
5
|
const vscode_uri_1 = require("vscode-uri");
|
|
6
6
|
const cancellation_1 = require("../utils/cancellation");
|
|
@@ -177,7 +177,9 @@ function register(context) {
|
|
|
177
177
|
});
|
|
178
178
|
return errors;
|
|
179
179
|
}, (errors, map) => {
|
|
180
|
-
return
|
|
180
|
+
return errors
|
|
181
|
+
.map(error => transformDiagnostic(context, error, map, language_core_1.shouldReportDiagnostics))
|
|
182
|
+
.filter(common_1.notEmpty);
|
|
181
183
|
}, arr => dedupe.withDiagnostics(arr.flat()));
|
|
182
184
|
if (result) {
|
|
183
185
|
cache.errors = result;
|
|
@@ -185,48 +187,45 @@ function register(context) {
|
|
|
185
187
|
}
|
|
186
188
|
}
|
|
187
189
|
};
|
|
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
|
-
else {
|
|
221
|
-
relatedInfos.push(info);
|
|
190
|
+
}
|
|
191
|
+
exports.register = register;
|
|
192
|
+
function transformDiagnostic(context, error, map, filter) {
|
|
193
|
+
// clone it to avoid modify cache
|
|
194
|
+
let _error = { ...error };
|
|
195
|
+
if (map) {
|
|
196
|
+
const range = map.getSourceRange(error.range, filter);
|
|
197
|
+
if (!range) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
_error.range = range;
|
|
201
|
+
}
|
|
202
|
+
if (_error.relatedInformation) {
|
|
203
|
+
const relatedInfos = [];
|
|
204
|
+
for (const info of _error.relatedInformation) {
|
|
205
|
+
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(info.location.uri));
|
|
206
|
+
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
207
|
+
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
208
|
+
if (virtualCode) {
|
|
209
|
+
for (const map of context.documents.getMaps(virtualCode)) {
|
|
210
|
+
const range = map.getSourceRange(info.location.range, filter);
|
|
211
|
+
if (range) {
|
|
212
|
+
relatedInfos.push({
|
|
213
|
+
location: {
|
|
214
|
+
uri: map.sourceDocument.uri,
|
|
215
|
+
range,
|
|
216
|
+
},
|
|
217
|
+
message: info.message,
|
|
218
|
+
});
|
|
222
219
|
}
|
|
223
220
|
}
|
|
224
|
-
_error.relatedInformation = relatedInfos;
|
|
225
221
|
}
|
|
226
|
-
|
|
222
|
+
else {
|
|
223
|
+
relatedInfos.push(info);
|
|
224
|
+
}
|
|
227
225
|
}
|
|
228
|
-
|
|
226
|
+
_error.relatedInformation = relatedInfos;
|
|
229
227
|
}
|
|
228
|
+
return _error;
|
|
230
229
|
}
|
|
231
|
-
exports.
|
|
230
|
+
exports.transformDiagnostic = transformDiagnostic;
|
|
232
231
|
//# sourceMappingURL=provideDiagnostics.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): (token?: vscode.CancellationToken) => Promise<vscode.WorkspaceDocumentDiagnosticReport[]>;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.register = void 0;
|
|
4
|
+
const common_1 = require("../utils/common");
|
|
5
|
+
const cancellation_1 = require("../utils/cancellation");
|
|
6
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
7
|
+
const provideDiagnostics_1 = require("./provideDiagnostics");
|
|
8
|
+
const language_core_1 = require("@volar/language-core");
|
|
9
|
+
function register(context) {
|
|
10
|
+
return async (token = cancellation_1.NoneCancellationToken) => {
|
|
11
|
+
const allItems = [];
|
|
12
|
+
for (const plugin of context.plugins) {
|
|
13
|
+
if (context.disabledServicePlugins.has(plugin[1])) {
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
if (token.isCancellationRequested) {
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
if (!plugin[1].provideWorkspaceDiagnostics) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const report = await plugin[1].provideWorkspaceDiagnostics(token);
|
|
23
|
+
if (!report) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
const items = report
|
|
27
|
+
.map(item => {
|
|
28
|
+
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(item.uri));
|
|
29
|
+
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
30
|
+
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
31
|
+
if (virtualCode && sourceScript) {
|
|
32
|
+
if (item.kind === 'unchanged') {
|
|
33
|
+
return {
|
|
34
|
+
...item,
|
|
35
|
+
uri: sourceScript.id.toString(),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
const map = context.documents.getMap(virtualCode, sourceScript);
|
|
40
|
+
return {
|
|
41
|
+
...item,
|
|
42
|
+
items: item.items
|
|
43
|
+
.map(error => (0, provideDiagnostics_1.transformDiagnostic)(context, error, map, language_core_1.shouldReportDiagnostics))
|
|
44
|
+
.filter(common_1.notEmpty)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
if (item.kind === 'unchanged') {
|
|
50
|
+
return item;
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
...item,
|
|
54
|
+
items: item.items
|
|
55
|
+
.map(error => (0, provideDiagnostics_1.transformDiagnostic)(context, error, undefined, language_core_1.shouldReportDiagnostics))
|
|
56
|
+
.filter(common_1.notEmpty)
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
allItems.push(...items);
|
|
61
|
+
}
|
|
62
|
+
return allItems;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
exports.register = register;
|
|
66
|
+
//# sourceMappingURL=provideWorkspaceDiagnostics.js.map
|
package/lib/languageService.d.ts
CHANGED
|
@@ -2,8 +2,13 @@ import { type Language } from '@volar/language-core';
|
|
|
2
2
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
3
3
|
import { URI } from 'vscode-uri';
|
|
4
4
|
import type { LanguageServicePlugin, LanguageServiceContext, LanguageServiceEnvironment } from './types';
|
|
5
|
-
export type LanguageService = ReturnType<typeof
|
|
5
|
+
export type LanguageService = ReturnType<typeof createLanguageServiceBase>;
|
|
6
6
|
export declare function createLanguageService(language: Language<URI>, plugins: LanguageServicePlugin[], env: LanguageServiceEnvironment): {
|
|
7
|
+
dispose: () => void;
|
|
8
|
+
context: LanguageServiceContext;
|
|
9
|
+
getCallHierarchyItems(uri: URI, position: vscode.Position, token?: vscode.CancellationToken): Promise<vscode.CallHierarchyItem[] | undefined>;
|
|
10
|
+
getCallHierarchyIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[]>;
|
|
11
|
+
getCallHierarchyOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[]>;
|
|
7
12
|
getSemanticTokenLegend: () => {
|
|
8
13
|
tokenModifiers: string[];
|
|
9
14
|
tokenTypes: string[];
|
|
@@ -12,56 +17,112 @@ export declare function createLanguageService(language: Language<URI>, plugins:
|
|
|
12
17
|
getAutoFormatTriggerCharacters: () => string[];
|
|
13
18
|
getSignatureHelpTriggerCharacters: () => string[];
|
|
14
19
|
getSignatureHelpRetriggerCharacters: () => string[];
|
|
15
|
-
|
|
20
|
+
getDocumentFormattingEdits: (uri: URI, options: vscode.FormattingOptions, range: vscode.Range | undefined, onTypeParams: {
|
|
16
21
|
ch: string;
|
|
17
22
|
position: vscode.Position;
|
|
18
23
|
} | undefined, token?: vscode.CancellationToken) => Promise<vscode.TextEdit[] | undefined>;
|
|
19
24
|
getFoldingRanges: (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.FoldingRange[] | undefined>;
|
|
20
25
|
getSelectionRanges: (uri: URI, positions: vscode.Position[], token?: vscode.CancellationToken) => Promise<vscode.SelectionRange[] | undefined>;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
getLinkedEditingRanges: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LinkedEditingRanges | undefined>;
|
|
27
|
+
getDocumentSymbols: (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.DocumentSymbol[] | undefined>;
|
|
28
|
+
getDocumentColors: (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.ColorInformation[] | undefined>;
|
|
24
29
|
getColorPresentations: (uri: URI, color: vscode.Color, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.ColorPresentation[] | undefined>;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
getDiagnostics: (uri: URI, token?: vscode.CancellationToken, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
31
|
+
getWorkspaceDiagnostics: (token?: vscode.CancellationToken) => Promise<vscode.WorkspaceDocumentDiagnosticReport[]>;
|
|
32
|
+
getReferences: (uri: URI, position: vscode.Position, referenceContext: vscode.ReferenceContext, token?: vscode.CancellationToken) => Promise<vscode.Location[] | undefined>;
|
|
33
|
+
getFileReferences: (uri: URI, token?: vscode.CancellationToken) => import("./types").NullableProviderResult<vscode.Location[]>;
|
|
34
|
+
getDefinition: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
|
|
35
|
+
getTypeDefinition: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
|
|
36
|
+
getImplementations: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
|
|
37
|
+
getRenameRange: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Range | {
|
|
32
38
|
range: vscode.Range;
|
|
33
39
|
placeholder: string;
|
|
34
40
|
} | {
|
|
35
41
|
message: string;
|
|
36
42
|
} | undefined>;
|
|
37
|
-
|
|
38
|
-
|
|
43
|
+
getRenameEdits: (uri: URI, position: vscode.Position, newName: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
44
|
+
getFileRenameEdits: (oldUri: URI, newUri: URI, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
39
45
|
getSemanticTokens: (uri: URI, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, token?: vscode.CancellationToken, _reportProgress?: ((tokens: vscode.SemanticTokens) => void) | undefined) => Promise<vscode.SemanticTokens | undefined>;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
doCodeActionResolve: (item: vscode.CodeAction, token?: vscode.CancellationToken) => Promise<vscode.CodeAction>;
|
|
44
|
-
doCompletionResolve: (item: vscode.CompletionItem, token?: vscode.CancellationToken) => Promise<vscode.CompletionItem>;
|
|
46
|
+
getHover: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Hover | undefined>;
|
|
47
|
+
getCompletionItems: (uri: URI, position: vscode.Position, completionContext?: vscode.CompletionContext, token?: vscode.CancellationToken) => Promise<vscode.CompletionList>;
|
|
48
|
+
getCodeActions: (uri: URI, range: vscode.Range, codeActionContext: vscode.CodeActionContext, token?: vscode.CancellationToken) => Promise<vscode.CodeAction[] | undefined>;
|
|
45
49
|
getSignatureHelp: (uri: URI, position: vscode.Position, signatureHelpContext?: vscode.SignatureHelpContext, token?: vscode.CancellationToken) => Promise<vscode.SignatureHelp | undefined>;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
findWorkspaceSymbols: (query: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol[]>;
|
|
52
|
-
doAutoInsert: (uri: URI, selection: vscode.Position, change: {
|
|
50
|
+
getCodeLenses: (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.CodeLens[]>;
|
|
51
|
+
getDocumentHighlights: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.DocumentHighlight[] | undefined>;
|
|
52
|
+
getDocumentLinks: (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
|
|
53
|
+
getWorkspaceSymbols: (query: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol[]>;
|
|
54
|
+
getAutoInsertSnippet: (uri: URI, selection: vscode.Position, change: {
|
|
53
55
|
rangeOffset: number;
|
|
54
56
|
rangeLength: number;
|
|
55
57
|
text: string;
|
|
56
58
|
}, token?: vscode.CancellationToken) => Promise<string | undefined>;
|
|
57
|
-
|
|
59
|
+
getDocumentDropEdits: (uri: URI, position: vscode.Position, dataTransfer: Map<string, import("./types").DataTransferItem>, token?: vscode.CancellationToken) => Promise<import("./types").DocumentDropEdit | undefined>;
|
|
58
60
|
getInlayHints: (uri: URI, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined>;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
resolveCodeAction: (item: vscode.CodeAction, token?: vscode.CancellationToken) => Promise<vscode.CodeAction>;
|
|
62
|
+
resolveCompletionItem: (item: vscode.CompletionItem, token?: vscode.CancellationToken) => Promise<vscode.CompletionItem>;
|
|
63
|
+
resolveCodeLens: (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
|
|
64
|
+
resolveDocumentLink: (item: vscode.DocumentLink, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink>;
|
|
65
|
+
resolveInlayHint: (item: vscode.InlayHint, token?: vscode.CancellationToken) => Promise<vscode.InlayHint>;
|
|
66
|
+
};
|
|
67
|
+
declare function createLanguageServiceBase(plugins: LanguageServicePlugin[], context: LanguageServiceContext): {
|
|
65
68
|
dispose: () => void;
|
|
66
69
|
context: LanguageServiceContext;
|
|
70
|
+
getCallHierarchyItems(uri: URI, position: vscode.Position, token?: vscode.CancellationToken): Promise<vscode.CallHierarchyItem[] | undefined>;
|
|
71
|
+
getCallHierarchyIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[]>;
|
|
72
|
+
getCallHierarchyOutgoingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyOutgoingCall[]>;
|
|
73
|
+
getSemanticTokenLegend: () => {
|
|
74
|
+
tokenModifiers: string[];
|
|
75
|
+
tokenTypes: string[];
|
|
76
|
+
};
|
|
77
|
+
getTriggerCharacters: () => string[];
|
|
78
|
+
getAutoFormatTriggerCharacters: () => string[];
|
|
79
|
+
getSignatureHelpTriggerCharacters: () => string[];
|
|
80
|
+
getSignatureHelpRetriggerCharacters: () => string[];
|
|
81
|
+
getDocumentFormattingEdits: (uri: URI, options: vscode.FormattingOptions, range: vscode.Range | undefined, onTypeParams: {
|
|
82
|
+
ch: string;
|
|
83
|
+
position: vscode.Position;
|
|
84
|
+
} | undefined, token?: vscode.CancellationToken) => Promise<vscode.TextEdit[] | undefined>;
|
|
85
|
+
getFoldingRanges: (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.FoldingRange[] | undefined>;
|
|
86
|
+
getSelectionRanges: (uri: URI, positions: vscode.Position[], token?: vscode.CancellationToken) => Promise<vscode.SelectionRange[] | undefined>;
|
|
87
|
+
getLinkedEditingRanges: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LinkedEditingRanges | undefined>;
|
|
88
|
+
getDocumentSymbols: (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.DocumentSymbol[] | undefined>;
|
|
89
|
+
getDocumentColors: (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.ColorInformation[] | undefined>;
|
|
90
|
+
getColorPresentations: (uri: URI, color: vscode.Color, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.ColorPresentation[] | undefined>;
|
|
91
|
+
getDiagnostics: (uri: URI, token?: vscode.CancellationToken, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
92
|
+
getWorkspaceDiagnostics: (token?: vscode.CancellationToken) => Promise<vscode.WorkspaceDocumentDiagnosticReport[]>;
|
|
93
|
+
getReferences: (uri: URI, position: vscode.Position, referenceContext: vscode.ReferenceContext, token?: vscode.CancellationToken) => Promise<vscode.Location[] | undefined>;
|
|
94
|
+
getFileReferences: (uri: URI, token?: vscode.CancellationToken) => import("./types").NullableProviderResult<vscode.Location[]>;
|
|
95
|
+
getDefinition: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
|
|
96
|
+
getTypeDefinition: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
|
|
97
|
+
getImplementations: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
|
|
98
|
+
getRenameRange: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Range | {
|
|
99
|
+
range: vscode.Range;
|
|
100
|
+
placeholder: string;
|
|
101
|
+
} | {
|
|
102
|
+
message: string;
|
|
103
|
+
} | undefined>;
|
|
104
|
+
getRenameEdits: (uri: URI, position: vscode.Position, newName: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
105
|
+
getFileRenameEdits: (oldUri: URI, newUri: URI, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
106
|
+
getSemanticTokens: (uri: URI, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, token?: vscode.CancellationToken, _reportProgress?: ((tokens: vscode.SemanticTokens) => void) | undefined) => Promise<vscode.SemanticTokens | undefined>;
|
|
107
|
+
getHover: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Hover | undefined>;
|
|
108
|
+
getCompletionItems: (uri: URI, position: vscode.Position, completionContext?: vscode.CompletionContext, token?: vscode.CancellationToken) => Promise<vscode.CompletionList>;
|
|
109
|
+
getCodeActions: (uri: URI, range: vscode.Range, codeActionContext: vscode.CodeActionContext, token?: vscode.CancellationToken) => Promise<vscode.CodeAction[] | undefined>;
|
|
110
|
+
getSignatureHelp: (uri: URI, position: vscode.Position, signatureHelpContext?: vscode.SignatureHelpContext, token?: vscode.CancellationToken) => Promise<vscode.SignatureHelp | undefined>;
|
|
111
|
+
getCodeLenses: (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.CodeLens[]>;
|
|
112
|
+
getDocumentHighlights: (uri: URI, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.DocumentHighlight[] | undefined>;
|
|
113
|
+
getDocumentLinks: (uri: URI, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
|
|
114
|
+
getWorkspaceSymbols: (query: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol[]>;
|
|
115
|
+
getAutoInsertSnippet: (uri: URI, selection: vscode.Position, change: {
|
|
116
|
+
rangeOffset: number;
|
|
117
|
+
rangeLength: number;
|
|
118
|
+
text: string;
|
|
119
|
+
}, token?: vscode.CancellationToken) => Promise<string | undefined>;
|
|
120
|
+
getDocumentDropEdits: (uri: URI, position: vscode.Position, dataTransfer: Map<string, import("./types").DataTransferItem>, token?: vscode.CancellationToken) => Promise<import("./types").DocumentDropEdit | undefined>;
|
|
121
|
+
getInlayHints: (uri: URI, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined>;
|
|
122
|
+
resolveCodeAction: (item: vscode.CodeAction, token?: vscode.CancellationToken) => Promise<vscode.CodeAction>;
|
|
123
|
+
resolveCompletionItem: (item: vscode.CompletionItem, token?: vscode.CancellationToken) => Promise<vscode.CompletionItem>;
|
|
124
|
+
resolveCodeLens: (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
|
|
125
|
+
resolveDocumentLink: (item: vscode.DocumentLink, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink>;
|
|
126
|
+
resolveInlayHint: (item: vscode.InlayHint, token?: vscode.CancellationToken) => Promise<vscode.InlayHint>;
|
|
67
127
|
};
|
|
128
|
+
export {};
|
package/lib/languageService.js
CHANGED
|
@@ -13,6 +13,7 @@ const colorPresentations = require("./features/provideColorPresentations");
|
|
|
13
13
|
const completions = require("./features/provideCompletionItems");
|
|
14
14
|
const definition = require("./features/provideDefinition");
|
|
15
15
|
const diagnostics = require("./features/provideDiagnostics");
|
|
16
|
+
const workspaceDiagnostics = require("./features/provideWorkspaceDiagnostics");
|
|
16
17
|
const documentColors = require("./features/provideDocumentColors");
|
|
17
18
|
const documentDrop = require("./features/provideDocumentDropEdits");
|
|
18
19
|
const format = require("./features/provideDocumentFormattingEdits");
|
|
@@ -46,6 +47,7 @@ function createLanguageService(language, plugins, env) {
|
|
|
46
47
|
const embeddedContentScheme = 'volar-embedded-content';
|
|
47
48
|
const context = {
|
|
48
49
|
language,
|
|
50
|
+
getLanguageService: () => langaugeService,
|
|
49
51
|
documents: {
|
|
50
52
|
get(uri, languageId, snapshot) {
|
|
51
53
|
if (!snapshot2Doc.has(snapshot)) {
|
|
@@ -59,6 +61,14 @@ function createLanguageService(language, plugins, env) {
|
|
|
59
61
|
}
|
|
60
62
|
return map.get(uri);
|
|
61
63
|
},
|
|
64
|
+
getMap(virtualCode, sourceScript) {
|
|
65
|
+
const map = context.language.maps.get(virtualCode, sourceScript);
|
|
66
|
+
if (!map2DocMap.has(map)) {
|
|
67
|
+
const embeddedUri = context.encodeEmbeddedDocumentUri(sourceScript.id, virtualCode.id);
|
|
68
|
+
map2DocMap.set(map, new documents_1.SourceMapWithDocuments(this.get(sourceScript.id, sourceScript.languageId, sourceScript.snapshot), this.get(embeddedUri, virtualCode.languageId, virtualCode.snapshot), map, virtualCode));
|
|
69
|
+
}
|
|
70
|
+
return map2DocMap.get(map);
|
|
71
|
+
},
|
|
62
72
|
*getMaps(virtualCode) {
|
|
63
73
|
for (const [uri, snapshot, map] of context.language.maps.forEach(virtualCode)) {
|
|
64
74
|
if (!map2DocMap.has(map)) {
|
|
@@ -164,7 +174,15 @@ function createLanguageService(language, plugins, env) {
|
|
|
164
174
|
});
|
|
165
175
|
},
|
|
166
176
|
};
|
|
167
|
-
const
|
|
177
|
+
for (const plugin of plugins) {
|
|
178
|
+
context.plugins.push([plugin, plugin.create(context)]);
|
|
179
|
+
}
|
|
180
|
+
const langaugeService = createLanguageServiceBase(plugins, context);
|
|
181
|
+
return langaugeService;
|
|
182
|
+
}
|
|
183
|
+
exports.createLanguageService = createLanguageService;
|
|
184
|
+
function createLanguageServiceBase(plugins, context) {
|
|
185
|
+
return {
|
|
168
186
|
getSemanticTokenLegend: () => {
|
|
169
187
|
const tokenModifiers = plugins.map(plugin => plugin.capabilities.semanticTokensProvider?.legend?.tokenModifiers ?? []).flat();
|
|
170
188
|
const tokenTypes = plugins.map(plugin => plugin.capabilities.semanticTokensProvider?.legend?.tokenTypes ?? []).flat();
|
|
@@ -177,47 +195,43 @@ function createLanguageService(language, plugins, env) {
|
|
|
177
195
|
getAutoFormatTriggerCharacters: () => plugins.map(plugin => plugin.capabilities.documentOnTypeFormattingProvider?.triggerCharacters ?? []).flat(),
|
|
178
196
|
getSignatureHelpTriggerCharacters: () => plugins.map(plugin => plugin.capabilities.signatureHelpProvider?.triggerCharacters ?? []).flat(),
|
|
179
197
|
getSignatureHelpRetriggerCharacters: () => plugins.map(plugin => plugin.capabilities.signatureHelpProvider?.retriggerCharacters ?? []).flat(),
|
|
180
|
-
|
|
198
|
+
getDocumentFormattingEdits: format.register(context),
|
|
181
199
|
getFoldingRanges: foldingRanges.register(context),
|
|
182
200
|
getSelectionRanges: selectionRanges.register(context),
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
201
|
+
getLinkedEditingRanges: linkedEditing.register(context),
|
|
202
|
+
getDocumentSymbols: documentSymbols.register(context),
|
|
203
|
+
getDocumentColors: documentColors.register(context),
|
|
186
204
|
getColorPresentations: colorPresentations.register(context),
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
205
|
+
getDiagnostics: diagnostics.register(context),
|
|
206
|
+
getWorkspaceDiagnostics: workspaceDiagnostics.register(context),
|
|
207
|
+
getReferences: references.register(context),
|
|
208
|
+
getFileReferences: fileReferences.register(context),
|
|
209
|
+
getDefinition: definition.register(context, 'provideDefinition', language_core_1.isDefinitionEnabled),
|
|
210
|
+
getTypeDefinition: definition.register(context, 'provideTypeDefinition', language_core_1.isTypeDefinitionEnabled),
|
|
211
|
+
getImplementations: definition.register(context, 'provideImplementation', language_core_1.isImplementationEnabled),
|
|
212
|
+
getRenameRange: renamePrepare.register(context),
|
|
213
|
+
getRenameEdits: rename.register(context),
|
|
214
|
+
getFileRenameEdits: fileRename.register(context),
|
|
196
215
|
getSemanticTokens: semanticTokens.register(context),
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
doCodeActionResolve: codeActionResolve.register(context),
|
|
201
|
-
doCompletionResolve: completionResolve.register(context),
|
|
216
|
+
getHover: hover.register(context),
|
|
217
|
+
getCompletionItems: completions.register(context),
|
|
218
|
+
getCodeActions: codeActions.register(context),
|
|
202
219
|
getSignatureHelp: signatureHelp.register(context),
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
doAutoInsert: autoInsert.register(context),
|
|
210
|
-
doDocumentDrop: documentDrop.register(context),
|
|
220
|
+
getCodeLenses: codeLens.register(context),
|
|
221
|
+
getDocumentHighlights: documentHighlight.register(context),
|
|
222
|
+
getDocumentLinks: documentLink.register(context),
|
|
223
|
+
getWorkspaceSymbols: workspaceSymbol.register(context),
|
|
224
|
+
getAutoInsertSnippet: autoInsert.register(context),
|
|
225
|
+
getDocumentDropEdits: documentDrop.register(context),
|
|
211
226
|
getInlayHints: inlayHints.register(context),
|
|
212
|
-
|
|
213
|
-
|
|
227
|
+
resolveCodeAction: codeActionResolve.register(context),
|
|
228
|
+
resolveCompletionItem: completionResolve.register(context),
|
|
229
|
+
resolveCodeLens: codeLensResolve.register(context),
|
|
230
|
+
resolveDocumentLink: documentLinkResolve.register(context),
|
|
231
|
+
resolveInlayHint: inlayHintResolve.register(context),
|
|
232
|
+
...callHierarchy.register(context),
|
|
214
233
|
dispose: () => context.plugins.forEach(plugin => plugin[1].dispose?.()),
|
|
215
234
|
context,
|
|
216
235
|
};
|
|
217
|
-
for (const plugin of plugins) {
|
|
218
|
-
context.plugins.push([plugin, plugin.create(context, api)]);
|
|
219
|
-
}
|
|
220
|
-
return api;
|
|
221
236
|
}
|
|
222
|
-
exports.createLanguageService = createLanguageService;
|
|
223
237
|
//# sourceMappingURL=languageService.js.map
|
package/lib/types.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export interface LanguageServiceCommand<T extends any[]> {
|
|
|
40
40
|
}
|
|
41
41
|
export interface LanguageServiceContext {
|
|
42
42
|
language: Language<URI>;
|
|
43
|
+
getLanguageService(): LanguageService;
|
|
43
44
|
env: LanguageServiceEnvironment;
|
|
44
45
|
inject<Provide, K extends keyof Provide = keyof Provide>(key: K, ...args: Provide[K] extends (...args: any) => any ? Parameters<Provide[K]> : never): ReturnType<Provide[K] extends (...args: any) => any ? Provide[K] : never> | undefined;
|
|
45
46
|
commands: {
|
|
@@ -49,6 +50,7 @@ export interface LanguageServiceContext {
|
|
|
49
50
|
};
|
|
50
51
|
documents: {
|
|
51
52
|
get(uri: URI, languageId: string, snapshot: ts.IScriptSnapshot): TextDocument;
|
|
53
|
+
getMap(virtualCode: VirtualCode, sourceScript: SourceScript<URI>): SourceMapWithDocuments;
|
|
52
54
|
getMaps(virtualCode: VirtualCode): Generator<SourceMapWithDocuments>;
|
|
53
55
|
getLinkedCodeMap(virtualCode: VirtualCode, documentUri: URI): LinkedCodeMapWithDocument | undefined;
|
|
54
56
|
};
|
|
@@ -121,9 +123,11 @@ export interface LanguageServicePlugin<P = any> {
|
|
|
121
123
|
codeActionKinds?: string[];
|
|
122
124
|
resolveProvider?: boolean;
|
|
123
125
|
};
|
|
124
|
-
diagnosticProvider?:
|
|
126
|
+
diagnosticProvider?: {
|
|
127
|
+
workspaceDiagnostics?: boolean;
|
|
128
|
+
};
|
|
125
129
|
};
|
|
126
|
-
create(context: LanguageServiceContext
|
|
130
|
+
create(context: LanguageServiceContext): LanguageServicePluginInstance<P>;
|
|
127
131
|
}
|
|
128
132
|
export interface EmbeddedCodeFormattingOptions {
|
|
129
133
|
level: number;
|
|
@@ -166,6 +170,7 @@ export interface LanguageServicePluginInstance<P = any> {
|
|
|
166
170
|
provideWorkspaceSymbols?(query: string, token: vscode.CancellationToken): NullableProviderResult<vscode.WorkspaceSymbol[]>;
|
|
167
171
|
provideDiagnostics?(document: TextDocument, token: vscode.CancellationToken): NullableProviderResult<vscode.Diagnostic[]>;
|
|
168
172
|
provideSemanticDiagnostics?(document: TextDocument, token: vscode.CancellationToken): NullableProviderResult<vscode.Diagnostic[]>;
|
|
173
|
+
provideWorkspaceDiagnostics?(token: vscode.CancellationToken): NullableProviderResult<vscode.WorkspaceDocumentDiagnosticReport[]>;
|
|
169
174
|
provideFileReferences?(document: TextDocument, token: vscode.CancellationToken): NullableProviderResult<vscode.Location[]>;
|
|
170
175
|
provideReferencesCodeLensRanges?(document: TextDocument, token: vscode.CancellationToken): NullableProviderResult<vscode.Range[]>;
|
|
171
176
|
provideAutoInsertSnippet?(document: TextDocument, position: vscode.Position, lastChange: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "2.3.0
|
|
3
|
+
"version": "2.3.0",
|
|
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.0
|
|
15
|
+
"@volar/language-core": "2.3.0",
|
|
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": "4f6488605e22e0f76ea877460848a443fd3e8762"
|
|
21
21
|
}
|