@volar/language-service 1.10.6 → 1.10.8
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.
|
@@ -42,7 +42,7 @@ export declare function createLanguageService(modules: SharedModules, env: Servi
|
|
|
42
42
|
doCodeLensResolve: (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
|
|
43
43
|
findDocumentHighlights: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.DocumentHighlight[] | undefined>;
|
|
44
44
|
findDocumentLinks: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
|
|
45
|
-
doDocumentLinkResolve: (item: vscode.
|
|
45
|
+
doDocumentLinkResolve: (item: vscode.DocumentLink, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink>;
|
|
46
46
|
findWorkspaceSymbols: (query: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol[]>;
|
|
47
47
|
doAutoInsert: (uri: string, position: vscode.Position, autoInsertContext: import("./types").AutoInsertionContext, token?: vscode.CancellationToken) => Promise<NonNullable<string | vscode.TextEdit | null | undefined> | undefined>;
|
|
48
48
|
getInlayHints: (uri: string, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined>;
|
|
@@ -95,7 +95,7 @@ declare function createLanguageServiceBase(context: ServiceContext): {
|
|
|
95
95
|
doCodeLensResolve: (item: vscode.CodeLens, token?: vscode.CancellationToken) => Promise<vscode.CodeLens>;
|
|
96
96
|
findDocumentHighlights: (uri: string, position: vscode.Position, token?: vscode.CancellationToken) => Promise<vscode.DocumentHighlight[] | undefined>;
|
|
97
97
|
findDocumentLinks: (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
|
|
98
|
-
doDocumentLinkResolve: (item: vscode.
|
|
98
|
+
doDocumentLinkResolve: (item: vscode.DocumentLink, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink>;
|
|
99
99
|
findWorkspaceSymbols: (query: string, token?: vscode.CancellationToken) => Promise<vscode.WorkspaceSymbol[]>;
|
|
100
100
|
doAutoInsert: (uri: string, position: vscode.Position, autoInsertContext: import("./types").AutoInsertionContext, token?: vscode.CancellationToken) => Promise<NonNullable<string | vscode.TextEdit | null | undefined> | undefined>;
|
|
101
101
|
getInlayHints: (uri: string, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.register = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
4
|
const common_1 = require("../utils/common");
|
|
6
5
|
const dedupe = require("../utils/dedupe");
|
|
7
6
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
@@ -121,7 +120,9 @@ function register(context) {
|
|
|
121
120
|
const vueRanges = tsRanges.map(tsRange => map.toSourceRange(tsRange)).filter(common_1.notEmpty);
|
|
122
121
|
const vueItem = {
|
|
123
122
|
...tsItem,
|
|
124
|
-
name: tsItem.name ===
|
|
123
|
+
name: tsItem.name === map.virtualFileDocument.uri.substring(map.virtualFileDocument.uri.lastIndexOf('/') + 1)
|
|
124
|
+
? map.sourceFileDocument.uri.substring(map.sourceFileDocument.uri.lastIndexOf('/') + 1)
|
|
125
|
+
: tsItem.name,
|
|
125
126
|
uri: map.sourceFileDocument.uri,
|
|
126
127
|
// TS Bug: `range: range` not works
|
|
127
128
|
range: {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { ServiceContext } from '../types';
|
|
3
|
-
export declare function register(context: ServiceContext): (item: vscode.
|
|
3
|
+
export declare function register(context: ServiceContext): (item: vscode.DocumentLink, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink>;
|
|
4
|
+
export declare function transformDocumentLinkTarget(target: string, context: ServiceContext): string;
|
|
4
5
|
//# sourceMappingURL=documentLinkResolve.d.ts.map
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.register = void 0;
|
|
3
|
+
exports.transformDocumentLinkTarget = exports.register = void 0;
|
|
4
4
|
const cancellation_1 = require("../utils/cancellation");
|
|
5
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
5
6
|
function register(context) {
|
|
6
7
|
return async (item, token = cancellation_1.NoneCancellationToken) => {
|
|
7
8
|
const data = item.data;
|
|
@@ -11,9 +12,52 @@ function register(context) {
|
|
|
11
12
|
return item;
|
|
12
13
|
Object.assign(item, data.original);
|
|
13
14
|
item = await service.resolveDocumentLink(item, token);
|
|
15
|
+
if (item.target) {
|
|
16
|
+
item.target = transformDocumentLinkTarget(item.target, context);
|
|
17
|
+
}
|
|
14
18
|
}
|
|
15
19
|
return item;
|
|
16
20
|
};
|
|
17
21
|
}
|
|
18
22
|
exports.register = register;
|
|
23
|
+
function transformDocumentLinkTarget(target, context) {
|
|
24
|
+
const targetUri = vscode_uri_1.URI.parse(target);
|
|
25
|
+
const clearUri = targetUri.with({ fragment: '' }).toString();
|
|
26
|
+
if (context.documents.isVirtualFileUri(clearUri)) {
|
|
27
|
+
for (const [virtualFile, map] of context.documents.getMapsByVirtualFileUri(clearUri)) {
|
|
28
|
+
if (!virtualFile.capabilities.documentSymbol) {
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
target = map.sourceFileDocument.uri;
|
|
32
|
+
const hash = targetUri.fragment;
|
|
33
|
+
const range = hash.match(/^L(\d+)(,(\d+))?(-L(\d+)(,(\d+))?)?$/);
|
|
34
|
+
if (range) {
|
|
35
|
+
const startLine = Number(range[1]) - 1;
|
|
36
|
+
const startCharacter = Number(range[3] ?? 1) - 1;
|
|
37
|
+
if (range[5] !== undefined) {
|
|
38
|
+
const endLine = Number(range[5]) - 1;
|
|
39
|
+
const endCharacter = Number(range[7] ?? 1) - 1;
|
|
40
|
+
const sourceRange = map.toSourceRange({
|
|
41
|
+
start: { line: startLine, character: startCharacter },
|
|
42
|
+
end: { line: endLine, character: endCharacter },
|
|
43
|
+
});
|
|
44
|
+
if (sourceRange) {
|
|
45
|
+
target += '#L' + (sourceRange.start.line + 1) + ',' + (sourceRange.start.character + 1);
|
|
46
|
+
target += '-L' + (sourceRange.end.line + 1) + ',' + (sourceRange.end.character + 1);
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
const sourcePos = map.toSourcePosition({ line: startLine, character: startCharacter });
|
|
52
|
+
if (sourcePos) {
|
|
53
|
+
target += '#L' + (sourcePos.line + 1) + ',' + (sourcePos.character + 1);
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return target;
|
|
61
|
+
}
|
|
62
|
+
exports.transformDocumentLinkTarget = transformDocumentLinkTarget;
|
|
19
63
|
//# sourceMappingURL=documentLinkResolve.js.map
|
|
@@ -4,13 +4,14 @@ exports.register = void 0;
|
|
|
4
4
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
5
5
|
const common_1 = require("../utils/common");
|
|
6
6
|
const cancellation_1 = require("../utils/cancellation");
|
|
7
|
+
const documentLinkResolve_1 = require("./documentLinkResolve");
|
|
7
8
|
function register(context) {
|
|
8
9
|
return async (uri, token = cancellation_1.NoneCancellationToken) => {
|
|
9
10
|
const pluginLinks = await (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, async (service, document) => {
|
|
10
11
|
if (token.isCancellationRequested)
|
|
11
12
|
return;
|
|
12
13
|
const links = await service.provideDocumentLinks?.(document, token);
|
|
13
|
-
|
|
14
|
+
for (const link of links ?? []) {
|
|
14
15
|
link.data = {
|
|
15
16
|
uri,
|
|
16
17
|
original: {
|
|
@@ -18,18 +19,21 @@ function register(context) {
|
|
|
18
19
|
},
|
|
19
20
|
serviceId: Object.keys(context.services).find(key => context.services[key] === service),
|
|
20
21
|
};
|
|
21
|
-
}
|
|
22
|
+
}
|
|
22
23
|
return links;
|
|
23
24
|
}, (links, map) => links.map(link => {
|
|
24
25
|
if (!map)
|
|
25
26
|
return link;
|
|
26
27
|
const range = map.toSourceRange(link.range);
|
|
27
|
-
if (range)
|
|
28
|
-
return
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
28
|
+
if (!range)
|
|
29
|
+
return;
|
|
30
|
+
link = {
|
|
31
|
+
...link,
|
|
32
|
+
range,
|
|
33
|
+
};
|
|
34
|
+
if (link.target)
|
|
35
|
+
link.target = (0, documentLinkResolve_1.transformDocumentLinkTarget)(link.target, context);
|
|
36
|
+
return link;
|
|
33
37
|
}).filter(common_1.notEmpty), arr => arr.flat()) ?? [];
|
|
34
38
|
const maps = context.documents.getMapsBySourceFileUri(uri);
|
|
35
39
|
const fictitiousLinks = maps ? getFictitiousLinks(context.documents.getDocumentByUri(maps.snapshot, uri), maps.maps) : [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volar/language-service",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.8",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"directory": "packages/language-service"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@volar/language-core": "1.10.
|
|
17
|
-
"@volar/source-map": "1.10.
|
|
16
|
+
"@volar/language-core": "1.10.8",
|
|
17
|
+
"@volar/source-map": "1.10.8",
|
|
18
18
|
"vscode-languageserver-protocol": "^3.17.5",
|
|
19
19
|
"vscode-languageserver-textdocument": "^1.0.11",
|
|
20
20
|
"vscode-uri": "^3.0.8"
|
|
21
21
|
},
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "fbad6fbc5bd3cc75d40492272bb97c5d1b01be2a"
|
|
23
23
|
}
|