@volar/language-service 1.5.0 → 1.5.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 +2 -2
- package/out/baseLanguageService.js +7 -7
- package/out/documentFeatures/colorPresentations.js +2 -2
- package/out/documentFeatures/documentColors.js +2 -2
- package/out/documentFeatures/documentSymbols.js +2 -2
- package/out/documentFeatures/foldingRanges.js +2 -2
- package/out/documentFeatures/format.js +9 -9
- package/out/documentFeatures/linkedEditingRanges.js +2 -2
- package/out/documentFeatures/selectionRanges.js +2 -2
- package/out/languageFeatures/autoInsert.js +2 -2
- package/out/languageFeatures/callHierarchy.d.ts +1 -1
- package/out/languageFeatures/callHierarchy.js +11 -11
- package/out/languageFeatures/codeActionResolve.js +4 -4
- package/out/languageFeatures/codeActions.d.ts +3 -3
- package/out/languageFeatures/codeActions.js +8 -9
- package/out/languageFeatures/codeLens.d.ts +4 -4
- package/out/languageFeatures/codeLens.js +6 -6
- package/out/languageFeatures/codeLensResolve.js +6 -6
- package/out/languageFeatures/complete.d.ts +2 -2
- package/out/languageFeatures/complete.js +28 -28
- package/out/languageFeatures/completeResolve.js +5 -5
- package/out/languageFeatures/definition.js +2 -2
- package/out/languageFeatures/documentHighlights.js +3 -3
- package/out/languageFeatures/documentLinkResolve.js +3 -3
- package/out/languageFeatures/documentLinks.d.ts +1 -1
- package/out/languageFeatures/documentLinks.js +3 -3
- package/out/languageFeatures/documentSemanticTokens.js +2 -2
- package/out/languageFeatures/fileReferences.js +2 -2
- package/out/languageFeatures/fileRename.js +3 -3
- package/out/languageFeatures/hover.js +2 -2
- package/out/languageFeatures/inlayHintResolve.js +3 -3
- package/out/languageFeatures/inlayHints.d.ts +1 -1
- package/out/languageFeatures/inlayHints.js +3 -3
- package/out/languageFeatures/references.js +3 -3
- package/out/languageFeatures/rename.js +18 -7
- package/out/languageFeatures/renamePrepare.js +2 -2
- package/out/languageFeatures/signatureHelp.js +4 -4
- package/out/languageFeatures/validation.d.ts +4 -4
- package/out/languageFeatures/validation.js +28 -27
- package/out/languageFeatures/workspaceSymbols.js +3 -3
- package/out/types.d.ts +23 -18
- package/out/types.js +8 -0
- package/out/utils/featureWorkers.d.ts +2 -2
- package/out/utils/featureWorkers.js +48 -49
- package/package.json +4 -4
|
@@ -16,9 +16,9 @@ function register(context) {
|
|
|
16
16
|
if (cacheData.virtualDocumentUri) {
|
|
17
17
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(cacheData.virtualDocumentUri)) {
|
|
18
18
|
for (const mapped of map.toGeneratedPositions(position, data => !!data.completion)) {
|
|
19
|
-
if (!cacheData.
|
|
19
|
+
if (!cacheData.service.provideCompletionItems)
|
|
20
20
|
continue;
|
|
21
|
-
const embeddedCompletionList = await cacheData.
|
|
21
|
+
const embeddedCompletionList = await cacheData.service.provideCompletionItems(map.virtualFileDocument, mapped, completionContext, token);
|
|
22
22
|
if (!embeddedCompletionList) {
|
|
23
23
|
cacheData.list.isIncomplete = false;
|
|
24
24
|
continue;
|
|
@@ -30,16 +30,16 @@ function register(context) {
|
|
|
30
30
|
textEdit: oldItem.textEdit,
|
|
31
31
|
data: oldItem.data,
|
|
32
32
|
},
|
|
33
|
-
|
|
33
|
+
serviceId: Object.keys(context.services).find(key => context.services[key] === cacheData.service),
|
|
34
34
|
virtualDocumentUri: map.virtualFileDocument.uri,
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
else if (document = context.getTextDocument(uri)) {
|
|
40
|
-
if (!cacheData.
|
|
40
|
+
if (!cacheData.service.provideCompletionItems)
|
|
41
41
|
continue;
|
|
42
|
-
const completionList = await cacheData.
|
|
42
|
+
const completionList = await cacheData.service.provideCompletionItems(document, position, completionContext, token);
|
|
43
43
|
if (!completionList) {
|
|
44
44
|
cacheData.list.isIncomplete = false;
|
|
45
45
|
continue;
|
|
@@ -52,7 +52,7 @@ function register(context) {
|
|
|
52
52
|
textEdit: item.textEdit,
|
|
53
53
|
data: item.data,
|
|
54
54
|
},
|
|
55
|
-
|
|
55
|
+
serviceId: Object.keys(context.services).find(key => context.services[key] === cacheData.service),
|
|
56
56
|
virtualDocumentUri: undefined,
|
|
57
57
|
};
|
|
58
58
|
});
|
|
@@ -70,28 +70,28 @@ function register(context) {
|
|
|
70
70
|
let isFirstMapping = true;
|
|
71
71
|
if (rootFile) {
|
|
72
72
|
await (0, definePlugin_1.visitEmbedded)(context.documents, rootFile, async (_, map) => {
|
|
73
|
-
const
|
|
73
|
+
const services = Object.values(context.services).sort(sortServices);
|
|
74
74
|
let _data;
|
|
75
75
|
for (const mapped of map.toGeneratedPositions(position, data => {
|
|
76
76
|
_data = data;
|
|
77
77
|
return !!data.completion;
|
|
78
78
|
})) {
|
|
79
|
-
for (const
|
|
79
|
+
for (const service of services) {
|
|
80
80
|
if (token.isCancellationRequested)
|
|
81
81
|
break;
|
|
82
|
-
if (!
|
|
82
|
+
if (!service.provideCompletionItems)
|
|
83
83
|
continue;
|
|
84
|
-
if (
|
|
84
|
+
if (service.isAdditionalCompletion && !isFirstMapping)
|
|
85
85
|
continue;
|
|
86
|
-
if (completionContext?.triggerCharacter && !
|
|
86
|
+
if (completionContext?.triggerCharacter && !service.triggerCharacters?.includes(completionContext.triggerCharacter))
|
|
87
87
|
continue;
|
|
88
|
-
const isAdditional = _data && typeof _data.completion === 'object' && _data.completion.additional ||
|
|
88
|
+
const isAdditional = _data && typeof _data.completion === 'object' && _data.completion.additional || service.isAdditionalCompletion;
|
|
89
89
|
if (cache.mainCompletion && (!isAdditional || cache?.mainCompletion.documentUri !== map.virtualFileDocument.uri))
|
|
90
90
|
continue;
|
|
91
91
|
// avoid duplicate items with .vue and .vue.html
|
|
92
|
-
if (
|
|
92
|
+
if (service.isAdditionalCompletion && cache?.data.some(data => data.service === service))
|
|
93
93
|
continue;
|
|
94
|
-
const embeddedCompletionList = await
|
|
94
|
+
const embeddedCompletionList = await service.provideCompletionItems(map.virtualFileDocument, mapped, completionContext, token);
|
|
95
95
|
if (!embeddedCompletionList || !embeddedCompletionList.items.length)
|
|
96
96
|
continue;
|
|
97
97
|
if (typeof _data?.completion === 'object' && _data.completion.autoImportOnly) {
|
|
@@ -107,12 +107,12 @@ function register(context) {
|
|
|
107
107
|
textEdit: oldItem.textEdit,
|
|
108
108
|
data: oldItem.data,
|
|
109
109
|
},
|
|
110
|
-
|
|
110
|
+
serviceId: Object.keys(context.services).find(key => context.services[key] === service),
|
|
111
111
|
virtualDocumentUri: map.virtualFileDocument.uri,
|
|
112
112
|
});
|
|
113
113
|
cache.data.push({
|
|
114
114
|
virtualDocumentUri: map.virtualFileDocument.uri,
|
|
115
|
-
|
|
115
|
+
service: service,
|
|
116
116
|
list: completionList,
|
|
117
117
|
});
|
|
118
118
|
}
|
|
@@ -122,25 +122,25 @@ function register(context) {
|
|
|
122
122
|
});
|
|
123
123
|
}
|
|
124
124
|
if (document = context.getTextDocument(uri)) {
|
|
125
|
-
const
|
|
126
|
-
for (const
|
|
125
|
+
const services = Object.values(context.services).sort(sortServices);
|
|
126
|
+
for (const service of services) {
|
|
127
127
|
if (token.isCancellationRequested)
|
|
128
128
|
break;
|
|
129
|
-
if (!
|
|
129
|
+
if (!service.provideCompletionItems)
|
|
130
130
|
continue;
|
|
131
|
-
if (
|
|
131
|
+
if (service.isAdditionalCompletion && !isFirstMapping)
|
|
132
132
|
continue;
|
|
133
|
-
if (completionContext?.triggerCharacter && !
|
|
133
|
+
if (completionContext?.triggerCharacter && !service.triggerCharacters?.includes(completionContext.triggerCharacter))
|
|
134
134
|
continue;
|
|
135
|
-
if (cache.mainCompletion && (!
|
|
135
|
+
if (cache.mainCompletion && (!service.isAdditionalCompletion || cache.mainCompletion.documentUri !== document.uri))
|
|
136
136
|
continue;
|
|
137
137
|
// avoid duplicate items with .vue and .vue.html
|
|
138
|
-
if (
|
|
138
|
+
if (service.isAdditionalCompletion && cache?.data.some(data => data.service === service))
|
|
139
139
|
continue;
|
|
140
|
-
const completionList = await
|
|
140
|
+
const completionList = await service.provideCompletionItems(document, position, completionContext, token);
|
|
141
141
|
if (!completionList || !completionList.items.length)
|
|
142
142
|
continue;
|
|
143
|
-
if (!
|
|
143
|
+
if (!service.isAdditionalCompletion) {
|
|
144
144
|
cache.mainCompletion = { documentUri: document.uri };
|
|
145
145
|
}
|
|
146
146
|
completionList.items.forEach(item => {
|
|
@@ -151,20 +151,20 @@ function register(context) {
|
|
|
151
151
|
textEdit: item.textEdit,
|
|
152
152
|
data: item.data,
|
|
153
153
|
},
|
|
154
|
-
|
|
154
|
+
serviceId: Object.keys(context.services).find(key => context.services[key] === service),
|
|
155
155
|
virtualDocumentUri: undefined,
|
|
156
156
|
};
|
|
157
157
|
});
|
|
158
158
|
cache.data.push({
|
|
159
159
|
virtualDocumentUri: undefined,
|
|
160
|
-
|
|
160
|
+
service: service,
|
|
161
161
|
list: completionList,
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
166
|
return combineCompletionList(cache.data.map(cacheData => cacheData.list));
|
|
167
|
-
function
|
|
167
|
+
function sortServices(a, b) {
|
|
168
168
|
return (b.isAdditionalCompletion ? -1 : 1) - (a.isAdditionalCompletion ? -1 : 1);
|
|
169
169
|
}
|
|
170
170
|
function combineCompletionList(lists) {
|
|
@@ -7,15 +7,15 @@ function register(context) {
|
|
|
7
7
|
return async (item, token = vscode.CancellationToken.None) => {
|
|
8
8
|
const data = item.data;
|
|
9
9
|
if (data) {
|
|
10
|
-
const
|
|
11
|
-
if (!
|
|
10
|
+
const service = context.services[data.serviceId];
|
|
11
|
+
if (!service.resolveCompletionItem)
|
|
12
12
|
return item;
|
|
13
13
|
item = Object.assign(item, data.original);
|
|
14
14
|
if (data.virtualDocumentUri) {
|
|
15
15
|
for (const [_, map] of context.documents.getMapsByVirtualFileUri(data.virtualDocumentUri)) {
|
|
16
|
-
item = await
|
|
16
|
+
item = await service.resolveCompletionItem(item, token);
|
|
17
17
|
item = transformer.asCompletionItem(item, embeddedRange => {
|
|
18
|
-
let range =
|
|
18
|
+
let range = service.resolveEmbeddedRange?.(embeddedRange);
|
|
19
19
|
if (range)
|
|
20
20
|
return range;
|
|
21
21
|
return map.toSourceRange(embeddedRange);
|
|
@@ -23,7 +23,7 @@ function register(context) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
else {
|
|
26
|
-
item = await
|
|
26
|
+
item = await service.resolveCompletionItem(item, token);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
// TODO: monkey fix import ts file icon
|
|
@@ -7,7 +7,7 @@ const dedupe = require("../utils/dedupe");
|
|
|
7
7
|
const common_1 = require("../utils/common");
|
|
8
8
|
function register(context, apiName, isValidMapping, isValidMirrorPosition) {
|
|
9
9
|
return (uri, position, token = vscode.CancellationToken.None) => {
|
|
10
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, isValidMapping), async (
|
|
10
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, isValidMapping), async (service, document, position) => {
|
|
11
11
|
if (token.isCancellationRequested)
|
|
12
12
|
return;
|
|
13
13
|
const recursiveChecker = dedupe.createLocationSet();
|
|
@@ -15,7 +15,7 @@ function register(context, apiName, isValidMapping, isValidMirrorPosition) {
|
|
|
15
15
|
await withMirrors(document, position, undefined);
|
|
16
16
|
return result;
|
|
17
17
|
async function withMirrors(document, position, originDefinition) {
|
|
18
|
-
const api =
|
|
18
|
+
const api = service[apiName];
|
|
19
19
|
if (!api)
|
|
20
20
|
return;
|
|
21
21
|
if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } }))
|
|
@@ -9,7 +9,7 @@ function register(context) {
|
|
|
9
9
|
return (uri, position, token = vscode.CancellationToken.None) => {
|
|
10
10
|
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position,
|
|
11
11
|
// note https://github.com/johnsoncodehk/volar/issues/2009
|
|
12
|
-
data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename), async (
|
|
12
|
+
data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename), async (service, document, position) => {
|
|
13
13
|
if (token.isCancellationRequested)
|
|
14
14
|
return;
|
|
15
15
|
const recursiveChecker = dedupe.createLocationSet();
|
|
@@ -17,12 +17,12 @@ function register(context) {
|
|
|
17
17
|
await withMirrors(document, position);
|
|
18
18
|
return result;
|
|
19
19
|
async function withMirrors(document, position) {
|
|
20
|
-
if (!
|
|
20
|
+
if (!service.provideDocumentHighlights)
|
|
21
21
|
return;
|
|
22
22
|
if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } }))
|
|
23
23
|
return;
|
|
24
24
|
recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
|
|
25
|
-
const references = await
|
|
25
|
+
const references = await service.provideDocumentHighlights(document, position, token) ?? [];
|
|
26
26
|
for (const reference of references) {
|
|
27
27
|
let foundMirrorPosition = false;
|
|
28
28
|
recursiveChecker.add({ uri: document.uri, range: { start: reference.range.start, end: reference.range.start } });
|
|
@@ -6,11 +6,11 @@ function register(context) {
|
|
|
6
6
|
return async (item, token = vscode.CancellationToken.None) => {
|
|
7
7
|
const data = item.data;
|
|
8
8
|
if (data) {
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
9
|
+
const service = context.services[data.serviceId];
|
|
10
|
+
if (!service.resolveDocumentLink)
|
|
11
11
|
return item;
|
|
12
12
|
Object.assign(item, data.original);
|
|
13
|
-
item = await
|
|
13
|
+
item = await service.resolveDocumentLink(item, token);
|
|
14
14
|
}
|
|
15
15
|
return item;
|
|
16
16
|
};
|
|
@@ -3,6 +3,6 @@ import type { ServiceContext } from '../types';
|
|
|
3
3
|
export interface DocumentLinkData {
|
|
4
4
|
uri: string;
|
|
5
5
|
original: Pick<vscode.DocumentLink, 'data'>;
|
|
6
|
-
|
|
6
|
+
serviceId: string;
|
|
7
7
|
}
|
|
8
8
|
export declare function register(context: ServiceContext): (uri: string, token?: vscode.CancellationToken) => Promise<vscode.DocumentLink[]>;
|
|
@@ -6,17 +6,17 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
6
6
|
const common_1 = require("../utils/common");
|
|
7
7
|
function register(context) {
|
|
8
8
|
return async (uri, token = vscode.CancellationToken.None) => {
|
|
9
|
-
const pluginLinks = await (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, async (
|
|
9
|
+
const pluginLinks = await (0, featureWorkers_1.documentFeatureWorker)(context, uri, file => !!file.capabilities.documentSymbol, async (service, document) => {
|
|
10
10
|
if (token.isCancellationRequested)
|
|
11
11
|
return;
|
|
12
|
-
const links = await
|
|
12
|
+
const links = await service.provideDocumentLinks?.(document, token);
|
|
13
13
|
links?.forEach(link => {
|
|
14
14
|
link.data = {
|
|
15
15
|
uri,
|
|
16
16
|
original: {
|
|
17
17
|
data: link.data,
|
|
18
18
|
},
|
|
19
|
-
|
|
19
|
+
serviceId: Object.keys(context.services).find(key => context.services[key] === service),
|
|
20
20
|
};
|
|
21
21
|
});
|
|
22
22
|
return links;
|
|
@@ -35,10 +35,10 @@ function register(context) {
|
|
|
35
35
|
if (range) {
|
|
36
36
|
yield range;
|
|
37
37
|
}
|
|
38
|
-
}, (
|
|
38
|
+
}, (service, document, offsetRange) => {
|
|
39
39
|
if (token?.isCancellationRequested)
|
|
40
40
|
return;
|
|
41
|
-
return
|
|
41
|
+
return service.provideDocumentSemanticTokens?.(document, vscode.Range.create(document.positionAt(offsetRange[0]), document.positionAt(offsetRange[1])), legend, token);
|
|
42
42
|
}, (tokens, map) => tokens.map(_token => {
|
|
43
43
|
if (!map)
|
|
44
44
|
return _token;
|
|
@@ -9,10 +9,10 @@ function register(context) {
|
|
|
9
9
|
return (uri, token = vscode.CancellationToken.None) => {
|
|
10
10
|
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, undefined, function* (_) {
|
|
11
11
|
yield _;
|
|
12
|
-
}, async (
|
|
12
|
+
}, async (service, document) => {
|
|
13
13
|
if (token.isCancellationRequested)
|
|
14
14
|
return;
|
|
15
|
-
return await
|
|
15
|
+
return await service.provideFileReferences?.(document, token) ?? [];
|
|
16
16
|
}, (data) => data.map(reference => {
|
|
17
17
|
if (!context.documents.isVirtualFileUri(reference.uri)) {
|
|
18
18
|
return reference;
|
|
@@ -21,12 +21,12 @@ function register(context) {
|
|
|
21
21
|
oldUri += tsExt;
|
|
22
22
|
newUri += tsExt;
|
|
23
23
|
}
|
|
24
|
-
for (const
|
|
24
|
+
for (const service of Object.values(context.services)) {
|
|
25
25
|
if (token.isCancellationRequested)
|
|
26
26
|
break;
|
|
27
|
-
if (!
|
|
27
|
+
if (!service.provideFileRenameEdits)
|
|
28
28
|
continue;
|
|
29
|
-
const workspaceEdit = await
|
|
29
|
+
const workspaceEdit = await service.provideFileRenameEdits(oldUri, newUri, token);
|
|
30
30
|
if (workspaceEdit) {
|
|
31
31
|
const result = (0, rename_1.embeddedEditToSourceEdit)(workspaceEdit, context.documents, 'fileName');
|
|
32
32
|
if (result?.documentChanges) {
|
|
@@ -7,10 +7,10 @@ const common_1 = require("../utils/common");
|
|
|
7
7
|
const validation_1 = require("./validation");
|
|
8
8
|
function register(context) {
|
|
9
9
|
return async (uri, position, token = vscode.CancellationToken.None) => {
|
|
10
|
-
let hover = await (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.hover), (
|
|
10
|
+
let hover = await (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.hover), (service, document, position) => {
|
|
11
11
|
if (token.isCancellationRequested)
|
|
12
12
|
return;
|
|
13
|
-
return
|
|
13
|
+
return service.provideHover?.(document, position, token);
|
|
14
14
|
}, (item, map) => {
|
|
15
15
|
if (!map || !item.range)
|
|
16
16
|
return item;
|
|
@@ -6,11 +6,11 @@ function register(context) {
|
|
|
6
6
|
return async (item, token = vscode.CancellationToken.None) => {
|
|
7
7
|
const data = item.data;
|
|
8
8
|
if (data) {
|
|
9
|
-
const
|
|
10
|
-
if (!
|
|
9
|
+
const service = context.services[data.serviceId];
|
|
10
|
+
if (!service.resolveInlayHint)
|
|
11
11
|
return item;
|
|
12
12
|
Object.assign(item, data.original);
|
|
13
|
-
item = await
|
|
13
|
+
item = await service.resolveInlayHint(item, token);
|
|
14
14
|
}
|
|
15
15
|
return item;
|
|
16
16
|
};
|
|
@@ -3,6 +3,6 @@ import type { ServiceContext } from '../types';
|
|
|
3
3
|
export interface InlayHintData {
|
|
4
4
|
uri: string;
|
|
5
5
|
original: Pick<vscode.CodeAction, 'data' | 'edit'>;
|
|
6
|
-
|
|
6
|
+
serviceId: string;
|
|
7
7
|
}
|
|
8
8
|
export declare function register(context: ServiceContext): (uri: string, range: vscode.Range, token?: vscode.CancellationToken) => Promise<vscode.InlayHint[] | undefined>;
|
|
@@ -37,17 +37,17 @@ function register(context) {
|
|
|
37
37
|
return [vscode.Range.create(map.virtualFileDocument.positionAt(minStart), map.virtualFileDocument.positionAt(maxEnd))];
|
|
38
38
|
}
|
|
39
39
|
return [];
|
|
40
|
-
}, async (
|
|
40
|
+
}, async (service, document, arg) => {
|
|
41
41
|
if (token.isCancellationRequested)
|
|
42
42
|
return;
|
|
43
|
-
const hints = await
|
|
43
|
+
const hints = await service.provideInlayHints?.(document, arg, token);
|
|
44
44
|
hints?.forEach(link => {
|
|
45
45
|
link.data = {
|
|
46
46
|
uri,
|
|
47
47
|
original: {
|
|
48
48
|
data: link.data,
|
|
49
49
|
},
|
|
50
|
-
|
|
50
|
+
serviceId: Object.keys(context.services).find(key => context.services[key] === service),
|
|
51
51
|
};
|
|
52
52
|
});
|
|
53
53
|
return hints;
|
|
@@ -6,7 +6,7 @@ const featureWorkers_1 = require("../utils/featureWorkers");
|
|
|
6
6
|
const dedupe = require("../utils/dedupe");
|
|
7
7
|
function register(context) {
|
|
8
8
|
return (uri, position, token = vscode.CancellationToken.None) => {
|
|
9
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.references), async (
|
|
9
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.references), async (service, document, position) => {
|
|
10
10
|
if (token.isCancellationRequested)
|
|
11
11
|
return;
|
|
12
12
|
const recursiveChecker = dedupe.createLocationSet();
|
|
@@ -14,12 +14,12 @@ function register(context) {
|
|
|
14
14
|
await withMirrors(document, position);
|
|
15
15
|
return result;
|
|
16
16
|
async function withMirrors(document, position) {
|
|
17
|
-
if (!
|
|
17
|
+
if (!service.provideReferences)
|
|
18
18
|
return;
|
|
19
19
|
if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } }))
|
|
20
20
|
return;
|
|
21
21
|
recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
|
|
22
|
-
const references = await
|
|
22
|
+
const references = await service.provideReferences(document, position, token) ?? [];
|
|
23
23
|
for (const reference of references) {
|
|
24
24
|
let foundMirrorPosition = false;
|
|
25
25
|
recursiveChecker.add({ uri: reference.uri, range: { start: reference.range.start, end: reference.range.start } });
|
|
@@ -19,7 +19,7 @@ function register(context) {
|
|
|
19
19
|
yield { position: mapped, newName };
|
|
20
20
|
}
|
|
21
21
|
;
|
|
22
|
-
}, async (
|
|
22
|
+
}, async (service, document, arg) => {
|
|
23
23
|
if (token.isCancellationRequested)
|
|
24
24
|
return;
|
|
25
25
|
const recursiveChecker = dedupe.createLocationSet();
|
|
@@ -27,12 +27,12 @@ function register(context) {
|
|
|
27
27
|
await withMirrors(document, arg.position, arg.newName);
|
|
28
28
|
return result;
|
|
29
29
|
async function withMirrors(document, position, newName) {
|
|
30
|
-
if (!
|
|
30
|
+
if (!service.provideRenameEdits)
|
|
31
31
|
return;
|
|
32
32
|
if (recursiveChecker.has({ uri: document.uri, range: { start: position, end: position } }))
|
|
33
33
|
return;
|
|
34
34
|
recursiveChecker.add({ uri: document.uri, range: { start: position, end: position } });
|
|
35
|
-
const workspaceEdit = await
|
|
35
|
+
const workspaceEdit = await service.provideRenameEdits(document, position, newName, token);
|
|
36
36
|
if (!workspaceEdit)
|
|
37
37
|
return;
|
|
38
38
|
if (!result)
|
|
@@ -116,7 +116,7 @@ function mergeWorkspaceEdits(original, ...others) {
|
|
|
116
116
|
original.documentChanges = [];
|
|
117
117
|
}
|
|
118
118
|
for (const docChange of other.documentChanges) {
|
|
119
|
-
original.documentChanges
|
|
119
|
+
pushEditToDocumentChanges(original.documentChanges, docChange);
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
}
|
|
@@ -149,7 +149,7 @@ function embeddedEditToSourceEdit(tsResult, documents, mode, versions = {}) {
|
|
|
149
149
|
for (const [_, map] of documents.getMapsByVirtualFileUri(tsUri)) {
|
|
150
150
|
const tsEdits = tsResult.changes[tsUri];
|
|
151
151
|
for (const tsEdit of tsEdits) {
|
|
152
|
-
if (mode === 'rename' || mode === 'fileName') {
|
|
152
|
+
if (mode === 'rename' || mode === 'fileName' || mode === 'codeAction') {
|
|
153
153
|
let _data;
|
|
154
154
|
const range = map.toSourceRange(tsEdit.range, data => {
|
|
155
155
|
_data = data;
|
|
@@ -188,7 +188,7 @@ function embeddedEditToSourceEdit(tsResult, documents, mode, versions = {}) {
|
|
|
188
188
|
version: versions[map.sourceFileDocument.uri] ?? null,
|
|
189
189
|
}, []);
|
|
190
190
|
for (const tsEdit of tsDocEdit.edits) {
|
|
191
|
-
if (mode === 'rename' || mode === 'fileName') {
|
|
191
|
+
if (mode === 'rename' || mode === 'fileName' || mode === 'codeAction') {
|
|
192
192
|
let _data;
|
|
193
193
|
const range = map.toSourceRange(tsEdit.range, data => {
|
|
194
194
|
_data = data;
|
|
@@ -253,7 +253,7 @@ function embeddedEditToSourceEdit(tsResult, documents, mode, versions = {}) {
|
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
255
|
if (sourceEdit) {
|
|
256
|
-
sourceResult.documentChanges
|
|
256
|
+
pushEditToDocumentChanges(sourceResult.documentChanges, sourceEdit);
|
|
257
257
|
hasResult = true;
|
|
258
258
|
}
|
|
259
259
|
}
|
|
@@ -263,4 +263,15 @@ function embeddedEditToSourceEdit(tsResult, documents, mode, versions = {}) {
|
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
exports.embeddedEditToSourceEdit = embeddedEditToSourceEdit;
|
|
266
|
+
function pushEditToDocumentChanges(arr, item) {
|
|
267
|
+
const current = arr.find(edit => vscode.TextDocumentEdit.is(edit)
|
|
268
|
+
&& vscode.TextDocumentEdit.is(item)
|
|
269
|
+
&& edit.textDocument.uri === item.textDocument.uri);
|
|
270
|
+
if (current) {
|
|
271
|
+
current.edits.push(...item.edits);
|
|
272
|
+
}
|
|
273
|
+
else {
|
|
274
|
+
arr.push(item);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
266
277
|
//# sourceMappingURL=rename.js.map
|
|
@@ -5,10 +5,10 @@ const vscode = require("vscode-languageserver-protocol");
|
|
|
5
5
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
6
6
|
function register(context) {
|
|
7
7
|
return (uri, position, token = vscode.CancellationToken.None) => {
|
|
8
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename), (
|
|
8
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => typeof data.rename === 'object' ? !!data.rename.normalize : !!data.rename), (service, document, position) => {
|
|
9
9
|
if (token.isCancellationRequested)
|
|
10
10
|
return;
|
|
11
|
-
return
|
|
11
|
+
return service.provideRenameRange?.(document, position, token);
|
|
12
12
|
}, (item, map) => {
|
|
13
13
|
if (!map) {
|
|
14
14
|
return item;
|
|
@@ -8,17 +8,17 @@ function register(context) {
|
|
|
8
8
|
triggerKind: vscode.SignatureHelpTriggerKind.Invoked,
|
|
9
9
|
isRetrigger: false,
|
|
10
10
|
}, token = vscode.CancellationToken.None) => {
|
|
11
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.completion), (
|
|
11
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, position, (position, map) => map.toGeneratedPositions(position, data => !!data.completion), (service, document, position) => {
|
|
12
12
|
if (token.isCancellationRequested)
|
|
13
13
|
return;
|
|
14
14
|
if (signatureHelpContext?.triggerKind === vscode.SignatureHelpTriggerKind.TriggerCharacter
|
|
15
15
|
&& signatureHelpContext.triggerCharacter
|
|
16
16
|
&& !(signatureHelpContext.isRetrigger
|
|
17
|
-
?
|
|
18
|
-
:
|
|
17
|
+
? service.signatureHelpRetriggerCharacters
|
|
18
|
+
: service.signatureHelpTriggerCharacters)?.includes(signatureHelpContext.triggerCharacter)) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
return
|
|
21
|
+
return service.provideSignatureHelp?.(document, position, signatureHelpContext, token);
|
|
22
22
|
}, (data) => data);
|
|
23
23
|
};
|
|
24
24
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import
|
|
2
|
+
import { ServiceContext } from '../types';
|
|
3
3
|
export declare function updateRange(range: vscode.Range, change: {
|
|
4
4
|
range: vscode.Range;
|
|
5
5
|
newEnd: vscode.Position;
|
|
6
6
|
}): vscode.Range | undefined;
|
|
7
|
-
export interface
|
|
7
|
+
export interface ServiceDiagnosticData {
|
|
8
8
|
uri: string;
|
|
9
9
|
version: number;
|
|
10
10
|
original: Pick<vscode.Diagnostic, 'data'>;
|
|
11
|
-
type: '
|
|
11
|
+
type: 'service' | 'rule';
|
|
12
12
|
isFormat: boolean;
|
|
13
|
-
|
|
13
|
+
serviceOrRuleId: string;
|
|
14
14
|
ruleFixIndex: number;
|
|
15
15
|
documentUri: string;
|
|
16
16
|
}
|