@volar/language-service 1.3.0-alpha.3 → 1.4.0-alpha.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 +37 -41
- package/out/baseLanguageService.js +26 -19
- package/out/documentFeatures/colorPresentations.d.ts +1 -1
- package/out/documentFeatures/colorPresentations.js +8 -4
- package/out/documentFeatures/documentColors.d.ts +1 -1
- package/out/documentFeatures/documentColors.js +8 -4
- package/out/documentFeatures/documentSymbols.d.ts +1 -1
- package/out/documentFeatures/documentSymbols.js +8 -15
- package/out/documentFeatures/foldingRanges.d.ts +2 -2
- package/out/documentFeatures/foldingRanges.js +6 -2
- package/out/documentFeatures/format.d.ts +2 -2
- package/out/documentFeatures/format.js +32 -39
- package/out/documentFeatures/linkedEditingRanges.d.ts +1 -1
- package/out/documentFeatures/linkedEditingRanges.js +8 -4
- package/out/documentFeatures/selectionRanges.d.ts +1 -1
- package/out/documentFeatures/selectionRanges.js +8 -4
- package/out/documents.js +3 -4
- package/out/index.d.ts +2 -0
- package/out/index.js +41 -1
- package/out/languageFeatures/autoInsert.d.ts +2 -2
- package/out/languageFeatures/autoInsert.js +12 -6
- package/out/languageFeatures/callHierarchy.d.ts +3 -3
- package/out/languageFeatures/callHierarchy.js +69 -76
- package/out/languageFeatures/codeActionResolve.d.ts +2 -2
- package/out/languageFeatures/codeActionResolve.js +10 -20
- package/out/languageFeatures/codeActions.d.ts +1 -1
- package/out/languageFeatures/codeActions.js +26 -31
- package/out/languageFeatures/codeLens.d.ts +1 -1
- package/out/languageFeatures/codeLens.js +19 -25
- package/out/languageFeatures/codeLensResolve.d.ts +1 -1
- package/out/languageFeatures/codeLensResolve.js +9 -19
- package/out/languageFeatures/complete.d.ts +1 -1
- package/out/languageFeatures/complete.js +35 -41
- package/out/languageFeatures/completeResolve.d.ts +1 -1
- package/out/languageFeatures/completeResolve.js +6 -17
- package/out/languageFeatures/definition.d.ts +1 -1
- package/out/languageFeatures/definition.js +41 -51
- package/out/languageFeatures/documentHighlights.d.ts +1 -1
- package/out/languageFeatures/documentHighlights.js +37 -44
- package/out/languageFeatures/documentLinks.d.ts +1 -1
- package/out/languageFeatures/documentLinks.js +13 -16
- package/out/languageFeatures/documentSemanticTokens.d.ts +1 -2
- package/out/languageFeatures/documentSemanticTokens.js +19 -8
- package/out/languageFeatures/fileReferences.d.ts +1 -1
- package/out/languageFeatures/fileReferences.js +8 -16
- package/out/languageFeatures/fileRename.d.ts +2 -1
- package/out/languageFeatures/fileRename.js +8 -16
- package/out/languageFeatures/hover.d.ts +1 -1
- package/out/languageFeatures/hover.js +10 -9
- package/out/languageFeatures/inlayHints.d.ts +1 -1
- package/out/languageFeatures/inlayHints.js +16 -21
- package/out/languageFeatures/references.d.ts +1 -1
- package/out/languageFeatures/references.js +29 -39
- package/out/languageFeatures/rename.d.ts +1 -1
- package/out/languageFeatures/rename.js +57 -69
- package/out/languageFeatures/renamePrepare.d.ts +1 -1
- package/out/languageFeatures/renamePrepare.js +6 -2
- package/out/languageFeatures/signatureHelp.d.ts +2 -2
- package/out/languageFeatures/signatureHelp.js +18 -2
- package/out/languageFeatures/validation.d.ts +1 -1
- package/out/languageFeatures/validation.js +143 -165
- package/out/languageFeatures/workspaceSymbols.d.ts +1 -1
- package/out/languageFeatures/workspaceSymbols.js +8 -15
- package/out/transformer/completionItem.js +9 -4
- package/out/transformer/completionList.js +6 -3
- package/out/transformer/documentSymbol.js +9 -4
- package/out/transformer/foldingRanges.js +2 -3
- package/out/transformer/hover.js +5 -2
- package/out/transformer/locationLike.js +4 -1
- package/out/transformer/locationsLike.js +2 -2
- package/out/transformer/selectionRanges.js +2 -2
- package/out/transformer/textEdit.js +20 -5
- package/out/transformer/workspaceSymbol.js +4 -1
- package/out/types.d.ts +56 -80
- package/out/types.js +0 -1
- package/out/utils/SemanticTokensBuilder.d.ts +13 -0
- package/out/utils/SemanticTokensBuilder.js +42 -0
- package/out/utils/common.d.ts +3 -0
- package/out/utils/common.js +25 -1
- package/out/utils/definePlugin.js +11 -23
- package/out/utils/featureWorkers.js +127 -155
- package/package.json +5 -6
|
@@ -1,35 +1,25 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
2
|
exports.register = exports.showReferencesCommand = void 0;
|
|
12
3
|
const references = require("./references");
|
|
13
4
|
exports.showReferencesCommand = `volar.${Math.random().toString(36).slice(2)}.show-references`;
|
|
14
5
|
function register(context) {
|
|
15
6
|
const findReferences = references.register(context);
|
|
16
|
-
return (item) =>
|
|
17
|
-
var _a, _b, _c;
|
|
7
|
+
return async (item, token) => {
|
|
18
8
|
const data = item.data;
|
|
19
|
-
if (
|
|
9
|
+
if (data?.kind === 'normal') {
|
|
20
10
|
const plugin = context.plugins[data.pluginId];
|
|
21
|
-
if (!
|
|
11
|
+
if (!plugin.resolveCodeLens)
|
|
22
12
|
return item;
|
|
23
13
|
Object.assign(item, data.original);
|
|
24
|
-
item =
|
|
14
|
+
item = await plugin.resolveCodeLens(item, token);
|
|
25
15
|
// item.range already transformed in codeLens request
|
|
26
16
|
}
|
|
27
|
-
if (
|
|
28
|
-
let references =
|
|
17
|
+
if (data?.kind === 'references') {
|
|
18
|
+
let references = await findReferences(data.uri, item.range.start, token) ?? [];
|
|
29
19
|
const plugin = context.plugins[data.pluginId];
|
|
30
20
|
const document = context.getTextDocument(data.uri);
|
|
31
|
-
if (document &&
|
|
32
|
-
references =
|
|
21
|
+
if (document && plugin.resolveReferencesCodeLens) {
|
|
22
|
+
references = await plugin.resolveReferencesCodeLens(document, data.location, references, token);
|
|
33
23
|
}
|
|
34
24
|
item.command = {
|
|
35
25
|
title: references.length === 1 ? '1 reference' : `${references.length} references`,
|
|
@@ -38,7 +28,7 @@ function register(context) {
|
|
|
38
28
|
};
|
|
39
29
|
}
|
|
40
30
|
return item;
|
|
41
|
-
}
|
|
31
|
+
};
|
|
42
32
|
}
|
|
43
33
|
exports.register = register;
|
|
44
34
|
//# sourceMappingURL=codeLensResolve.js.map
|
|
@@ -8,4 +8,4 @@ export interface PluginCompletionData {
|
|
|
8
8
|
embeddedDocumentUri: string;
|
|
9
9
|
} | undefined;
|
|
10
10
|
}
|
|
11
|
-
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position, completionContext
|
|
11
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position, completionContext: vscode.CompletionContext | undefined, token: vscode.CancellationToken) => Promise<vscode.CompletionList>;
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
2
|
exports.register = void 0;
|
|
12
3
|
const transformer = require("../transformer");
|
|
@@ -14,20 +5,22 @@ const vscode = require("vscode-languageserver-protocol");
|
|
|
14
5
|
const definePlugin_1 = require("../utils/definePlugin");
|
|
15
6
|
function register(context) {
|
|
16
7
|
let cache;
|
|
17
|
-
return (uri, position, completionContext) =>
|
|
18
|
-
|
|
8
|
+
return async (uri, position, completionContext, token) => {
|
|
9
|
+
completionContext ??= {
|
|
10
|
+
triggerKind: vscode.CompletionTriggerKind.Invoked,
|
|
11
|
+
};
|
|
19
12
|
let document;
|
|
20
|
-
if (
|
|
21
|
-
&&
|
|
13
|
+
if (completionContext?.triggerKind === vscode.CompletionTriggerKind.TriggerForIncompleteCompletions
|
|
14
|
+
&& cache?.uri === uri) {
|
|
22
15
|
for (const cacheData of cache.data) {
|
|
23
16
|
if (!cacheData.list.isIncomplete)
|
|
24
17
|
continue;
|
|
25
18
|
if (cacheData.map) {
|
|
26
19
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(cacheData.map.embeddedDocumentUri)) {
|
|
27
20
|
for (const mapped of map.toGeneratedPositions(position, data => !!data.completion)) {
|
|
28
|
-
if (!
|
|
21
|
+
if (!cacheData.plugin.provideCompletionItems)
|
|
29
22
|
continue;
|
|
30
|
-
const embeddedCompletionList =
|
|
23
|
+
const embeddedCompletionList = await cacheData.plugin.provideCompletionItems(map.virtualFileDocument, mapped, completionContext, token);
|
|
31
24
|
if (!embeddedCompletionList) {
|
|
32
25
|
cacheData.list.isIncomplete = false;
|
|
33
26
|
continue;
|
|
@@ -48,9 +41,9 @@ function register(context) {
|
|
|
48
41
|
}
|
|
49
42
|
}
|
|
50
43
|
else if (document = context.getTextDocument(uri)) {
|
|
51
|
-
if (!
|
|
44
|
+
if (!cacheData.plugin.provideCompletionItems)
|
|
52
45
|
continue;
|
|
53
|
-
const completionList =
|
|
46
|
+
const completionList = await cacheData.plugin.provideCompletionItems(document, position, completionContext, token);
|
|
54
47
|
if (!completionList) {
|
|
55
48
|
cacheData.list.isIncomplete = false;
|
|
56
49
|
continue;
|
|
@@ -71,7 +64,7 @@ function register(context) {
|
|
|
71
64
|
}
|
|
72
65
|
}
|
|
73
66
|
else {
|
|
74
|
-
const rootFile =
|
|
67
|
+
const rootFile = context.documents.getSourceByUri(uri)?.root;
|
|
75
68
|
cache = {
|
|
76
69
|
uri,
|
|
77
70
|
data: [],
|
|
@@ -80,8 +73,7 @@ function register(context) {
|
|
|
80
73
|
// monky fix https://github.com/johnsoncodehk/volar/issues/1358
|
|
81
74
|
let isFirstMapping = true;
|
|
82
75
|
if (rootFile) {
|
|
83
|
-
|
|
84
|
-
var _f, _g;
|
|
76
|
+
await (0, definePlugin_1.visitEmbedded)(context.documents, rootFile, async (_, map) => {
|
|
85
77
|
const plugins = Object.values(context.plugins).sort(sortPlugins);
|
|
86
78
|
let _data;
|
|
87
79
|
for (const mapped of map.toGeneratedPositions(position, data => {
|
|
@@ -89,22 +81,24 @@ function register(context) {
|
|
|
89
81
|
return !!data.completion;
|
|
90
82
|
})) {
|
|
91
83
|
for (const plugin of plugins) {
|
|
92
|
-
if (
|
|
84
|
+
if (token.isCancellationRequested)
|
|
85
|
+
break;
|
|
86
|
+
if (!plugin.provideCompletionItems)
|
|
93
87
|
continue;
|
|
94
|
-
if (plugin.
|
|
88
|
+
if (plugin.isAdditionalCompletion && !isFirstMapping)
|
|
95
89
|
continue;
|
|
96
|
-
if (
|
|
90
|
+
if (completionContext?.triggerCharacter && !plugin.triggerCharacters?.includes(completionContext.triggerCharacter))
|
|
97
91
|
continue;
|
|
98
|
-
const isAdditional = _data && typeof _data.completion === 'object' && _data.completion.additional || plugin.
|
|
99
|
-
if (cache.mainCompletion && (!isAdditional ||
|
|
92
|
+
const isAdditional = _data && typeof _data.completion === 'object' && _data.completion.additional || plugin.isAdditionalCompletion;
|
|
93
|
+
if (cache.mainCompletion && (!isAdditional || cache?.mainCompletion.documentUri !== map.virtualFileDocument.uri))
|
|
100
94
|
continue;
|
|
101
95
|
// avoid duplicate items with .vue and .vue.html
|
|
102
|
-
if (plugin.
|
|
96
|
+
if (plugin.isAdditionalCompletion && cache?.data.some(data => data.plugin === plugin))
|
|
103
97
|
continue;
|
|
104
|
-
const embeddedCompletionList =
|
|
98
|
+
const embeddedCompletionList = await plugin.provideCompletionItems(map.virtualFileDocument, mapped, completionContext, token);
|
|
105
99
|
if (!embeddedCompletionList || !embeddedCompletionList.items.length)
|
|
106
100
|
continue;
|
|
107
|
-
if (typeof
|
|
101
|
+
if (typeof _data?.completion === 'object' && _data.completion.autoImportOnly) {
|
|
108
102
|
embeddedCompletionList.items = embeddedCompletionList.items.filter(item => !!item.labelDetails);
|
|
109
103
|
}
|
|
110
104
|
if (!isAdditional) {
|
|
@@ -133,26 +127,28 @@ function register(context) {
|
|
|
133
127
|
isFirstMapping = false;
|
|
134
128
|
}
|
|
135
129
|
return true;
|
|
136
|
-
})
|
|
130
|
+
});
|
|
137
131
|
}
|
|
138
132
|
if (document = context.getTextDocument(uri)) {
|
|
139
133
|
const plugins = Object.values(context.plugins).sort(sortPlugins);
|
|
140
134
|
for (const plugin of plugins) {
|
|
141
|
-
if (
|
|
135
|
+
if (token.isCancellationRequested)
|
|
136
|
+
break;
|
|
137
|
+
if (!plugin.provideCompletionItems)
|
|
142
138
|
continue;
|
|
143
|
-
if (plugin.
|
|
139
|
+
if (plugin.isAdditionalCompletion && !isFirstMapping)
|
|
144
140
|
continue;
|
|
145
|
-
if (
|
|
141
|
+
if (completionContext?.triggerCharacter && !plugin.triggerCharacters?.includes(completionContext.triggerCharacter))
|
|
146
142
|
continue;
|
|
147
|
-
if (cache.mainCompletion && (!plugin.
|
|
143
|
+
if (cache.mainCompletion && (!plugin.isAdditionalCompletion || cache.mainCompletion.documentUri !== document.uri))
|
|
148
144
|
continue;
|
|
149
145
|
// avoid duplicate items with .vue and .vue.html
|
|
150
|
-
if (plugin.
|
|
146
|
+
if (plugin.isAdditionalCompletion && cache?.data.some(data => data.plugin === plugin))
|
|
151
147
|
continue;
|
|
152
|
-
const completionList =
|
|
148
|
+
const completionList = await plugin.provideCompletionItems(document, position, completionContext, token);
|
|
153
149
|
if (!completionList || !completionList.items.length)
|
|
154
150
|
continue;
|
|
155
|
-
if (!plugin.
|
|
151
|
+
if (!plugin.isAdditionalCompletion) {
|
|
156
152
|
cache.mainCompletion = { documentUri: document.uri };
|
|
157
153
|
}
|
|
158
154
|
completionList.items.forEach(item => {
|
|
@@ -177,18 +173,16 @@ function register(context) {
|
|
|
177
173
|
}
|
|
178
174
|
return combineCompletionList(cache.data.map(cacheData => cacheData.list));
|
|
179
175
|
function sortPlugins(a, b) {
|
|
180
|
-
|
|
181
|
-
return (((_a = b.complete) === null || _a === void 0 ? void 0 : _a.isAdditional) ? -1 : 1) - (((_b = a.complete) === null || _b === void 0 ? void 0 : _b.isAdditional) ? -1 : 1);
|
|
176
|
+
return (b.isAdditionalCompletion ? -1 : 1) - (a.isAdditionalCompletion ? -1 : 1);
|
|
182
177
|
}
|
|
183
178
|
function combineCompletionList(lists) {
|
|
184
|
-
var _a;
|
|
185
179
|
return {
|
|
186
180
|
isIncomplete: lists.some(list => list.isIncomplete),
|
|
187
|
-
itemDefaults:
|
|
181
|
+
itemDefaults: lists.find(list => list.itemDefaults)?.itemDefaults,
|
|
188
182
|
items: lists.map(list => list.items).flat(),
|
|
189
183
|
};
|
|
190
184
|
}
|
|
191
|
-
}
|
|
185
|
+
};
|
|
192
186
|
}
|
|
193
187
|
exports.register = register;
|
|
194
188
|
//# sourceMappingURL=complete.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
-
export declare function register(context: LanguageServicePluginContext): (item: vscode.CompletionItem) => Promise<vscode.CompletionItem>;
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (item: vscode.CompletionItem, token: vscode.CancellationToken) => Promise<vscode.CompletionItem>;
|
|
@@ -1,30 +1,19 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
2
|
exports.register = void 0;
|
|
12
3
|
const transformer = require("../transformer");
|
|
13
4
|
function register(context) {
|
|
14
|
-
return (item) =>
|
|
15
|
-
var _a;
|
|
5
|
+
return async (item, token) => {
|
|
16
6
|
const data = item.data;
|
|
17
7
|
if (data) {
|
|
18
8
|
const plugin = context.plugins[data.pluginId];
|
|
19
|
-
if (!
|
|
9
|
+
if (!plugin.resolveCompletionItem)
|
|
20
10
|
return item;
|
|
21
11
|
item = Object.assign(item, data.original);
|
|
22
12
|
if (data.map) {
|
|
23
13
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(data.map.embeddedDocumentUri)) {
|
|
24
|
-
item =
|
|
14
|
+
item = await plugin.resolveCompletionItem(item, token);
|
|
25
15
|
item = transformer.asCompletionItem(item, embeddedRange => {
|
|
26
|
-
|
|
27
|
-
let range = (_a = plugin.resolveEmbeddedRange) === null || _a === void 0 ? void 0 : _a.call(plugin, embeddedRange);
|
|
16
|
+
let range = plugin.resolveEmbeddedRange?.(embeddedRange);
|
|
28
17
|
if (range)
|
|
29
18
|
return range;
|
|
30
19
|
return map.toSourceRange(embeddedRange);
|
|
@@ -32,7 +21,7 @@ function register(context) {
|
|
|
32
21
|
}
|
|
33
22
|
}
|
|
34
23
|
else {
|
|
35
|
-
item =
|
|
24
|
+
item = await plugin.resolveCompletionItem(item, token);
|
|
36
25
|
}
|
|
37
26
|
}
|
|
38
27
|
// TODO: monkey fix import ts file icon
|
|
@@ -40,7 +29,7 @@ function register(context) {
|
|
|
40
29
|
item.detail = item.detail;
|
|
41
30
|
}
|
|
42
31
|
return item;
|
|
43
|
-
}
|
|
32
|
+
};
|
|
44
33
|
}
|
|
45
34
|
exports.register = register;
|
|
46
35
|
//# sourceMappingURL=completeResolve.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
3
3
|
import { FileRangeCapabilities, MirrorBehaviorCapabilities } from '@volar/language-core';
|
|
4
|
-
export declare function register(context: LanguageServicePluginContext,
|
|
4
|
+
export declare function register(context: LanguageServicePluginContext, apiName: 'provideDefinition' | 'provideTypeDefinition' | 'provideImplementation', isValidMapping: (data: FileRangeCapabilities) => boolean, isValidMirrorPosition: (mirrorData: MirrorBehaviorCapabilities) => boolean): (uri: string, position: vscode.Position, token: vscode.CancellationToken) => Promise<vscode.LocationLink[] | undefined>;
|
|
@@ -1,63 +1,53 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
2
|
exports.register = void 0;
|
|
12
|
-
const shared = require("@volar/shared");
|
|
13
3
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
14
4
|
const dedupe = require("../utils/dedupe");
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
const common_1 = require("../utils/common");
|
|
6
|
+
function register(context, apiName, isValidMapping, isValidMirrorPosition) {
|
|
7
|
+
return (uri, position, token) => {
|
|
8
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, isValidMapping), async (plugin, document, position) => {
|
|
9
|
+
if (token.isCancellationRequested)
|
|
10
|
+
return;
|
|
18
11
|
const recursiveChecker = dedupe.createLocationSet();
|
|
19
12
|
const result = [];
|
|
20
|
-
|
|
13
|
+
await withMirrors(document, position, undefined);
|
|
21
14
|
return result;
|
|
22
|
-
function withMirrors(document, position, originDefinition) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
15
|
+
async function withMirrors(document, position, originDefinition) {
|
|
16
|
+
const api = plugin[apiName];
|
|
17
|
+
if (!api)
|
|
18
|
+
return;
|
|
19
|
+
if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } }))
|
|
20
|
+
return;
|
|
21
|
+
recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
|
|
22
|
+
const definitions = await api?.(document, position, token) ?? [];
|
|
23
|
+
for (const definition of definitions) {
|
|
24
|
+
let foundMirrorPosition = false;
|
|
25
|
+
recursiveChecker.add({ uri: definition.targetUri, range: { start: definition.targetRange.start, end: definition.targetRange.start } });
|
|
26
|
+
const mirrorMap = context.documents.getMirrorMapByUri(definition.targetUri)?.[1];
|
|
27
|
+
if (mirrorMap) {
|
|
28
|
+
for (const mapped of mirrorMap.findMirrorPositions(definition.targetSelectionRange.start)) {
|
|
29
|
+
if (!isValidMirrorPosition(mapped[1]))
|
|
30
|
+
continue;
|
|
31
|
+
if (recursiveChecker.has({ uri: mirrorMap.document.uri, range: { start: mapped[0], end: mapped[0] } }))
|
|
32
|
+
continue;
|
|
33
|
+
foundMirrorPosition = true;
|
|
34
|
+
await withMirrors(mirrorMap.document, mapped[0], originDefinition ?? definition);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (!foundMirrorPosition) {
|
|
38
|
+
if (originDefinition) {
|
|
39
|
+
result.push({
|
|
40
|
+
...definition,
|
|
41
|
+
originSelectionRange: originDefinition.originSelectionRange,
|
|
42
|
+
});
|
|
48
43
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
result.push(Object.assign(Object.assign({}, definition), { originSelectionRange: originDefinition.originSelectionRange }));
|
|
52
|
-
}
|
|
53
|
-
else {
|
|
54
|
-
result.push(definition);
|
|
55
|
-
}
|
|
44
|
+
else {
|
|
45
|
+
result.push(definition);
|
|
56
46
|
}
|
|
57
47
|
}
|
|
58
|
-
}
|
|
48
|
+
}
|
|
59
49
|
}
|
|
60
|
-
}
|
|
50
|
+
}, (data, sourceMap) => data.map(link => {
|
|
61
51
|
if (link.originSelectionRange && sourceMap) {
|
|
62
52
|
const originSelectionRange = toSourcePositionPreferSurroundedPosition(sourceMap, link.originSelectionRange, position);
|
|
63
53
|
if (!originSelectionRange)
|
|
@@ -73,14 +63,14 @@ function register(context, api, isValidMapping, isValidMirrorPosition) {
|
|
|
73
63
|
let targetRange = targetSourceMap.toSourceRange(link.targetRange);
|
|
74
64
|
link.targetUri = targetSourceMap.sourceFileDocument.uri;
|
|
75
65
|
// loose range mapping to for template slots, slot properties
|
|
76
|
-
link.targetRange = targetRange
|
|
66
|
+
link.targetRange = targetRange ?? targetSelectionRange;
|
|
77
67
|
link.targetSelectionRange = targetSelectionRange;
|
|
78
68
|
}
|
|
79
69
|
if (context.documents.hasVirtualFileByUri(link.targetUri) && !foundTargetSelectionRange) {
|
|
80
70
|
return;
|
|
81
71
|
}
|
|
82
72
|
return link;
|
|
83
|
-
}).filter(
|
|
73
|
+
}).filter(common_1.notEmpty), arr => dedupe.withLocationLinks(arr.flat()));
|
|
84
74
|
};
|
|
85
75
|
}
|
|
86
76
|
exports.register = register;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
-
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position) => Promise<vscode.DocumentHighlight[] | undefined>;
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, position: vscode.Position, token: vscode.CancellationToken) => Promise<vscode.DocumentHighlight[] | undefined>;
|
|
@@ -1,63 +1,56 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
2
|
exports.register = void 0;
|
|
12
|
-
const shared = require("@volar/shared");
|
|
13
3
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
14
4
|
const dedupe = require("../utils/dedupe");
|
|
5
|
+
const common_1 = require("../utils/common");
|
|
15
6
|
function register(context) {
|
|
16
|
-
return (uri, position) => {
|
|
7
|
+
return (uri, position, token) => {
|
|
17
8
|
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position,
|
|
18
9
|
// note https://github.com/johnsoncodehk/volar/issues/2009
|
|
19
|
-
data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename), (plugin, document, position) =>
|
|
10
|
+
data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename), async (plugin, document, position) => {
|
|
11
|
+
if (token.isCancellationRequested)
|
|
12
|
+
return;
|
|
20
13
|
const recursiveChecker = dedupe.createLocationSet();
|
|
21
14
|
const result = [];
|
|
22
|
-
|
|
15
|
+
await withMirrors(document, position);
|
|
23
16
|
return result;
|
|
24
|
-
function withMirrors(document, position) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
foundMirrorPosition = true;
|
|
44
|
-
yield withMirrors(mirrorMap.document, mapped[0]);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (!foundMirrorPosition) {
|
|
48
|
-
result.push(reference);
|
|
17
|
+
async function withMirrors(document, position) {
|
|
18
|
+
if (!plugin.provideDocumentHighlights)
|
|
19
|
+
return;
|
|
20
|
+
if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } }))
|
|
21
|
+
return;
|
|
22
|
+
recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
|
|
23
|
+
const references = await plugin.provideDocumentHighlights(document, position, token) ?? [];
|
|
24
|
+
for (const reference of references) {
|
|
25
|
+
let foundMirrorPosition = false;
|
|
26
|
+
recursiveChecker.add({ uri: document.uri, range: { start: reference.range.start, end: reference.range.start } });
|
|
27
|
+
const mirrorMap = context.documents.getMirrorMapByUri(document.uri)?.[1];
|
|
28
|
+
if (mirrorMap) {
|
|
29
|
+
for (const mapped of mirrorMap.findMirrorPositions(reference.range.start)) {
|
|
30
|
+
if (!mapped[1].references)
|
|
31
|
+
continue;
|
|
32
|
+
if (recursiveChecker.has({ uri: mirrorMap.document.uri, range: { start: mapped[0], end: mapped[0] } }))
|
|
33
|
+
continue;
|
|
34
|
+
foundMirrorPosition = true;
|
|
35
|
+
await withMirrors(mirrorMap.document, mapped[0]);
|
|
49
36
|
}
|
|
50
37
|
}
|
|
51
|
-
|
|
38
|
+
if (!foundMirrorPosition) {
|
|
39
|
+
result.push(reference);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
52
42
|
}
|
|
53
|
-
}
|
|
43
|
+
}, (data, map) => data.map(highlight => {
|
|
54
44
|
if (!map)
|
|
55
|
-
return
|
|
56
|
-
const range = map.toSourceRange(
|
|
45
|
+
return highlight;
|
|
46
|
+
const range = map.toSourceRange(highlight.range);
|
|
57
47
|
if (range) {
|
|
58
|
-
return
|
|
48
|
+
return {
|
|
49
|
+
...highlight,
|
|
50
|
+
range,
|
|
51
|
+
};
|
|
59
52
|
}
|
|
60
|
-
}).filter(
|
|
53
|
+
}).filter(common_1.notEmpty), arr => arr.flat());
|
|
61
54
|
};
|
|
62
55
|
}
|
|
63
56
|
exports.register = register;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
3
|
-
export declare function register(context: LanguageServicePluginContext): (uri: string) => Promise<vscode.DocumentLink[]>;
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, token: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
|
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
1
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
2
|
exports.register = void 0;
|
|
12
|
-
const shared = require("@volar/shared");
|
|
13
3
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
4
|
+
const common_1 = require("../utils/common");
|
|
14
5
|
function register(context) {
|
|
15
|
-
return (uri) =>
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
return async (uri, token) => {
|
|
7
|
+
const pluginLinks = await (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, (plugin, document) => {
|
|
8
|
+
if (token.isCancellationRequested)
|
|
9
|
+
return;
|
|
10
|
+
return plugin.provideLinks?.(document, token);
|
|
11
|
+
}, (data, map) => data.map(link => {
|
|
18
12
|
if (!map)
|
|
19
13
|
return link;
|
|
20
14
|
const range = map.toSourceRange(link.range);
|
|
21
15
|
if (range) {
|
|
22
|
-
return
|
|
16
|
+
return {
|
|
17
|
+
...link,
|
|
18
|
+
range,
|
|
19
|
+
};
|
|
23
20
|
}
|
|
24
|
-
}).filter(
|
|
21
|
+
}).filter(common_1.notEmpty), arr => arr.flat()) ?? [];
|
|
25
22
|
const maps = context.documents.getMapsBySourceFileUri(uri);
|
|
26
23
|
const fictitiousLinks = maps ? getFictitiousLinks(context.documents.getDocumentByUri(maps.snapshot, uri), maps.maps) : [];
|
|
27
24
|
return [
|
|
@@ -47,7 +44,7 @@ function register(context) {
|
|
|
47
44
|
}
|
|
48
45
|
return result;
|
|
49
46
|
}
|
|
50
|
-
}
|
|
47
|
+
};
|
|
51
48
|
}
|
|
52
49
|
exports.register = register;
|
|
53
50
|
//# sourceMappingURL=documentLinks.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import { SemanticToken } from '@volar/language-service';
|
|
3
2
|
import type { LanguageServicePluginContext } from '../types';
|
|
4
|
-
export declare function register(context: LanguageServicePluginContext): (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend,
|
|
3
|
+
export declare function register(context: LanguageServicePluginContext): (uri: string, range: vscode.Range | undefined, legend: vscode.SemanticTokensLegend, token: vscode.CancellationToken, reportProgress?: ((tokens: vscode.SemanticTokens) => void) | undefined) => Promise<vscode.SemanticTokens | undefined>;
|