@volar/language-service 1.4.0-alpha.8 → 1.4.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/out/baseLanguageService.d.ts +6 -2
- package/out/baseLanguageService.js +7 -3
- package/out/documentFeatures/format.js +4 -1
- package/out/documents.js +1 -1
- package/out/languageFeatures/codeLens.js +11 -14
- package/out/languageFeatures/codeLensResolve copy.d.ts +3 -0
- package/out/languageFeatures/codeLensResolve copy.js +31 -0
- package/out/languageFeatures/definition.js +10 -0
- package/out/languageFeatures/documentLinkResolve copy.d.ts +3 -0
- package/out/languageFeatures/documentLinkResolve copy.js +19 -0
- package/out/languageFeatures/documentLinkResolve.d.ts +3 -0
- package/out/languageFeatures/documentLinkResolve.js +19 -0
- package/out/languageFeatures/documentLinks copy.d.ts +8 -0
- package/out/languageFeatures/documentLinks copy.js +62 -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 +12 -2
- package/out/languageFeatures/validation.d.ts +4 -0
- package/out/languageFeatures/validation.js +21 -10
- package/out/types.d.ts +7 -2
- package/package.json +5 -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");
|
|
@@ -38,13 +40,13 @@ const vscode = require("vscode-languageserver-protocol");
|
|
|
38
40
|
// fix build
|
|
39
41
|
const common_1 = require("./utils/common");
|
|
40
42
|
function createLanguageService(ctx, documentRegistry) {
|
|
41
|
-
const languageContext = (0, language_core_1.createLanguageContext)(ctx.host, Object.values(ctx.config.languages ?? {}).filter(common_1.notEmpty));
|
|
43
|
+
const languageContext = (0, language_core_1.createLanguageContext)(ctx.host, ctx.modules, Object.values(ctx.config.languages ?? {}).filter(common_1.notEmpty));
|
|
42
44
|
const context = createLanguageServicePluginContext(ctx, languageContext, documentRegistry);
|
|
43
45
|
return createLanguageServiceBase(context);
|
|
44
46
|
}
|
|
45
47
|
exports.createLanguageService = createLanguageService;
|
|
46
48
|
function createLanguageServicePluginContext(ctx, languageContext, documentRegistry) {
|
|
47
|
-
const ts = ctx.
|
|
49
|
+
const ts = ctx.modules.typescript;
|
|
48
50
|
let tsLs;
|
|
49
51
|
if (ts) {
|
|
50
52
|
const created = tsFaster.createLanguageService(ts, languageContext.typescript.languageServiceHost, proxiedHost => ts.createLanguageService(proxiedHost, documentRegistry), ctx.rootUri.path);
|
|
@@ -165,7 +167,7 @@ function createLanguageServicePluginContext(ctx, languageContext, documentRegist
|
|
|
165
167
|
if (!document) {
|
|
166
168
|
const newVersion = (documentVersions.get(uri.toLowerCase()) ?? 0) + 1;
|
|
167
169
|
documentVersions.set(uri.toLowerCase(), newVersion);
|
|
168
|
-
document = vscode_languageserver_textdocument_1.TextDocument.create(uri, ctx.
|
|
170
|
+
document = vscode_languageserver_textdocument_1.TextDocument.create(uri, ctx.host.getScriptLanguageId?.(fileName) ?? (0, common_1.resolveCommonLanguageId)(uri), newVersion, scriptSnapshot.getText(0, scriptSnapshot.getLength()));
|
|
169
171
|
documents.set(scriptSnapshot, document);
|
|
170
172
|
}
|
|
171
173
|
return document;
|
|
@@ -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
|
}
|
package/out/documents.js
CHANGED
|
@@ -217,7 +217,7 @@ function createDocumentsAndSourceMaps(ctx, mapper) {
|
|
|
217
217
|
const map = _documents.get(snapshot);
|
|
218
218
|
if (!map.has(fileName)) {
|
|
219
219
|
const uri = ctx.fileNameToUri(fileName);
|
|
220
|
-
map.set(fileName, vscode_languageserver_textdocument_1.TextDocument.create(uri, ctx.
|
|
220
|
+
map.set(fileName, vscode_languageserver_textdocument_1.TextDocument.create(uri, ctx.host.getScriptLanguageId?.(fileName) ?? (0, common_1.resolveCommonLanguageId)(uri), version++, snapshot.getText(0, snapshot.getLength())));
|
|
221
221
|
}
|
|
222
222
|
return map.get(fileName);
|
|
223
223
|
}
|
|
@@ -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)
|
|
@@ -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,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.register = void 0;
|
|
4
|
+
const vscode = require("vscode-languageserver-protocol");
|
|
5
|
+
const references = require("./references");
|
|
6
|
+
function register(context) {
|
|
7
|
+
const findReferences = references.register(context);
|
|
8
|
+
return async (item, token = vscode.CancellationToken.None) => {
|
|
9
|
+
const data = item.data;
|
|
10
|
+
if (data?.kind === 'normal') {
|
|
11
|
+
const plugin = context.plugins[data.pluginId];
|
|
12
|
+
if (!plugin.resolveCodeLens)
|
|
13
|
+
return item;
|
|
14
|
+
Object.assign(item, data.original);
|
|
15
|
+
item = await plugin.resolveCodeLens(item, token);
|
|
16
|
+
// item.range already transformed in codeLens request
|
|
17
|
+
}
|
|
18
|
+
if (data?.kind === 'references') {
|
|
19
|
+
let references = await findReferences(data.uri, item.range.start, token) ?? [];
|
|
20
|
+
const plugin = context.plugins[data.pluginId];
|
|
21
|
+
const document = context.getTextDocument(data.uri);
|
|
22
|
+
if (document && plugin.resolveReferencesCodeLensLocations) {
|
|
23
|
+
references = await plugin.resolveReferencesCodeLensLocations(document, data.range, references, token);
|
|
24
|
+
}
|
|
25
|
+
item.command = context.commands.createShowReferencesCommand(data.uri, data.range.start, references);
|
|
26
|
+
}
|
|
27
|
+
return item;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.register = register;
|
|
31
|
+
//# sourceMappingURL=codeLensResolve%20copy.js.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%20copy.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.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
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
+
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
+
export interface DocumentLinkData {
|
|
4
|
+
uri: string;
|
|
5
|
+
original: Pick<vscode.DocumentLink, 'data'>;
|
|
6
|
+
pluginId: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.register = void 0;
|
|
4
|
+
const vscode = require("vscode-languageserver-protocol");
|
|
5
|
+
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
6
|
+
const common_1 = require("../utils/common");
|
|
7
|
+
function register(context) {
|
|
8
|
+
return async (uri, token = vscode.CancellationToken.None) => {
|
|
9
|
+
const pluginLinks = await (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, async (plugin, document) => {
|
|
10
|
+
if (token.isCancellationRequested)
|
|
11
|
+
return;
|
|
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 => {
|
|
24
|
+
if (!map)
|
|
25
|
+
return link;
|
|
26
|
+
const range = map.toSourceRange(link.range);
|
|
27
|
+
if (range) {
|
|
28
|
+
return {
|
|
29
|
+
...link,
|
|
30
|
+
range,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}).filter(common_1.notEmpty), arr => arr.flat()) ?? [];
|
|
34
|
+
const maps = context.documents.getMapsBySourceFileUri(uri);
|
|
35
|
+
const fictitiousLinks = maps ? getFictitiousLinks(context.documents.getDocumentByUri(maps.snapshot, uri), maps.maps) : [];
|
|
36
|
+
return [
|
|
37
|
+
...pluginLinks,
|
|
38
|
+
...fictitiousLinks,
|
|
39
|
+
];
|
|
40
|
+
function getFictitiousLinks(document, maps) {
|
|
41
|
+
const result = [];
|
|
42
|
+
for (const [_, map] of maps) {
|
|
43
|
+
for (const mapped of map.map.mappings) {
|
|
44
|
+
if (!mapped.data.displayWithLink)
|
|
45
|
+
continue;
|
|
46
|
+
if (mapped.sourceRange[0] === mapped.sourceRange[1])
|
|
47
|
+
continue;
|
|
48
|
+
result.push({
|
|
49
|
+
range: {
|
|
50
|
+
start: document.positionAt(mapped.sourceRange[0]),
|
|
51
|
+
end: document.positionAt(mapped.sourceRange[1]),
|
|
52
|
+
},
|
|
53
|
+
target: uri, // TODO
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
exports.register = register;
|
|
62
|
+
//# sourceMappingURL=documentLinks%20copy.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,10 +37,20 @@ 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;
|
|
@@ -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
|
@@ -8,6 +8,9 @@ import { URI } from 'vscode-uri';
|
|
|
8
8
|
import { DocumentsAndSourceMaps } from './documents';
|
|
9
9
|
export * from 'vscode-languageserver-protocol';
|
|
10
10
|
export interface LanguageServiceOptions {
|
|
11
|
+
modules: {
|
|
12
|
+
typescript?: typeof import('typescript/lib/tsserverlibrary');
|
|
13
|
+
};
|
|
11
14
|
locale?: string;
|
|
12
15
|
rootUri: URI;
|
|
13
16
|
capabilities?: vscode.ClientCapabilities;
|
|
@@ -20,7 +23,6 @@ export interface LanguageServiceOptions {
|
|
|
20
23
|
fileSystemProvider?: FileSystemProvider;
|
|
21
24
|
fileSystemHost?: FileSystemHost;
|
|
22
25
|
schemaRequestService?: SchemaRequestService;
|
|
23
|
-
getOpenedTextDocumentLanguageId?(uri: string): string | undefined;
|
|
24
26
|
}
|
|
25
27
|
interface FileSystemHost {
|
|
26
28
|
onDidChangeWatchedFiles(cb: (params: vscode.DidChangeWatchedFilesParams) => void): () => void;
|
|
@@ -94,7 +96,7 @@ export interface LanguageServicePluginInstance {
|
|
|
94
96
|
provideCodeActions?(document: TextDocument, range: vscode.Range, context: vscode.CodeActionContext, token: vscode.CancellationToken): NullableResult<vscode.CodeAction[]>;
|
|
95
97
|
provideDocumentFormattingEdits?(document: TextDocument, range: vscode.Range, options: vscode.FormattingOptions, token: vscode.CancellationToken): NullableResult<vscode.TextEdit[]>;
|
|
96
98
|
provideOnTypeFormattingEdits?(document: TextDocument, position: vscode.Position, key: string, options: vscode.FormattingOptions, token: vscode.CancellationToken): NullableResult<vscode.TextEdit[]>;
|
|
97
|
-
|
|
99
|
+
provideDocumentLinks?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.DocumentLink[]>;
|
|
98
100
|
provideCompletionItems?(document: TextDocument, position: vscode.Position, context: vscode.CompletionContext, token: vscode.CancellationToken): NullableResult<vscode.CompletionList>;
|
|
99
101
|
provideDocumentColors?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.ColorInformation[]>;
|
|
100
102
|
provideColorPresentations?(document: TextDocument, color: vscode.Color, range: vscode.Range, token: vscode.CancellationToken): NullableResult<vscode.ColorPresentation[]>;
|
|
@@ -112,6 +114,7 @@ export interface LanguageServicePluginInstance {
|
|
|
112
114
|
provideWorkspaceSymbols?(query: string, token: vscode.CancellationToken): NullableResult<vscode.WorkspaceSymbol[]>;
|
|
113
115
|
provideSyntacticDiagnostics?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Diagnostic[]>;
|
|
114
116
|
provideSemanticDiagnostics?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Diagnostic[]>;
|
|
117
|
+
provideDiagnosticMarkupContent?(diagnostic: vscode.Diagnostic, token: vscode.CancellationToken): NullableResult<vscode.MarkupContent>;
|
|
115
118
|
provideFileReferences?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Location[]>;
|
|
116
119
|
provideReferencesCodeLensRanges?(document: TextDocument, token: vscode.CancellationToken): NullableResult<vscode.Range[]>;
|
|
117
120
|
provideAutoInsertionEdit?(document: TextDocument, position: vscode.Position, context: AutoInsertionContext, token: vscode.CancellationToken): NullableResult<string | vscode.TextEdit>;
|
|
@@ -120,6 +123,8 @@ export interface LanguageServicePluginInstance {
|
|
|
120
123
|
resolveCodeLens?(codeLens: vscode.CodeLens, token: vscode.CancellationToken): Result<vscode.CodeLens>;
|
|
121
124
|
resolveCodeAction?(codeAction: vscode.CodeAction, token: vscode.CancellationToken): Result<vscode.CodeAction>;
|
|
122
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>;
|
|
123
128
|
resolveReferencesCodeLensLocations?(document: TextDocument, range: vscode.Range, references: vscode.Location[], token: vscode.CancellationToken): Result<vscode.Location[]>;
|
|
124
129
|
resolveRuleContext?(context: RuleContext, ruleType: 'format' | 'syntax' | 'semantic'): Result<RuleContext>;
|
|
125
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.0
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,13 +13,14 @@
|
|
|
13
13
|
"directory": "packages/language-service"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "1.4.0
|
|
17
|
-
"@volar/source-map": "1.4.0
|
|
16
|
+
"@volar/language-core": "1.4.0",
|
|
17
|
+
"@volar/source-map": "1.4.0",
|
|
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",
|
|
21
21
|
"vscode-languageserver-protocol": "^3.17.3",
|
|
22
22
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
23
23
|
"vscode-uri": "^3.0.7"
|
|
24
|
-
}
|
|
24
|
+
},
|
|
25
|
+
"gitHead": "9bf14ef0d08c53f9ae32cf538d9748fa91cc4ab7"
|
|
25
26
|
}
|