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