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