@volar/language-service 1.4.0-alpha.9 → 1.4.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/out/baseLanguageService.d.ts +6 -2
- package/out/baseLanguageService.js +4 -0
- package/out/documentFeatures/format.js +4 -1
- package/out/languageFeatures/codeLens.js +11 -14
- package/out/languageFeatures/definition.js +10 -0
- package/out/languageFeatures/documentLinkResolve.d.ts +3 -0
- package/out/languageFeatures/documentLinkResolve.js +19 -0
- package/out/languageFeatures/documentLinks.d.ts +5 -0
- package/out/languageFeatures/documentLinks.js +13 -3
- package/out/languageFeatures/hover.js +39 -8
- package/out/languageFeatures/inlayHintResolve.d.ts +3 -0
- package/out/languageFeatures/inlayHintResolve.js +19 -0
- package/out/languageFeatures/inlayHints.d.ts +5 -0
- package/out/languageFeatures/inlayHints.js +13 -3
- package/out/languageFeatures/validation.d.ts +4 -0
- package/out/languageFeatures/validation.js +21 -10
- package/out/types.d.ts +4 -1
- package/package.json +4 -4
|
@@ -17,7 +17,7 @@ export declare function createLanguageService(ctx: LanguageServiceOptions, docum
|
|
|
17
17
|
findDocumentSymbols: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentSymbol[] | undefined>;
|
|
18
18
|
findDocumentColors: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.ColorInformation[] | undefined>;
|
|
19
19
|
getColorPresentations: (uri: string, color: vscode.Color, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.ColorPresentation[] | undefined>;
|
|
20
|
-
doValidation: (uri: string, mode: "
|
|
20
|
+
doValidation: (uri: string, mode: "semantic" | "all" | "syntactic", token?: vscode.CancellationToken, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
21
21
|
findReferences: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Location[] | undefined>;
|
|
22
22
|
findFileReferences: (uri: string, token?: vscode.CancellationToken) => import("./types").NullableResult<vscode.Location[]>;
|
|
23
23
|
findDefinition: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
|
|
@@ -37,9 +37,11 @@ export declare function createLanguageService(ctx: LanguageServiceOptions, docum
|
|
|
37
37
|
doCodeLensResolve: (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
|
|
38
38
|
findDocumentHighlights: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.DocumentHighlight[] | undefined>;
|
|
39
39
|
findDocumentLinks: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
|
|
40
|
+
doDocumentLinkResolve: (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
|
|
40
41
|
findWorkspaceSymbols: (query: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol[]>;
|
|
41
42
|
doAutoInsert: (uri: string, position: vscode.Position, autoInsertContext: import("./types").AutoInsertionContext, token?: vscode.CancellationToken) => Promise<NonNullable<string | vscode.TextEdit | null | undefined> | undefined>;
|
|
42
43
|
getInlayHints: (uri: string, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined>;
|
|
44
|
+
doInlayHintResolve: (item: vscode.InlayHint, token?: vscode.CancellationToken) => Promise<vscode.InlayHint>;
|
|
43
45
|
callHierarchy: {
|
|
44
46
|
doPrepare(uri: string, position: vscode.Position, token?: vscode.CancellationToken): Promise<vscode.CallHierarchyItem[] | undefined>;
|
|
45
47
|
getIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[]>;
|
|
@@ -63,7 +65,7 @@ declare function createLanguageServiceBase(context: LanguageServicePluginContext
|
|
|
63
65
|
findDocumentSymbols: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentSymbol[] | undefined>;
|
|
64
66
|
findDocumentColors: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.ColorInformation[] | undefined>;
|
|
65
67
|
getColorPresentations: (uri: string, color: vscode.Color, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.ColorPresentation[] | undefined>;
|
|
66
|
-
doValidation: (uri: string, mode: "
|
|
68
|
+
doValidation: (uri: string, mode: "semantic" | "all" | "syntactic", token?: vscode.CancellationToken, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
67
69
|
findReferences: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.Location[] | undefined>;
|
|
68
70
|
findFileReferences: (uri: string, token?: vscode.CancellationToken) => import("./types").NullableResult<vscode.Location[]>;
|
|
69
71
|
findDefinition: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
|
|
@@ -83,9 +85,11 @@ declare function createLanguageServiceBase(context: LanguageServicePluginContext
|
|
|
83
85
|
doCodeLensResolve: (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
|
|
84
86
|
findDocumentHighlights: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.DocumentHighlight[] | undefined>;
|
|
85
87
|
findDocumentLinks: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
|
|
88
|
+
doDocumentLinkResolve: (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
|
|
86
89
|
findWorkspaceSymbols: (query: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol[]>;
|
|
87
90
|
doAutoInsert: (uri: string, position: vscode.Position, autoInsertContext: import("./types").AutoInsertionContext, token?: vscode.CancellationToken) => Promise<NonNullable<string | vscode.TextEdit | null | undefined> | undefined>;
|
|
88
91
|
getInlayHints: (uri: string, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined>;
|
|
92
|
+
doInlayHintResolve: (item: vscode.InlayHint, token?: vscode.CancellationToken) => Promise<vscode.InlayHint>;
|
|
89
93
|
callHierarchy: {
|
|
90
94
|
doPrepare(uri: string, position: vscode.Position, token?: vscode.CancellationToken): Promise<vscode.CallHierarchyItem[] | undefined>;
|
|
91
95
|
getIncomingCalls(item: vscode.CallHierarchyItem, token: vscode.CancellationToken): Promise<vscode.CallHierarchyIncomingCall[]>;
|
|
@@ -16,11 +16,13 @@ const completionResolve = require("./languageFeatures/completeResolve");
|
|
|
16
16
|
const definition = require("./languageFeatures/definition");
|
|
17
17
|
const documentHighlight = require("./languageFeatures/documentHighlights");
|
|
18
18
|
const documentLink = require("./languageFeatures/documentLinks");
|
|
19
|
+
const documentLinkResolve = require("./languageFeatures/documentLinkResolve");
|
|
19
20
|
const semanticTokens = require("./languageFeatures/documentSemanticTokens");
|
|
20
21
|
const fileReferences = require("./languageFeatures/fileReferences");
|
|
21
22
|
const fileRename = require("./languageFeatures/fileRename");
|
|
22
23
|
const hover = require("./languageFeatures/hover");
|
|
23
24
|
const inlayHints = require("./languageFeatures/inlayHints");
|
|
25
|
+
const inlayHintResolve = require("./languageFeatures/inlayHintResolve");
|
|
24
26
|
const references = require("./languageFeatures/references");
|
|
25
27
|
const rename = require("./languageFeatures/rename");
|
|
26
28
|
const renamePrepare = require("./languageFeatures/renamePrepare");
|
|
@@ -205,9 +207,11 @@ function createLanguageServiceBase(context) {
|
|
|
205
207
|
doCodeLensResolve: codeLensResolve.register(context),
|
|
206
208
|
findDocumentHighlights: documentHighlight.register(context),
|
|
207
209
|
findDocumentLinks: documentLink.register(context),
|
|
210
|
+
doDocumentLinkResolve: documentLinkResolve.register(context),
|
|
208
211
|
findWorkspaceSymbols: workspaceSymbol.register(context),
|
|
209
212
|
doAutoInsert: autoInsert.register(context),
|
|
210
213
|
getInlayHints: inlayHints.register(context),
|
|
214
|
+
doInlayHintResolve: inlayHintResolve.register(context),
|
|
211
215
|
callHierarchy: callHierarchy.register(context),
|
|
212
216
|
dispose: () => context.typescript?.languageService.dispose(),
|
|
213
217
|
context,
|
|
@@ -95,7 +95,10 @@ function register(context) {
|
|
|
95
95
|
const lines = await plugin.provideFormattingIndentSensitiveLines(map.virtualFileDocument, token);
|
|
96
96
|
if (lines) {
|
|
97
97
|
for (const line of lines) {
|
|
98
|
-
|
|
98
|
+
const sourceLine = map.toSourcePosition({ line: line, character: 0 })?.line;
|
|
99
|
+
if (sourceLine !== undefined) {
|
|
100
|
+
indentSensitiveLines.add(sourceLine);
|
|
101
|
+
}
|
|
99
102
|
}
|
|
100
103
|
}
|
|
101
104
|
}
|
|
@@ -6,7 +6,6 @@ const vscode = require("vscode-languageserver-protocol");
|
|
|
6
6
|
const common_1 = require("../utils/common");
|
|
7
7
|
function register(context) {
|
|
8
8
|
return async (uri, token = vscode.CancellationToken.None) => {
|
|
9
|
-
const referencesCodeLendsEnabled = await context.configurationHost?.getConfiguration('volar.codeLens.references') ?? true;
|
|
10
9
|
return await (0, featureWorkers_1.languageFeatureWorker)(context, uri, undefined, (arg) => [arg], async (plugin, document) => {
|
|
11
10
|
if (token.isCancellationRequested)
|
|
12
11
|
return;
|
|
@@ -22,19 +21,17 @@ function register(context) {
|
|
|
22
21
|
pluginId,
|
|
23
22
|
};
|
|
24
23
|
});
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
codeLens
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
];
|
|
37
|
-
}
|
|
24
|
+
const ranges = await plugin.provideReferencesCodeLensRanges?.(document, token);
|
|
25
|
+
const referencesCodeLens = ranges?.map(range => vscode.CodeLens.create(range, {
|
|
26
|
+
kind: 'references',
|
|
27
|
+
uri,
|
|
28
|
+
range,
|
|
29
|
+
pluginId,
|
|
30
|
+
}));
|
|
31
|
+
codeLens = [
|
|
32
|
+
...codeLens ?? [],
|
|
33
|
+
...referencesCodeLens ?? [],
|
|
34
|
+
];
|
|
38
35
|
return codeLens;
|
|
39
36
|
}, (data, map) => data.map(codeLens => {
|
|
40
37
|
if (!map)
|
|
@@ -69,6 +69,16 @@ function register(context, apiName, isValidMapping, isValidMirrorPosition) {
|
|
|
69
69
|
link.targetSelectionRange = targetSelectionRange;
|
|
70
70
|
}
|
|
71
71
|
if (context.documents.isVirtualFileUri(link.targetUri) && !foundTargetSelectionRange) {
|
|
72
|
+
for (const [_, targetMap] of context.documents.getMapsByVirtualFileUri(link.targetUri)) {
|
|
73
|
+
if (targetMap && targetMap.sourceFileDocument.uri !== uri) {
|
|
74
|
+
return {
|
|
75
|
+
...link,
|
|
76
|
+
targetUri: targetMap.sourceFileDocument.uri,
|
|
77
|
+
targetRange: vscode.Range.create(0, 0, 0, 0),
|
|
78
|
+
targetSelectionRange: vscode.Range.create(0, 0, 0, 0),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
72
82
|
return;
|
|
73
83
|
}
|
|
74
84
|
return link;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
+
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.register = void 0;
|
|
4
|
+
const vscode = require("vscode-languageserver-protocol");
|
|
5
|
+
function register(context) {
|
|
6
|
+
return async (item, token = vscode.CancellationToken.None) => {
|
|
7
|
+
const data = item.data;
|
|
8
|
+
if (data) {
|
|
9
|
+
const plugin = context.plugins[data.pluginId];
|
|
10
|
+
if (!plugin.resolveDocumentLink)
|
|
11
|
+
return item;
|
|
12
|
+
Object.assign(item, data.original);
|
|
13
|
+
item = await plugin.resolveDocumentLink(item, token);
|
|
14
|
+
}
|
|
15
|
+
return item;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.register = register;
|
|
19
|
+
//# sourceMappingURL=documentLinkResolve.js.map
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
+
export interface DocumentLinkData {
|
|
4
|
+
uri: string;
|
|
5
|
+
original: Pick<vscode.DocumentLink, 'data'>;
|
|
6
|
+
pluginId: string;
|
|
7
|
+
}
|
|
3
8
|
export declare function register(context: LanguageServicePluginContext): (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
|
|
@@ -6,11 +6,21 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
6
6
|
const common_1 = require("../utils/common");
|
|
7
7
|
function register(context) {
|
|
8
8
|
return async (uri, token = vscode.CancellationToken.None) => {
|
|
9
|
-
const pluginLinks = await (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, (plugin, document) => {
|
|
9
|
+
const pluginLinks = await (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, async (plugin, document) => {
|
|
10
10
|
if (token.isCancellationRequested)
|
|
11
11
|
return;
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
const links = await plugin.provideDocumentLinks?.(document, token);
|
|
13
|
+
links?.forEach(link => {
|
|
14
|
+
link.data = {
|
|
15
|
+
uri,
|
|
16
|
+
original: {
|
|
17
|
+
data: link.data,
|
|
18
|
+
},
|
|
19
|
+
pluginId: Object.keys(context.plugins).find(key => context.plugins[key] === plugin),
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
return links;
|
|
23
|
+
}, (links, map) => links.map(link => {
|
|
14
24
|
if (!map)
|
|
15
25
|
return link;
|
|
16
26
|
const range = map.toSourceRange(link.range);
|
|
@@ -4,9 +4,10 @@ exports.register = void 0;
|
|
|
4
4
|
const vscode = require("vscode-languageserver-protocol");
|
|
5
5
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
6
6
|
const common_1 = require("../utils/common");
|
|
7
|
+
const validation_1 = require("./validation");
|
|
7
8
|
function register(context) {
|
|
8
|
-
return (uri, position, token = vscode.CancellationToken.None) => {
|
|
9
|
-
|
|
9
|
+
return async (uri, position, token = vscode.CancellationToken.None) => {
|
|
10
|
+
let hover = await (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.hover), (plugin, document, position) => {
|
|
10
11
|
if (token.isCancellationRequested)
|
|
11
12
|
return;
|
|
12
13
|
return plugin.provideHover?.(document, position, token);
|
|
@@ -19,16 +20,41 @@ function register(context) {
|
|
|
19
20
|
return item;
|
|
20
21
|
}
|
|
21
22
|
}, hovers => ({
|
|
22
|
-
contents:
|
|
23
|
+
contents: {
|
|
24
|
+
kind: vscode.MarkupKind.Markdown,
|
|
25
|
+
value: hovers.map(getHoverTexts).flat().join('\n\n---\n\n'),
|
|
26
|
+
},
|
|
23
27
|
range: hovers.find(hover => hover.range && (0, common_1.isInsideRange)(hover.range, { start: position, end: position }))?.range ?? hovers[0].range,
|
|
24
28
|
}));
|
|
29
|
+
const markups = validation_1.errorMarkups[uri];
|
|
30
|
+
if (markups) {
|
|
31
|
+
for (const errorAndMarkup of markups) {
|
|
32
|
+
if ((0, common_1.isInsideRange)(errorAndMarkup.error.range, { start: position, end: position })) {
|
|
33
|
+
hover ??= {
|
|
34
|
+
contents: {
|
|
35
|
+
kind: vscode.MarkupKind.Markdown,
|
|
36
|
+
value: '',
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
hover.range = errorAndMarkup.error.range;
|
|
40
|
+
if (!vscode.MarkupContent.is(hover.contents)) {
|
|
41
|
+
hover.contents = {
|
|
42
|
+
kind: vscode.MarkupKind.Markdown,
|
|
43
|
+
value: hover.contents,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (hover.contents.value) {
|
|
47
|
+
hover.contents.value += '\n\n---\n\n';
|
|
48
|
+
}
|
|
49
|
+
hover.contents.value += errorAndMarkup.markup.value;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return hover;
|
|
25
54
|
};
|
|
26
55
|
}
|
|
27
56
|
exports.register = register;
|
|
28
57
|
function getHoverTexts(hover) {
|
|
29
|
-
if (!hover) {
|
|
30
|
-
return [];
|
|
31
|
-
}
|
|
32
58
|
if (typeof hover.contents === 'string') {
|
|
33
59
|
return [hover.contents];
|
|
34
60
|
}
|
|
@@ -36,8 +62,13 @@ function getHoverTexts(hover) {
|
|
|
36
62
|
return [hover.contents.value];
|
|
37
63
|
}
|
|
38
64
|
if (Array.isArray(hover.contents)) {
|
|
39
|
-
return hover.contents
|
|
65
|
+
return hover.contents.map(content => {
|
|
66
|
+
if (typeof content === 'string') {
|
|
67
|
+
return content;
|
|
68
|
+
}
|
|
69
|
+
return `\`\`\`${content.language}\n${content.value}\n\`\`\``;
|
|
70
|
+
});
|
|
40
71
|
}
|
|
41
|
-
return [hover.contents.value];
|
|
72
|
+
return [`\`\`\`${hover.contents.language}\n${hover.contents.value}\n\`\`\``];
|
|
42
73
|
}
|
|
43
74
|
//# sourceMappingURL=hover.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
+
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (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 = void 0;
|
|
4
|
+
const vscode = require("vscode-languageserver-protocol");
|
|
5
|
+
function register(context) {
|
|
6
|
+
return async (item, token = vscode.CancellationToken.None) => {
|
|
7
|
+
const data = item.data;
|
|
8
|
+
if (data) {
|
|
9
|
+
const plugin = context.plugins[data.pluginId];
|
|
10
|
+
if (!plugin.resolveInlayHint)
|
|
11
|
+
return item;
|
|
12
|
+
Object.assign(item, data.original);
|
|
13
|
+
item = await plugin.resolveInlayHint(item, token);
|
|
14
|
+
}
|
|
15
|
+
return item;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.register = register;
|
|
19
|
+
//# sourceMappingURL=inlayHintResolve.js.map
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
+
export interface InlayHintData {
|
|
4
|
+
uri: string;
|
|
5
|
+
original: Pick<vscode.CodeAction, 'data' | 'edit'>;
|
|
6
|
+
pluginId: string;
|
|
7
|
+
}
|
|
3
8
|
export declare function register(context: LanguageServicePluginContext): (uri: string, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined>;
|
|
@@ -37,14 +37,24 @@ function register(context) {
|
|
|
37
37
|
return [vscode.Range.create(map.virtualFileDocument.positionAt(minStart), map.virtualFileDocument.positionAt(maxEnd))];
|
|
38
38
|
}
|
|
39
39
|
return [];
|
|
40
|
-
}, (plugin, document, arg) => {
|
|
40
|
+
}, async (plugin, document, arg) => {
|
|
41
41
|
if (token.isCancellationRequested)
|
|
42
42
|
return;
|
|
43
|
-
|
|
43
|
+
const hints = await plugin.provideInlayHints?.(document, arg, token);
|
|
44
|
+
hints?.forEach(link => {
|
|
45
|
+
link.data = {
|
|
46
|
+
uri,
|
|
47
|
+
original: {
|
|
48
|
+
data: link.data,
|
|
49
|
+
},
|
|
50
|
+
pluginId: Object.keys(context.plugins).find(key => context.plugins[key] === plugin),
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
return hints;
|
|
44
54
|
}, (inlayHints, map) => inlayHints.map((_inlayHint) => {
|
|
45
55
|
if (!map)
|
|
46
56
|
return _inlayHint;
|
|
47
|
-
const position = map.toSourcePosition(_inlayHint.position);
|
|
57
|
+
const position = map.toSourcePosition(_inlayHint.position, data => !!data.semanticTokens /* todo */);
|
|
48
58
|
const edits = _inlayHint.textEdits
|
|
49
59
|
?.map(textEdit => transformer.asTextEdit(textEdit, range => map.toSourceRange(range), map.virtualFileDocument))
|
|
50
60
|
.filter(common_1.notEmpty);
|
|
@@ -14,4 +14,8 @@ export interface PluginDiagnosticData {
|
|
|
14
14
|
ruleFixIndex: number;
|
|
15
15
|
documentUri: string;
|
|
16
16
|
}
|
|
17
|
+
export declare const errorMarkups: Record<string, {
|
|
18
|
+
error: vscode.Diagnostic;
|
|
19
|
+
markup: vscode.MarkupContent;
|
|
20
|
+
}[]>;
|
|
17
21
|
export declare function register(context: LanguageServicePluginContext): (uri: string, mode: 'all' | 'semantic' | 'syntactic', token?: vscode.CancellationToken, response?: ((result: vscode.Diagnostic[]) => void) | undefined) => Promise<vscode.Diagnostic[]>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.register = exports.updateRange = void 0;
|
|
3
|
+
exports.register = exports.errorMarkups = exports.updateRange = void 0;
|
|
4
4
|
const vscode = require("vscode-languageserver-protocol");
|
|
5
5
|
const common_1 = require("../utils/common");
|
|
6
6
|
const dedupe = require("../utils/dedupe");
|
|
@@ -77,6 +77,7 @@ function updatePosition(position, change, isEnd) {
|
|
|
77
77
|
}
|
|
78
78
|
return false;
|
|
79
79
|
}
|
|
80
|
+
exports.errorMarkups = {};
|
|
80
81
|
function register(context) {
|
|
81
82
|
const lastResponses = new Map();
|
|
82
83
|
const cacheMaps = {
|
|
@@ -126,26 +127,36 @@ function register(context) {
|
|
|
126
127
|
}
|
|
127
128
|
if (mode === 'all' || mode === 'syntactic') {
|
|
128
129
|
await lintWorker('onFormat', cacheMaps.format_rules, lastResponse.format_rules);
|
|
129
|
-
doResponse();
|
|
130
|
+
await doResponse();
|
|
130
131
|
await lintWorker('onSyntax', cacheMaps.syntax_rules, lastResponse.syntax_rules);
|
|
131
|
-
doResponse();
|
|
132
|
+
await doResponse();
|
|
132
133
|
await worker('provideSyntacticDiagnostics', cacheMaps.syntactic, lastResponse.syntactic);
|
|
133
|
-
doResponse();
|
|
134
|
+
await doResponse();
|
|
134
135
|
}
|
|
135
136
|
if (mode === 'all' || mode === 'semantic') {
|
|
136
137
|
await lintWorker('onSemantic', cacheMaps.semantic_rules, lastResponse.semantic_rules);
|
|
137
|
-
doResponse();
|
|
138
|
+
await doResponse();
|
|
138
139
|
await worker('provideSemanticDiagnostics', cacheMaps.semantic, lastResponse.semantic);
|
|
139
140
|
}
|
|
140
|
-
return collectErrors();
|
|
141
|
-
function doResponse() {
|
|
141
|
+
return await collectErrors();
|
|
142
|
+
async function doResponse() {
|
|
142
143
|
if (errorsUpdated && !updateCacheRangeFailed) {
|
|
143
|
-
response?.(collectErrors());
|
|
144
|
+
response?.(await collectErrors());
|
|
144
145
|
errorsUpdated = false;
|
|
145
146
|
}
|
|
146
147
|
}
|
|
147
|
-
function collectErrors() {
|
|
148
|
-
|
|
148
|
+
async function collectErrors() {
|
|
149
|
+
const errors = Object.values(lastResponse).flatMap(({ errors }) => errors);
|
|
150
|
+
exports.errorMarkups[uri] = [];
|
|
151
|
+
for (const error of errors) {
|
|
152
|
+
for (const plugin of Object.values(context.plugins)) {
|
|
153
|
+
const markup = await plugin.provideDiagnosticMarkupContent?.(error, token);
|
|
154
|
+
if (markup) {
|
|
155
|
+
exports.errorMarkups[uri].push({ error, markup });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return errors;
|
|
149
160
|
}
|
|
150
161
|
async function lintWorker(api, cacheMap, cache) {
|
|
151
162
|
const result = await (0, featureWorkers_1.ruleWorker)(context, api, uri, file => api === 'onFormat' ? !!file.capabilities.documentFormatting : !!file.capabilities.diagnostic, async (ruleName, rule, ruleCtx) => {
|
package/out/types.d.ts
CHANGED
|
@@ -96,7 +96,7 @@ export interface LanguageServicePluginInstance {
|
|
|
96
96
|
provideCodeActions?(document: TextDocument, range: vscode.Range, context: vscode.CodeActionContext, token: vscode.CancellationToken): NullableResult<vscode.CodeAction[]>;
|
|
97
97
|
provideDocumentFormattingEdits?(document: TextDocument, range: vscode.Range, options: vscode.FormattingOptions, token: vscode.CancellationToken): NullableResult<vscode.TextEdit[]>;
|
|
98
98
|
provideOnTypeFormattingEdits?(document: TextDocument, position: vscode.Position, key: string, options: vscode.FormattingOptions, token: vscode.CancellationToken): NullableResult<vscode.TextEdit[]>;
|
|
99
|
-
|
|
99
|
+
provideDocumentLinks?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.DocumentLink[]>;
|
|
100
100
|
provideCompletionItems?(document: TextDocument, position: vscode.Position, context: vscode.CompletionContext, token: vscode.CancellationToken): NullableResult<vscode.CompletionList>;
|
|
101
101
|
provideDocumentColors?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.ColorInformation[]>;
|
|
102
102
|
provideColorPresentations?(document: TextDocument, color: vscode.Color, range: vscode.Range, token: vscode.CancellationToken): NullableResult<vscode.ColorPresentation[]>;
|
|
@@ -114,6 +114,7 @@ export interface LanguageServicePluginInstance {
|
|
|
114
114
|
provideWorkspaceSymbols?(query: string, token: vscode.CancellationToken): NullableResult<vscode.WorkspaceSymbol[]>;
|
|
115
115
|
provideSyntacticDiagnostics?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Diagnostic[]>;
|
|
116
116
|
provideSemanticDiagnostics?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Diagnostic[]>;
|
|
117
|
+
provideDiagnosticMarkupContent?(diagnostic: vscode.Diagnostic, token: vscode.CancellationToken): NullableResult<vscode.MarkupContent>;
|
|
117
118
|
provideFileReferences?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Location[]>;
|
|
118
119
|
provideReferencesCodeLensRanges?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Range[]>;
|
|
119
120
|
provideAutoInsertionEdit?(document: TextDocument, position: vscode.Position, context: AutoInsertionContext, token: vscode.CancellationToken): NullableResult<string | vscode.TextEdit>;
|
|
@@ -122,6 +123,8 @@ export interface LanguageServicePluginInstance {
|
|
|
122
123
|
resolveCodeLens?(codeLens: vscode.CodeLens, token: vscode.CancellationToken): Result<vscode.CodeLens>;
|
|
123
124
|
resolveCodeAction?(codeAction: vscode.CodeAction, token: vscode.CancellationToken): Result<vscode.CodeAction>;
|
|
124
125
|
resolveCompletionItem?(item: vscode.CompletionItem, token: vscode.CancellationToken): Result<vscode.CompletionItem>;
|
|
126
|
+
resolveDocumentLink?(link: vscode.DocumentLink, token: vscode.CancellationToken): Result<vscode.DocumentLink>;
|
|
127
|
+
resolveInlayHint?(inlayHint: vscode.InlayHint, token: vscode.CancellationToken): Result<vscode.InlayHint>;
|
|
125
128
|
resolveReferencesCodeLensLocations?(document: TextDocument, range: vscode.Range, references: vscode.Location[], token: vscode.CancellationToken): Result<vscode.Location[]>;
|
|
126
129
|
resolveRuleContext?(context: RuleContext, ruleType: 'format' | 'syntax' | 'semantic'): Result<RuleContext>;
|
|
127
130
|
resolveEmbeddedRange?(range: vscode.Range): vscode.Range | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"directory": "packages/language-service"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "1.4.
|
|
17
|
-
"@volar/source-map": "1.4.
|
|
16
|
+
"@volar/language-core": "1.4.1",
|
|
17
|
+
"@volar/source-map": "1.4.1",
|
|
18
18
|
"typescript-auto-import-cache": "^0.2.1",
|
|
19
19
|
"vscode-html-languageservice": "^5.0.4",
|
|
20
20
|
"vscode-json-languageservice": "^5.2.0",
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
23
23
|
"vscode-uri": "^3.0.7"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "2c8a783542ace3292649a04490919b515e387b9e"
|
|
26
26
|
}
|