@volar/language-service 1.0.16 → 1.0.17
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/baseDocumentService.js +13 -28
- package/out/baseLanguageService.d.ts +2 -2
- package/out/baseLanguageService.js +4 -4
- package/out/documentFeatures/autoInsert.js +2 -2
- package/out/documentFeatures/colorPresentations.js +4 -4
- package/out/documentFeatures/documentColors.js +3 -3
- package/out/documentFeatures/documentSymbols.js +4 -4
- package/out/documentFeatures/foldingRanges.js +1 -1
- package/out/documentFeatures/format.js +37 -35
- package/out/documentFeatures/linkedEditingRanges.js +2 -2
- package/out/documentFeatures/selectionRanges.js +3 -3
- package/out/documents.d.ts +26 -56
- package/out/documents.js +102 -144
- package/out/languageFeatures/autoInsert.js +7 -7
- package/out/languageFeatures/callHierarchy.d.ts +1 -1
- package/out/languageFeatures/callHierarchy.js +33 -34
- package/out/languageFeatures/codeActionResolve.js +2 -3
- package/out/languageFeatures/codeActions.d.ts +1 -1
- package/out/languageFeatures/codeActions.js +10 -10
- package/out/languageFeatures/codeLens.js +3 -3
- package/out/languageFeatures/complete.d.ts +1 -1
- package/out/languageFeatures/complete.js +32 -33
- package/out/languageFeatures/completeResolve.js +3 -4
- package/out/languageFeatures/definition.d.ts +2 -2
- package/out/languageFeatures/definition.js +24 -20
- package/out/languageFeatures/documentHighlights.js +15 -15
- package/out/languageFeatures/documentLinks.js +8 -9
- package/out/languageFeatures/documentSemanticTokens.js +5 -5
- package/out/languageFeatures/executeCommand.d.ts +1 -1
- package/out/languageFeatures/executeCommand.js +2 -1
- package/out/languageFeatures/fileReferences.js +3 -4
- package/out/languageFeatures/fileRename.js +4 -4
- package/out/languageFeatures/hover.js +3 -3
- package/out/languageFeatures/inlayHints.js +10 -10
- package/out/languageFeatures/references.js +21 -20
- package/out/languageFeatures/rename.d.ts +2 -2
- package/out/languageFeatures/rename.js +99 -80
- package/out/languageFeatures/renamePrepare.js +3 -3
- package/out/languageFeatures/signatureHelp.js +1 -1
- package/out/languageFeatures/validation.js +19 -18
- package/out/languageFeatures/workspaceSymbols.js +6 -5
- package/out/types.d.ts +9 -8
- package/out/utils/definePlugin.d.ts +3 -2
- package/out/utils/definePlugin.js +9 -6
- package/out/utils/featureWorkers.d.ts +5 -5
- package/out/utils/featureWorkers.js +15 -14
- package/package.json +7 -7
|
@@ -22,26 +22,25 @@ function register(context) {
|
|
|
22
22
|
for (const cacheData of cache.data) {
|
|
23
23
|
if (!cacheData.list.isIncomplete)
|
|
24
24
|
continue;
|
|
25
|
-
if (cacheData.
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
if (cacheData.map) {
|
|
26
|
+
for (const [_, map] of context.documents.getMapsByVirtualFileUri(cacheData.map.embeddedDocumentUri)) {
|
|
27
|
+
for (const mapped of map.toGeneratedPositions(position, data => !!data.completion)) {
|
|
28
|
+
if (!((_a = cacheData.plugin.complete) === null || _a === void 0 ? void 0 : _a.on))
|
|
29
|
+
continue;
|
|
30
|
+
const embeddedCompletionList = yield cacheData.plugin.complete.on(map.virtualFileDocument, mapped, completionContext);
|
|
31
|
+
if (!embeddedCompletionList) {
|
|
32
|
+
cacheData.list.isIncomplete = false;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
cacheData.list = (0, transforms_1.transformCompletionList)(embeddedCompletionList, range => map.toSourceRange(range), (newItem, oldItem) => newItem.data = {
|
|
36
|
+
uri,
|
|
37
|
+
originalItem: oldItem,
|
|
38
|
+
pluginId: context.plugins.indexOf(cacheData.plugin),
|
|
39
|
+
map: {
|
|
40
|
+
embeddedDocumentUri: map.virtualFileDocument.uri,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
36
43
|
}
|
|
37
|
-
cacheData.list = (0, transforms_1.transformCompletionList)(embeddedCompletionList, range => sourceMap.toSourceRange(range), (newItem, oldItem) => newItem.data = {
|
|
38
|
-
uri,
|
|
39
|
-
originalItem: oldItem,
|
|
40
|
-
pluginId: context.plugins.indexOf(cacheData.plugin),
|
|
41
|
-
sourceMap: {
|
|
42
|
-
embeddedDocumentUri: sourceMap.mappedDocument.uri,
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
else if (document = context.getTextDocument(uri)) {
|
|
@@ -56,13 +55,13 @@ function register(context) {
|
|
|
56
55
|
uri,
|
|
57
56
|
originalItem: item,
|
|
58
57
|
pluginId: context.plugins.indexOf(cacheData.plugin),
|
|
59
|
-
|
|
58
|
+
map: undefined,
|
|
60
59
|
} }))) });
|
|
61
60
|
}
|
|
62
61
|
}
|
|
63
62
|
}
|
|
64
63
|
else {
|
|
65
|
-
const
|
|
64
|
+
const rootFile = context.documents.getRootFileBySourceFileUri(uri);
|
|
66
65
|
cache = {
|
|
67
66
|
uri,
|
|
68
67
|
data: [],
|
|
@@ -70,12 +69,12 @@ function register(context) {
|
|
|
70
69
|
};
|
|
71
70
|
// monky fix https://github.com/johnsoncodehk/volar/issues/1358
|
|
72
71
|
let isFirstMapping = true;
|
|
73
|
-
if (
|
|
74
|
-
yield (0, definePlugin_1.visitEmbedded)(
|
|
72
|
+
if (rootFile) {
|
|
73
|
+
yield (0, definePlugin_1.visitEmbedded)(context.documents, rootFile, (_, map) => __awaiter(this, void 0, void 0, function* () {
|
|
75
74
|
var _e, _f;
|
|
76
75
|
const plugins = context.plugins.sort(sortPlugins);
|
|
77
76
|
let _data;
|
|
78
|
-
for (const mapped of
|
|
77
|
+
for (const mapped of map.toGeneratedPositions(position, data => {
|
|
79
78
|
_data = data;
|
|
80
79
|
return !!data.completion;
|
|
81
80
|
})) {
|
|
@@ -87,31 +86,31 @@ function register(context) {
|
|
|
87
86
|
if ((completionContext === null || completionContext === void 0 ? void 0 : completionContext.triggerCharacter) && !((_f = plugin.complete.triggerCharacters) === null || _f === void 0 ? void 0 : _f.includes(completionContext.triggerCharacter)))
|
|
88
87
|
continue;
|
|
89
88
|
const isAdditional = _data && typeof _data.completion === 'object' && _data.completion.additional || plugin.complete.isAdditional;
|
|
90
|
-
if (cache.mainCompletion && (!isAdditional || (cache === null || cache === void 0 ? void 0 : cache.mainCompletion.documentUri) !==
|
|
89
|
+
if (cache.mainCompletion && (!isAdditional || (cache === null || cache === void 0 ? void 0 : cache.mainCompletion.documentUri) !== map.virtualFileDocument.uri))
|
|
91
90
|
continue;
|
|
92
91
|
// avoid duplicate items with .vue and .vue.html
|
|
93
92
|
if (plugin.complete.isAdditional && (cache === null || cache === void 0 ? void 0 : cache.data.some(data => data.plugin === plugin)))
|
|
94
93
|
continue;
|
|
95
|
-
const embeddedCompletionList = yield plugin.complete.on(
|
|
94
|
+
const embeddedCompletionList = yield plugin.complete.on(map.virtualFileDocument, mapped, completionContext);
|
|
96
95
|
if (!embeddedCompletionList || !embeddedCompletionList.items.length)
|
|
97
96
|
continue;
|
|
98
97
|
if (typeof (_data === null || _data === void 0 ? void 0 : _data.completion) === 'object' && _data.completion.autoImportOnly) {
|
|
99
98
|
embeddedCompletionList.items = embeddedCompletionList.items.filter(item => !!item.labelDetails);
|
|
100
99
|
}
|
|
101
100
|
if (!isAdditional) {
|
|
102
|
-
cache.mainCompletion = { documentUri:
|
|
101
|
+
cache.mainCompletion = { documentUri: map.virtualFileDocument.uri };
|
|
103
102
|
}
|
|
104
|
-
const completionList = (0, transforms_1.transformCompletionList)(embeddedCompletionList, range =>
|
|
103
|
+
const completionList = (0, transforms_1.transformCompletionList)(embeddedCompletionList, range => map.toSourceRange(range), (newItem, oldItem) => newItem.data = {
|
|
105
104
|
uri,
|
|
106
105
|
originalItem: oldItem,
|
|
107
106
|
pluginId: context.plugins.indexOf(plugin),
|
|
108
|
-
|
|
109
|
-
embeddedDocumentUri:
|
|
107
|
+
map: {
|
|
108
|
+
embeddedDocumentUri: map.virtualFileDocument.uri,
|
|
110
109
|
}
|
|
111
110
|
});
|
|
112
111
|
cache.data.push({
|
|
113
|
-
|
|
114
|
-
embeddedDocumentUri:
|
|
112
|
+
map: {
|
|
113
|
+
embeddedDocumentUri: map.virtualFileDocument.uri,
|
|
115
114
|
},
|
|
116
115
|
plugin,
|
|
117
116
|
list: completionList,
|
|
@@ -143,7 +142,7 @@ function register(context) {
|
|
|
143
142
|
cache.mainCompletion = { documentUri: document.uri };
|
|
144
143
|
}
|
|
145
144
|
cache.data.push({
|
|
146
|
-
|
|
145
|
+
map: undefined,
|
|
147
146
|
plugin,
|
|
148
147
|
list: Object.assign(Object.assign({}, completionList), { items: completionList.items.map(item => {
|
|
149
148
|
return Object.assign(Object.assign({}, item), { data: {
|
|
@@ -21,9 +21,8 @@ function register(context) {
|
|
|
21
21
|
if (!((_a = plugin.complete) === null || _a === void 0 ? void 0 : _a.resolve))
|
|
22
22
|
return item;
|
|
23
23
|
const originalItem = data.originalItem;
|
|
24
|
-
if (data.
|
|
25
|
-
const
|
|
26
|
-
if (sourceMap) {
|
|
24
|
+
if (data.map) {
|
|
25
|
+
for (const [_, map] of context.documents.getMapsByVirtualFileUri(data.map.embeddedDocumentUri)) {
|
|
27
26
|
const resolvedItem = yield plugin.complete.resolve(originalItem);
|
|
28
27
|
// fix https://github.com/johnsoncodehk/volar/issues/916
|
|
29
28
|
if (resolvedItem.additionalTextEdits) {
|
|
@@ -41,7 +40,7 @@ function register(context) {
|
|
|
41
40
|
let range = (_a = plugin.resolveEmbeddedRange) === null || _a === void 0 ? void 0 : _a.call(plugin, embeddedRange);
|
|
42
41
|
if (range)
|
|
43
42
|
return range;
|
|
44
|
-
return
|
|
43
|
+
return map.toSourceRange(embeddedRange);
|
|
45
44
|
});
|
|
46
45
|
}
|
|
47
46
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServiceRuntimeContext } from '../types';
|
|
3
|
-
import {
|
|
4
|
-
export declare function register(context: LanguageServiceRuntimeContext, api: 'findDefinition' | 'findTypeDefinition' | 'findImplementations',
|
|
3
|
+
import { FileRangeCapabilities, MirrorBehaviorCapabilities } from '@volar/language-core';
|
|
4
|
+
export declare function register(context: LanguageServiceRuntimeContext, api: 'findDefinition' | 'findTypeDefinition' | 'findImplementations', isValidMapping: (data: FileRangeCapabilities) => boolean, isValidMirrorPosition: (mirrorData: MirrorBehaviorCapabilities) => boolean): (uri: string, position: vscode.Position) => Promise<vscode.LocationLink[] | undefined>;
|
|
@@ -12,15 +12,15 @@ exports.register = void 0;
|
|
|
12
12
|
const shared = require("@volar/shared");
|
|
13
13
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
14
14
|
const dedupe = require("../utils/dedupe");
|
|
15
|
-
function register(context, api,
|
|
15
|
+
function register(context, api, isValidMapping, isValidMirrorPosition) {
|
|
16
16
|
return (uri, position) => {
|
|
17
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position,
|
|
17
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, isValidMapping), (plugin, document, position) => __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
const recursiveChecker = dedupe.createLocationSet();
|
|
19
19
|
const result = [];
|
|
20
|
-
yield
|
|
20
|
+
yield withMirrors(document, position, undefined);
|
|
21
21
|
return result;
|
|
22
|
-
function
|
|
23
|
-
var _a, _b, _c;
|
|
22
|
+
function withMirrors(document, position, originDefinition) {
|
|
23
|
+
var _a, _b, _c, _d;
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
25
|
const _api = api === 'findDefinition' ? (_a = plugin.definition) === null || _a === void 0 ? void 0 : _a.on :
|
|
26
26
|
api === 'findTypeDefinition' ? (_b = plugin.definition) === null || _b === void 0 ? void 0 : _b.onType :
|
|
@@ -33,20 +33,20 @@ function register(context, api, isValidMappingData, isValidTeleportSideData) {
|
|
|
33
33
|
recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
|
|
34
34
|
const definitions = (_c = yield (_api === null || _api === void 0 ? void 0 : _api(document, position))) !== null && _c !== void 0 ? _c : [];
|
|
35
35
|
for (const definition of definitions) {
|
|
36
|
-
let
|
|
36
|
+
let foundMirrorPosition = false;
|
|
37
37
|
recursiveChecker.add({ uri: definition.targetUri, range: { start: definition.targetRange.start, end: definition.targetRange.start } });
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
for (const mapped of
|
|
41
|
-
if (!
|
|
38
|
+
const mirrorMap = (_d = context.documents.getMirrorMapByUri(definition.targetUri)) === null || _d === void 0 ? void 0 : _d[1];
|
|
39
|
+
if (mirrorMap) {
|
|
40
|
+
for (const mapped of mirrorMap.findMirrorPositions(definition.targetSelectionRange.start)) {
|
|
41
|
+
if (!isValidMirrorPosition(mapped[1]))
|
|
42
42
|
continue;
|
|
43
|
-
if (recursiveChecker.has({ uri:
|
|
43
|
+
if (recursiveChecker.has({ uri: mirrorMap.document.uri, range: { start: mapped[0], end: mapped[0] } }))
|
|
44
44
|
continue;
|
|
45
|
-
|
|
46
|
-
yield
|
|
45
|
+
foundMirrorPosition = true;
|
|
46
|
+
yield withMirrors(mirrorMap.document, mapped[0], originDefinition !== null && originDefinition !== void 0 ? originDefinition : definition);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
if (!
|
|
49
|
+
if (!foundMirrorPosition) {
|
|
50
50
|
if (originDefinition) {
|
|
51
51
|
result.push(Object.assign(Object.assign({}, definition), { originSelectionRange: originDefinition.originSelectionRange }));
|
|
52
52
|
}
|
|
@@ -64,25 +64,29 @@ function register(context, api, isValidMappingData, isValidTeleportSideData) {
|
|
|
64
64
|
return;
|
|
65
65
|
link.originSelectionRange = originSelectionRange;
|
|
66
66
|
}
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
let foundTargetSelectionRange = false;
|
|
68
|
+
for (const [_, targetSourceMap] of context.documents.getMapsByVirtualFileUri(link.targetUri)) {
|
|
69
69
|
const targetSelectionRange = targetSourceMap.toSourceRange(link.targetSelectionRange);
|
|
70
70
|
if (!targetSelectionRange)
|
|
71
|
-
|
|
71
|
+
continue;
|
|
72
|
+
foundTargetSelectionRange = true;
|
|
72
73
|
let targetRange = targetSourceMap.toSourceRange(link.targetRange);
|
|
73
|
-
link.targetUri = targetSourceMap.
|
|
74
|
+
link.targetUri = targetSourceMap.sourceFileDocument.uri;
|
|
74
75
|
// loose range mapping to for template slots, slot properties
|
|
75
76
|
link.targetRange = targetRange !== null && targetRange !== void 0 ? targetRange : targetSelectionRange;
|
|
76
77
|
link.targetSelectionRange = targetSelectionRange;
|
|
77
78
|
}
|
|
79
|
+
if (context.documents.getVirtualFileByUri(link.targetUri) && !foundTargetSelectionRange) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
78
82
|
return link;
|
|
79
83
|
}).filter(shared.notEmpty), arr => dedupe.withLocationLinks(arr.flat()));
|
|
80
84
|
};
|
|
81
85
|
}
|
|
82
86
|
exports.register = register;
|
|
83
|
-
function toSourcePositionPreferSurroundedPosition(
|
|
87
|
+
function toSourcePositionPreferSurroundedPosition(map, mappedRange, position) {
|
|
84
88
|
let result;
|
|
85
|
-
for (const range of
|
|
89
|
+
for (const range of map.toSourceRanges(mappedRange)) {
|
|
86
90
|
if (!result) {
|
|
87
91
|
result = range;
|
|
88
92
|
}
|
|
@@ -14,15 +14,15 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
14
14
|
const dedupe = require("../utils/dedupe");
|
|
15
15
|
function register(context) {
|
|
16
16
|
return (uri, position) => {
|
|
17
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position,
|
|
17
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position,
|
|
18
18
|
// note https://github.com/johnsoncodehk/volar/issues/2009
|
|
19
19
|
data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename), (plugin, document, position) => __awaiter(this, void 0, void 0, function* () {
|
|
20
20
|
const recursiveChecker = dedupe.createLocationSet();
|
|
21
21
|
const result = [];
|
|
22
|
-
yield
|
|
22
|
+
yield withMirrors(document, position);
|
|
23
23
|
return result;
|
|
24
|
-
function
|
|
25
|
-
var _a;
|
|
24
|
+
function withMirrors(document, position) {
|
|
25
|
+
var _a, _b;
|
|
26
26
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
27
|
if (!plugin.findDocumentHighlights)
|
|
28
28
|
return;
|
|
@@ -31,29 +31,29 @@ function register(context) {
|
|
|
31
31
|
recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
|
|
32
32
|
const references = (_a = yield plugin.findDocumentHighlights(document, position)) !== null && _a !== void 0 ? _a : [];
|
|
33
33
|
for (const reference of references) {
|
|
34
|
-
let
|
|
34
|
+
let foundMirrorPosition = false;
|
|
35
35
|
recursiveChecker.add({ uri: document.uri, range: { start: reference.range.start, end: reference.range.start } });
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
38
|
-
for (const mapped of
|
|
36
|
+
const mirrorMap = (_b = context.documents.getMirrorMapByUri(document.uri)) === null || _b === void 0 ? void 0 : _b[1];
|
|
37
|
+
if (mirrorMap) {
|
|
38
|
+
for (const mapped of mirrorMap.findMirrorPositions(reference.range.start)) {
|
|
39
39
|
if (!mapped[1].references)
|
|
40
40
|
continue;
|
|
41
|
-
if (recursiveChecker.has({ uri:
|
|
41
|
+
if (recursiveChecker.has({ uri: mirrorMap.document.uri, range: { start: mapped[0], end: mapped[0] } }))
|
|
42
42
|
continue;
|
|
43
|
-
|
|
44
|
-
yield
|
|
43
|
+
foundMirrorPosition = true;
|
|
44
|
+
yield withMirrors(mirrorMap.document, mapped[0]);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
if (!
|
|
47
|
+
if (!foundMirrorPosition) {
|
|
48
48
|
result.push(reference);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
}), (data,
|
|
54
|
-
if (!
|
|
53
|
+
}), (data, map) => data.map(highlisht => {
|
|
54
|
+
if (!map)
|
|
55
55
|
return highlisht;
|
|
56
|
-
const range =
|
|
56
|
+
const range = map.toSourceRange(highlisht.range);
|
|
57
57
|
if (range) {
|
|
58
58
|
return Object.assign(Object.assign({}, highlisht), { range });
|
|
59
59
|
}
|
|
@@ -14,25 +14,24 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
14
14
|
function register(context) {
|
|
15
15
|
return (uri) => __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
var _a;
|
|
17
|
-
const pluginLinks = (_a = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, undefined, (arg) => [arg], (plugin, document) => { var _a; return (_a = plugin.findDocumentLinks) === null || _a === void 0 ? void 0 : _a.call(plugin, document); }, (data,
|
|
18
|
-
if (!
|
|
17
|
+
const pluginLinks = (_a = yield (0, featureWorkers_1.languageFeatureWorker)(context, uri, undefined, (arg) => [arg], (plugin, document) => { var _a; return (_a = plugin.findDocumentLinks) === null || _a === void 0 ? void 0 : _a.call(plugin, document); }, (data, map) => data.map(link => {
|
|
18
|
+
if (!map)
|
|
19
19
|
return link;
|
|
20
|
-
const range =
|
|
20
|
+
const range = map.toSourceRange(link.range);
|
|
21
21
|
if (range) {
|
|
22
22
|
return Object.assign(Object.assign({}, link), { range });
|
|
23
23
|
}
|
|
24
24
|
}).filter(shared.notEmpty), arr => arr.flat())) !== null && _a !== void 0 ? _a : [];
|
|
25
|
-
const
|
|
26
|
-
const fictitiousLinks =
|
|
25
|
+
const maps = context.documents.getMapsBySourceFileUri(uri);
|
|
26
|
+
const fictitiousLinks = maps ? getFictitiousLinks(context.documents.getDocumentByUri(maps.snapshot, uri), maps.maps) : [];
|
|
27
27
|
return [
|
|
28
28
|
...pluginLinks,
|
|
29
29
|
...fictitiousLinks,
|
|
30
30
|
];
|
|
31
|
-
function getFictitiousLinks(
|
|
31
|
+
function getFictitiousLinks(document, maps) {
|
|
32
32
|
const result = [];
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
for (const mapped of sourceMap.mappings) {
|
|
33
|
+
for (const [_, map] of maps) {
|
|
34
|
+
for (const mapped of map.map.mappings) {
|
|
36
35
|
if (!mapped.data.displayWithLink)
|
|
37
36
|
continue;
|
|
38
37
|
if (mapped.sourceRange[0] === mapped.sourceRange[1])
|
|
@@ -15,11 +15,11 @@ function register(context) {
|
|
|
15
15
|
0,
|
|
16
16
|
document.getText().length,
|
|
17
17
|
];
|
|
18
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, offsetRange, function* (offsetRange,
|
|
18
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, offsetRange, function* (offsetRange, map) {
|
|
19
19
|
if (cancelToken === null || cancelToken === void 0 ? void 0 : cancelToken.isCancellationRequested)
|
|
20
20
|
return;
|
|
21
21
|
let range;
|
|
22
|
-
for (const mapping of
|
|
22
|
+
for (const mapping of map.map.mappings) {
|
|
23
23
|
if (mapping.data.semanticTokens
|
|
24
24
|
&& mapping.sourceRange[1] > offsetRange[0]
|
|
25
25
|
&& mapping.sourceRange[0] < offsetRange[1]) {
|
|
@@ -38,10 +38,10 @@ function register(context) {
|
|
|
38
38
|
}, (plugin, document, offsetRange) => {
|
|
39
39
|
var _a;
|
|
40
40
|
return (_a = plugin.findDocumentSemanticTokens) === null || _a === void 0 ? void 0 : _a.call(plugin, document, vscode.Range.create(document.positionAt(offsetRange[0]), document.positionAt(offsetRange[1])), legend);
|
|
41
|
-
}, (tokens,
|
|
42
|
-
if (!
|
|
41
|
+
}, (tokens, map) => tokens.map(_token => {
|
|
42
|
+
if (!map)
|
|
43
43
|
return _token;
|
|
44
|
-
const range =
|
|
44
|
+
const range = map.toSourceRange({
|
|
45
45
|
start: { line: _token[0], character: _token[1] },
|
|
46
46
|
end: { line: _token[0], character: _token[1] + _token[2] },
|
|
47
47
|
}, data => !!data.semanticTokens);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LanguageServiceRuntimeContext } from '../types';
|
|
2
2
|
import { ExecuteCommandContext } from '@volar/language-service';
|
|
3
3
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
4
|
-
export declare const executePluginCommand
|
|
4
|
+
export declare const executePluginCommand: string;
|
|
5
5
|
export type ExecutePluginCommandArgs = [
|
|
6
6
|
string,
|
|
7
7
|
// uri
|
|
@@ -9,7 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
11
|
exports.register = exports.executePluginCommand = void 0;
|
|
12
|
-
|
|
12
|
+
const randomCommandId = Math.random().toString(36).slice(2); // TODO
|
|
13
|
+
exports.executePluginCommand = `volar.${randomCommandId}.executePluginCommand`;
|
|
13
14
|
function register(context) {
|
|
14
15
|
return (command, args, executeCommandContext) => __awaiter(this, void 0, void 0, function* () {
|
|
15
16
|
var _a, _b;
|
|
@@ -20,14 +20,13 @@ function register(context) {
|
|
|
20
20
|
var _a, _b;
|
|
21
21
|
return (_b = yield ((_a = plugin.findFileReferences) === null || _a === void 0 ? void 0 : _a.call(plugin, document))) !== null && _b !== void 0 ? _b : [];
|
|
22
22
|
}), (data) => data.map(reference => {
|
|
23
|
-
|
|
24
|
-
if (!map) {
|
|
23
|
+
if (!context.documents.getVirtualFileByUri(reference.uri)) {
|
|
25
24
|
return reference;
|
|
26
25
|
}
|
|
27
|
-
|
|
26
|
+
for (const [_, map] of context.documents.getMapsByVirtualFileUri(reference.uri)) {
|
|
28
27
|
const range = map.toSourceRange(reference.range);
|
|
29
28
|
if (range) {
|
|
30
|
-
reference.uri = map.
|
|
29
|
+
reference.uri = map.sourceFileDocument.uri;
|
|
31
30
|
reference.range = range;
|
|
32
31
|
return reference;
|
|
33
32
|
}
|
|
@@ -14,11 +14,11 @@ const dedupe = require("../utils/dedupe");
|
|
|
14
14
|
const language_core_1 = require("@volar/language-core");
|
|
15
15
|
function register(context) {
|
|
16
16
|
return (oldUri, newUri) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
17
|
+
const rootFile = context.documents.getRootFileBySourceFileUri(oldUri);
|
|
18
|
+
if (rootFile) {
|
|
19
19
|
let tsExt;
|
|
20
|
-
(0, language_core_1.
|
|
21
|
-
if (embedded.kind && embedded.fileName.replace(
|
|
20
|
+
(0, language_core_1.forEachEmbeddedFile)(rootFile, embedded => {
|
|
21
|
+
if (embedded.kind && embedded.fileName.replace(rootFile.fileName, '').match(/^\.(js|ts)x?$/)) {
|
|
22
22
|
tsExt = embedded.fileName.substring(embedded.fileName.lastIndexOf('.'));
|
|
23
23
|
}
|
|
24
24
|
});
|
|
@@ -5,10 +5,10 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
5
5
|
const common_1 = require("../utils/common");
|
|
6
6
|
function register(context) {
|
|
7
7
|
return (uri, position) => {
|
|
8
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position,
|
|
9
|
-
if (!
|
|
8
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.hover), (plugin, document, position) => { var _a; return (_a = plugin.doHover) === null || _a === void 0 ? void 0 : _a.call(plugin, document, position); }, (item, map) => {
|
|
9
|
+
if (!map || !item.range)
|
|
10
10
|
return item;
|
|
11
|
-
const range =
|
|
11
|
+
const range = map.toSourceRange(item.range);
|
|
12
12
|
if (range) {
|
|
13
13
|
item.range = range;
|
|
14
14
|
return item;
|
|
@@ -23,20 +23,20 @@ function register(context) {
|
|
|
23
23
|
start: document.offsetAt(range.start),
|
|
24
24
|
end: document.offsetAt(range.end),
|
|
25
25
|
};
|
|
26
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, range, (_arg,
|
|
26
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, range, (_arg, map, file) => {
|
|
27
27
|
/**
|
|
28
28
|
* copy from ./codeActions.ts
|
|
29
29
|
*/
|
|
30
30
|
var _a, _b;
|
|
31
|
-
if (!
|
|
31
|
+
if (!file.capabilities.inlayHint)
|
|
32
32
|
return [];
|
|
33
33
|
let minStart;
|
|
34
34
|
let maxEnd;
|
|
35
|
-
for (const mapping of
|
|
35
|
+
for (const mapping of map.map.mappings) {
|
|
36
36
|
const overlapRange = (0, common_1.getOverlapRange)(offsetRange.start, offsetRange.end, mapping.sourceRange[0], mapping.sourceRange[1]);
|
|
37
37
|
if (overlapRange) {
|
|
38
|
-
const start = (_a =
|
|
39
|
-
const end = (_b =
|
|
38
|
+
const start = (_a = map.map.toGeneratedOffset(overlapRange.start)) === null || _a === void 0 ? void 0 : _a[0];
|
|
39
|
+
const end = (_b = map.map.toGeneratedOffset(overlapRange.end)) === null || _b === void 0 ? void 0 : _b[0];
|
|
40
40
|
if (start !== undefined && end !== undefined) {
|
|
41
41
|
minStart = minStart === undefined ? start : Math.min(start, minStart);
|
|
42
42
|
maxEnd = maxEnd === undefined ? end : Math.max(end, maxEnd);
|
|
@@ -44,18 +44,18 @@ function register(context) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
if (minStart !== undefined && maxEnd !== undefined) {
|
|
47
|
-
return [vscode.Range.create(
|
|
47
|
+
return [vscode.Range.create(map.virtualFileDocument.positionAt(minStart), map.virtualFileDocument.positionAt(maxEnd))];
|
|
48
48
|
}
|
|
49
49
|
return [];
|
|
50
50
|
}, (plugin, document, arg) => {
|
|
51
51
|
var _a, _b;
|
|
52
52
|
return (_b = (_a = plugin.inlayHints) === null || _a === void 0 ? void 0 : _a.on) === null || _b === void 0 ? void 0 : _b.call(_a, document, arg);
|
|
53
|
-
}, (inlayHints,
|
|
53
|
+
}, (inlayHints, map) => inlayHints.map(_inlayHint => {
|
|
54
54
|
var _a;
|
|
55
|
-
if (!
|
|
55
|
+
if (!map)
|
|
56
56
|
return _inlayHint;
|
|
57
|
-
const position =
|
|
58
|
-
const edits = (_a = _inlayHint.textEdits) === null || _a === void 0 ? void 0 : _a.map(textEdit => (0, transforms_1.transformTextEdit)(textEdit, range =>
|
|
57
|
+
const position = map.toSourcePosition(_inlayHint.position);
|
|
58
|
+
const edits = (_a = _inlayHint.textEdits) === null || _a === void 0 ? void 0 : _a.map(textEdit => (0, transforms_1.transformTextEdit)(textEdit, range => map.toSourceRange(range))).filter(shared.notEmpty);
|
|
59
59
|
if (position) {
|
|
60
60
|
return Object.assign(Object.assign({}, _inlayHint), { position,
|
|
61
61
|
edits });
|
|
@@ -13,13 +13,13 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
13
13
|
const dedupe = require("../utils/dedupe");
|
|
14
14
|
function register(context) {
|
|
15
15
|
return (uri, position) => {
|
|
16
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position,
|
|
16
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.references), (plugin, document, position) => __awaiter(this, void 0, void 0, function* () {
|
|
17
17
|
const recursiveChecker = dedupe.createLocationSet();
|
|
18
18
|
const result = [];
|
|
19
|
-
yield
|
|
19
|
+
yield withMirrors(document, position);
|
|
20
20
|
return result;
|
|
21
|
-
function
|
|
22
|
-
var _a;
|
|
21
|
+
function withMirrors(document, position) {
|
|
22
|
+
var _a, _b;
|
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
24
|
if (!plugin.findReferences)
|
|
25
25
|
return;
|
|
@@ -28,20 +28,20 @@ function register(context) {
|
|
|
28
28
|
recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
|
|
29
29
|
const references = (_a = yield plugin.findReferences(document, position)) !== null && _a !== void 0 ? _a : [];
|
|
30
30
|
for (const reference of references) {
|
|
31
|
-
let
|
|
31
|
+
let foundMirrorPosition = false;
|
|
32
32
|
recursiveChecker.add({ uri: reference.uri, range: { start: reference.range.start, end: reference.range.start } });
|
|
33
|
-
const
|
|
34
|
-
if (
|
|
35
|
-
for (const mapped of
|
|
33
|
+
const mirrorMap = (_b = context.documents.getMirrorMapByUri(reference.uri)) === null || _b === void 0 ? void 0 : _b[1];
|
|
34
|
+
if (mirrorMap) {
|
|
35
|
+
for (const mapped of mirrorMap.findMirrorPositions(reference.range.start)) {
|
|
36
36
|
if (!mapped[1].references)
|
|
37
37
|
continue;
|
|
38
|
-
if (recursiveChecker.has({ uri:
|
|
38
|
+
if (recursiveChecker.has({ uri: mirrorMap.document.uri, range: { start: mapped[0], end: mapped[0] } }))
|
|
39
39
|
continue;
|
|
40
|
-
|
|
41
|
-
yield
|
|
40
|
+
foundMirrorPosition = true;
|
|
41
|
+
yield withMirrors(mirrorMap.document, mapped[0]);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
if (!
|
|
44
|
+
if (!foundMirrorPosition) {
|
|
45
45
|
result.push(reference);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
@@ -50,14 +50,15 @@ function register(context) {
|
|
|
50
50
|
}), (data) => {
|
|
51
51
|
const results = [];
|
|
52
52
|
for (const reference of data) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
53
|
+
if (context.documents.getVirtualFileByUri(reference.uri)) {
|
|
54
|
+
for (const [_, map] of context.documents.getMapsByVirtualFileUri(reference.uri)) {
|
|
55
|
+
const range = map.toSourceRange(reference.range, data => !!data.references);
|
|
56
|
+
if (range) {
|
|
57
|
+
results.push({
|
|
58
|
+
uri: map.sourceFileDocument.uri,
|
|
59
|
+
range,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
else {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServiceRuntimeContext } from '../types';
|
|
3
|
-
import {
|
|
3
|
+
import { DocumentsAndSourceMaps } from '../documents';
|
|
4
4
|
export declare function register(context: LanguageServiceRuntimeContext): (uri: string, position: vscode.Position, newName: string) => Promise<vscode.WorkspaceEdit | undefined>;
|
|
5
5
|
export declare function mergeWorkspaceEdits(original: vscode.WorkspaceEdit, ...others: vscode.WorkspaceEdit[]): void;
|
|
6
|
-
export declare function embeddedEditToSourceEdit(tsResult: vscode.WorkspaceEdit, vueDocuments:
|
|
6
|
+
export declare function embeddedEditToSourceEdit(tsResult: vscode.WorkspaceEdit, vueDocuments: DocumentsAndSourceMaps): vscode.WorkspaceEdit | undefined;
|