@volar/language-service 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/lib/features/provideAutoInsertSnippet.js +4 -5
- package/lib/features/provideCallHierarchyItems.d.ts +1 -1
- package/lib/features/provideCallHierarchyItems.js +18 -17
- package/lib/features/provideCodeActions.js +7 -8
- package/lib/features/provideCodeLenses.js +6 -8
- package/lib/features/provideColorPresentations.js +8 -10
- package/lib/features/provideCompletionItems.js +32 -21
- package/lib/features/provideDefinition.js +22 -20
- package/lib/features/provideDiagnostics.d.ts +2 -2
- package/lib/features/provideDiagnostics.js +38 -30
- package/lib/features/provideDocumentColors.js +6 -8
- package/lib/features/provideDocumentDropEdits.js +3 -4
- package/lib/features/provideDocumentFormattingEdits.js +15 -14
- package/lib/features/provideDocumentHighlights.js +12 -13
- package/lib/features/provideDocumentLinks.js +6 -8
- package/lib/features/provideDocumentSemanticTokens.js +9 -10
- package/lib/features/provideDocumentSymbols.js +6 -7
- package/lib/features/provideFileReferences.d.ts +1 -1
- package/lib/features/provideFileReferences.js +9 -8
- package/lib/features/provideFileRenameEdits.js +1 -2
- package/lib/features/provideFoldingRanges.js +5 -6
- package/lib/features/provideHover.js +5 -6
- package/lib/features/provideInlayHints.js +11 -13
- package/lib/features/provideLinkedEditingRanges.js +7 -9
- package/lib/features/provideReferences.js +15 -12
- package/lib/features/provideRenameEdits.js +10 -10
- package/lib/features/provideRenameRange.js +5 -6
- package/lib/features/provideSelectionRanges.js +11 -8
- package/lib/features/provideSignatureHelp.js +2 -3
- package/lib/features/provideWorkspaceDiagnostics.js +12 -9
- package/lib/features/provideWorkspaceSymbols.js +14 -10
- package/lib/features/resolveCodeAction.js +1 -2
- package/lib/features/resolveCodeLens.js +1 -2
- package/lib/features/resolveCompletionItem.js +9 -6
- package/lib/features/resolveDocumentLink.js +1 -2
- package/lib/features/resolveInlayHint.js +1 -2
- package/lib/languageService.d.ts +11 -5
- package/lib/languageService.js +25 -51
- package/lib/types.d.ts +0 -4
- package/lib/utils/common.d.ts +2 -3
- package/lib/utils/common.js +7 -12
- package/lib/utils/dedupe.js +10 -11
- package/lib/utils/featureWorkers.d.ts +30 -6
- package/lib/utils/featureWorkers.js +106 -38
- package/lib/utils/transform.d.ts +1 -1
- package/lib/utils/transform.js +61 -48
- package/lib/utils/uriMap.js +1 -2
- package/package.json +3 -3
- package/lib/documents.d.ts +0 -31
- package/lib/documents.js +0 -117
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -17,7 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.mergeWorkspaceEdits = void 0;
|
|
18
18
|
__exportStar(require("@volar/language-core"), exports);
|
|
19
19
|
__exportStar(require("./lib/languageService"), exports);
|
|
20
|
-
__exportStar(require("./lib/documents"), exports);
|
|
21
20
|
var provideRenameEdits_1 = require("./lib/features/provideRenameEdits");
|
|
22
21
|
Object.defineProperty(exports, "mergeWorkspaceEdits", { enumerable: true, get: function () { return provideRenameEdits_1.mergeWorkspaceEdits; } });
|
|
23
22
|
__exportStar(require("./lib/types"), exports);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.register =
|
|
3
|
+
exports.register = register;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
5
|
const cancellation_1 = require("../utils/cancellation");
|
|
6
6
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
7
7
|
function register(context) {
|
|
8
8
|
return (uri, selection, change, token = cancellation_1.NoneCancellationToken) => {
|
|
9
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => ({ selection, change }), function* (
|
|
10
|
-
for (const mappedPosition of
|
|
11
|
-
for (const mapped of
|
|
9
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => ({ selection, change }), function* (docs) {
|
|
10
|
+
for (const mappedPosition of (0, featureWorkers_1.getGeneratedPositions)(docs, selection, language_core_1.isAutoInsertEnabled)) {
|
|
11
|
+
for (const mapped of docs[2].toGeneratedLocation(change.rangeOffset)) {
|
|
12
12
|
yield {
|
|
13
13
|
selection: mappedPosition,
|
|
14
14
|
change: {
|
|
@@ -28,5 +28,4 @@ function register(context) {
|
|
|
28
28
|
}, snippet => snippet);
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
exports.register = register;
|
|
32
31
|
//# sourceMappingURL=provideAutoInsertSnippet.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
2
|
-
import type { LanguageServiceContext } from '../types';
|
|
3
2
|
import { URI } from 'vscode-uri';
|
|
3
|
+
import type { LanguageServiceContext } from '../types';
|
|
4
4
|
export interface PluginCallHierarchyData {
|
|
5
5
|
uri: string;
|
|
6
6
|
original: Pick<vscode.CallHierarchyItem, 'data'>;
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.register =
|
|
3
|
+
exports.register = register;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
|
+
const vscode_uri_1 = require("vscode-uri");
|
|
5
6
|
const cancellation_1 = require("../utils/cancellation");
|
|
6
|
-
const common_1 = require("../utils/common");
|
|
7
7
|
const dedupe = require("../utils/dedupe");
|
|
8
8
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
9
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
10
9
|
function register(context) {
|
|
11
10
|
return {
|
|
12
11
|
getCallHierarchyItems(uri, position, token = cancellation_1.NoneCancellationToken) {
|
|
13
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position,
|
|
12
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, docs => (0, featureWorkers_1.getGeneratedPositions)(docs, position, language_core_1.isCallHierarchyEnabled), async (plugin, document, position, map) => {
|
|
14
13
|
if (token.isCancellationRequested) {
|
|
15
14
|
return;
|
|
16
15
|
}
|
|
@@ -22,7 +21,7 @@ function register(context) {
|
|
|
22
21
|
data: item.data,
|
|
23
22
|
},
|
|
24
23
|
pluginIndex: context.plugins.indexOf(plugin),
|
|
25
|
-
embeddedDocumentUri: map?.
|
|
24
|
+
embeddedDocumentUri: map?.[1].uri,
|
|
26
25
|
};
|
|
27
26
|
});
|
|
28
27
|
return items;
|
|
@@ -32,7 +31,7 @@ function register(context) {
|
|
|
32
31
|
}
|
|
33
32
|
return data
|
|
34
33
|
.map(item => transformCallHierarchyItem(item, [])?.[0])
|
|
35
|
-
.filter(
|
|
34
|
+
.filter(item => !!item);
|
|
36
35
|
}, arr => dedupe.withLocations(arr.flat()));
|
|
37
36
|
},
|
|
38
37
|
async getCallHierarchyIncomingCalls(item, token) {
|
|
@@ -122,29 +121,32 @@ function register(context) {
|
|
|
122
121
|
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(tsItem.uri));
|
|
123
122
|
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
124
123
|
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
125
|
-
if (!virtualCode) {
|
|
124
|
+
if (!sourceScript || !virtualCode) {
|
|
126
125
|
return [tsItem, tsRanges];
|
|
127
126
|
}
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
const embeddedDocument = context.documents.get(context.encodeEmbeddedDocumentUri(sourceScript.id, virtualCode.id), virtualCode.languageId, virtualCode.snapshot);
|
|
128
|
+
for (const [sourceScript, map] of context.language.maps.forEach(virtualCode)) {
|
|
129
|
+
const sourceDocument = context.documents.get(sourceScript.id, sourceScript.languageId, sourceScript.snapshot);
|
|
130
|
+
const docs = [sourceDocument, embeddedDocument, map];
|
|
131
|
+
let range = (0, featureWorkers_1.getSourceRange)(docs, tsItem.range);
|
|
130
132
|
if (!range) {
|
|
131
133
|
// TODO: <script> range
|
|
132
134
|
range = {
|
|
133
|
-
start:
|
|
134
|
-
end:
|
|
135
|
+
start: sourceDocument.positionAt(0),
|
|
136
|
+
end: sourceDocument.positionAt(sourceDocument.getText().length),
|
|
135
137
|
};
|
|
136
138
|
}
|
|
137
|
-
const selectionRange =
|
|
139
|
+
const selectionRange = (0, featureWorkers_1.getSourceRange)(docs, tsItem.selectionRange);
|
|
138
140
|
if (!selectionRange) {
|
|
139
141
|
continue;
|
|
140
142
|
}
|
|
141
|
-
const vueRanges = tsRanges.map(tsRange =>
|
|
143
|
+
const vueRanges = tsRanges.map(tsRange => (0, featureWorkers_1.getSourceRange)(docs, tsRange)).filter(range => !!range);
|
|
142
144
|
const vueItem = {
|
|
143
145
|
...tsItem,
|
|
144
|
-
name: tsItem.name ===
|
|
145
|
-
?
|
|
146
|
+
name: tsItem.name === embeddedDocument.uri.substring(embeddedDocument.uri.lastIndexOf('/') + 1)
|
|
147
|
+
? sourceDocument.uri.substring(sourceDocument.uri.lastIndexOf('/') + 1)
|
|
146
148
|
: tsItem.name,
|
|
147
|
-
uri:
|
|
149
|
+
uri: sourceDocument.uri,
|
|
148
150
|
// TS Bug: `range: range` not works
|
|
149
151
|
range: {
|
|
150
152
|
start: range.start,
|
|
@@ -159,5 +161,4 @@ function register(context) {
|
|
|
159
161
|
}
|
|
160
162
|
}
|
|
161
163
|
}
|
|
162
|
-
exports.register = register;
|
|
163
164
|
//# sourceMappingURL=provideCallHierarchyItems.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.register =
|
|
3
|
+
exports.register = register;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
5
|
const cancellation_1 = require("../utils/cancellation");
|
|
6
6
|
const common_1 = require("../utils/common");
|
|
@@ -14,17 +14,17 @@ function register(context) {
|
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
16
|
const transformedCodeActions = new WeakSet();
|
|
17
|
-
return await (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => ({ range, codeActionContext }), function* (
|
|
17
|
+
return await (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => ({ range, codeActionContext }), function* (docs) {
|
|
18
18
|
const _codeActionContext = {
|
|
19
|
-
diagnostics: (0, transform_1.transformLocations)(codeActionContext.diagnostics, range =>
|
|
19
|
+
diagnostics: (0, transform_1.transformLocations)(codeActionContext.diagnostics, range => (0, featureWorkers_1.getGeneratedRange)(docs, range)),
|
|
20
20
|
only: codeActionContext.only,
|
|
21
21
|
};
|
|
22
|
-
const mapped = (0, common_1.findOverlapCodeRange)(
|
|
22
|
+
const mapped = (0, common_1.findOverlapCodeRange)(docs[0].offsetAt(range.start), docs[0].offsetAt(range.end), docs[2], language_core_1.isCodeActionsEnabled);
|
|
23
23
|
if (mapped) {
|
|
24
24
|
yield {
|
|
25
25
|
range: {
|
|
26
|
-
start:
|
|
27
|
-
end:
|
|
26
|
+
start: docs[1].positionAt(mapped.start),
|
|
27
|
+
end: docs[1].positionAt(mapped.end),
|
|
28
28
|
},
|
|
29
29
|
codeActionContext: _codeActionContext,
|
|
30
30
|
};
|
|
@@ -86,8 +86,7 @@ function register(context) {
|
|
|
86
86
|
}
|
|
87
87
|
return action;
|
|
88
88
|
})
|
|
89
|
-
.filter(
|
|
89
|
+
.filter(action => !!action), arr => dedupe.withCodeAction(arr.flat()));
|
|
90
90
|
};
|
|
91
91
|
}
|
|
92
|
-
exports.register = register;
|
|
93
92
|
//# sourceMappingURL=provideCodeActions.js.map
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.register =
|
|
3
|
+
exports.register = register;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
5
|
const cancellation_1 = require("../utils/cancellation");
|
|
6
|
-
const common_1 = require("../utils/common");
|
|
7
6
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
8
7
|
function register(context) {
|
|
9
8
|
return async (uri, token = cancellation_1.NoneCancellationToken) => {
|
|
10
|
-
return await (0, featureWorkers_1.documentFeatureWorker)(context, uri,
|
|
9
|
+
return await (0, featureWorkers_1.documentFeatureWorker)(context, uri, docs => docs[2].mappings.some(mapping => (0, language_core_1.isCodeLensEnabled)(mapping.data)), async (plugin, document) => {
|
|
11
10
|
if (token.isCancellationRequested) {
|
|
12
11
|
return;
|
|
13
12
|
}
|
|
@@ -39,13 +38,13 @@ function register(context) {
|
|
|
39
38
|
...referencesCodeLens ?? [],
|
|
40
39
|
];
|
|
41
40
|
return codeLens;
|
|
42
|
-
}, (data,
|
|
43
|
-
if (!
|
|
41
|
+
}, (data, docs) => {
|
|
42
|
+
if (!docs) {
|
|
44
43
|
return data;
|
|
45
44
|
}
|
|
46
45
|
return data
|
|
47
46
|
.map(codeLens => {
|
|
48
|
-
const range =
|
|
47
|
+
const range = (0, featureWorkers_1.getSourceRange)(docs, codeLens.range, language_core_1.isCodeLensEnabled);
|
|
49
48
|
if (range) {
|
|
50
49
|
return {
|
|
51
50
|
...codeLens,
|
|
@@ -53,9 +52,8 @@ function register(context) {
|
|
|
53
52
|
};
|
|
54
53
|
}
|
|
55
54
|
})
|
|
56
|
-
.filter(
|
|
55
|
+
.filter(codeLens => !!codeLens);
|
|
57
56
|
}, arr => arr.flat()) ?? [];
|
|
58
57
|
};
|
|
59
58
|
}
|
|
60
|
-
exports.register = register;
|
|
61
59
|
//# sourceMappingURL=provideCodeLenses.js.map
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.register =
|
|
3
|
+
exports.register = register;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
5
|
const cancellation_1 = require("../utils/cancellation");
|
|
6
|
-
const common_1 = require("../utils/common");
|
|
7
6
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
8
7
|
function register(context) {
|
|
9
8
|
return (uri, color, range, token = cancellation_1.NoneCancellationToken) => {
|
|
10
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => range, function* (
|
|
11
|
-
for (const mappedRange of
|
|
9
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => range, function* (docs) {
|
|
10
|
+
for (const mappedRange of (0, featureWorkers_1.getGeneratedRanges)(docs, range, language_core_1.isColorEnabled)) {
|
|
12
11
|
yield mappedRange;
|
|
13
12
|
}
|
|
14
13
|
}, (plugin, document, range) => {
|
|
@@ -16,14 +15,14 @@ function register(context) {
|
|
|
16
15
|
return;
|
|
17
16
|
}
|
|
18
17
|
return plugin[1].provideColorPresentations?.(document, color, range, token);
|
|
19
|
-
}, (data,
|
|
20
|
-
if (!
|
|
18
|
+
}, (data, docs) => {
|
|
19
|
+
if (!docs) {
|
|
21
20
|
return data;
|
|
22
21
|
}
|
|
23
22
|
return data
|
|
24
23
|
.map(colorPresentation => {
|
|
25
24
|
if (colorPresentation.textEdit) {
|
|
26
|
-
const range =
|
|
25
|
+
const range = (0, featureWorkers_1.getSourceRange)(docs, colorPresentation.textEdit.range);
|
|
27
26
|
if (!range) {
|
|
28
27
|
return undefined;
|
|
29
28
|
}
|
|
@@ -31,7 +30,7 @@ function register(context) {
|
|
|
31
30
|
}
|
|
32
31
|
if (colorPresentation.additionalTextEdits) {
|
|
33
32
|
for (const textEdit of colorPresentation.additionalTextEdits) {
|
|
34
|
-
const range =
|
|
33
|
+
const range = (0, featureWorkers_1.getSourceRange)(docs, textEdit.range);
|
|
35
34
|
if (!range) {
|
|
36
35
|
return undefined;
|
|
37
36
|
}
|
|
@@ -40,9 +39,8 @@ function register(context) {
|
|
|
40
39
|
}
|
|
41
40
|
return colorPresentation;
|
|
42
41
|
})
|
|
43
|
-
.filter(
|
|
42
|
+
.filter(colorPresentation => !!colorPresentation);
|
|
44
43
|
});
|
|
45
44
|
};
|
|
46
45
|
}
|
|
47
|
-
exports.register = register;
|
|
48
46
|
//# sourceMappingURL=provideColorPresentations.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.register =
|
|
3
|
+
exports.register = register;
|
|
4
4
|
const language_core_1 = require("@volar/language-core");
|
|
5
5
|
const vscode_uri_1 = require("vscode-uri");
|
|
6
6
|
const cancellation_1 = require("../utils/cancellation");
|
|
@@ -9,8 +9,17 @@ const transform_1 = require("../utils/transform");
|
|
|
9
9
|
function register(context) {
|
|
10
10
|
let lastResult;
|
|
11
11
|
return async (uri, position, completionContext = { triggerKind: 1, }, token = cancellation_1.NoneCancellationToken) => {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
let langaugeIdAndSnapshot;
|
|
13
|
+
let sourceScript;
|
|
14
|
+
const decoded = context.decodeEmbeddedDocumentUri(uri);
|
|
15
|
+
if (decoded) {
|
|
16
|
+
langaugeIdAndSnapshot = context.language.scripts.get(decoded[0])?.generated?.embeddedCodes.get(decoded[1]);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
sourceScript = context.language.scripts.get(uri);
|
|
20
|
+
langaugeIdAndSnapshot = sourceScript;
|
|
21
|
+
}
|
|
22
|
+
if (!langaugeIdAndSnapshot) {
|
|
14
23
|
return {
|
|
15
24
|
isIncomplete: false,
|
|
16
25
|
items: [],
|
|
@@ -27,15 +36,18 @@ function register(context) {
|
|
|
27
36
|
const decoded = context.decodeEmbeddedDocumentUri(cacheData.embeddedDocumentUri);
|
|
28
37
|
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
29
38
|
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
30
|
-
if (!virtualCode) {
|
|
39
|
+
if (!sourceScript || !virtualCode) {
|
|
31
40
|
continue;
|
|
32
41
|
}
|
|
33
|
-
|
|
34
|
-
|
|
42
|
+
const embeddedDocument = context.documents.get(context.encodeEmbeddedDocumentUri(sourceScript.id, virtualCode.id), virtualCode.languageId, virtualCode.snapshot);
|
|
43
|
+
for (const [sourceScript, map] of context.language.maps.forEach(virtualCode)) {
|
|
44
|
+
const sourceDocument = context.documents.get(sourceScript.id, sourceScript.languageId, sourceScript.snapshot);
|
|
45
|
+
const docs = [sourceDocument, embeddedDocument, map];
|
|
46
|
+
for (const mapped of (0, featureWorkers_1.getGeneratedPositions)(docs, position, data => (0, language_core_1.isCompletionEnabled)(data))) {
|
|
35
47
|
if (!cacheData.plugin.provideCompletionItems) {
|
|
36
48
|
continue;
|
|
37
49
|
}
|
|
38
|
-
cacheData.list = await cacheData.plugin.provideCompletionItems(
|
|
50
|
+
cacheData.list = await cacheData.plugin.provideCompletionItems(embeddedDocument, mapped, completionContext, token);
|
|
39
51
|
if (!cacheData.list) {
|
|
40
52
|
continue;
|
|
41
53
|
}
|
|
@@ -48,10 +60,10 @@ function register(context) {
|
|
|
48
60
|
data: item.data,
|
|
49
61
|
},
|
|
50
62
|
pluginIndex: pluginIndex,
|
|
51
|
-
embeddedDocumentUri:
|
|
63
|
+
embeddedDocumentUri: embeddedDocument.uri,
|
|
52
64
|
};
|
|
53
65
|
}
|
|
54
|
-
cacheData.list = (0, transform_1.transformCompletionList)(cacheData.list, range =>
|
|
66
|
+
cacheData.list = (0, transform_1.transformCompletionList)(cacheData.list, range => (0, featureWorkers_1.getSourceRange)(docs, range), embeddedDocument, context);
|
|
55
67
|
}
|
|
56
68
|
}
|
|
57
69
|
}
|
|
@@ -59,7 +71,7 @@ function register(context) {
|
|
|
59
71
|
if (!cacheData.plugin.provideCompletionItems) {
|
|
60
72
|
continue;
|
|
61
73
|
}
|
|
62
|
-
const document = context.documents.get(uri,
|
|
74
|
+
const document = context.documents.get(uri, langaugeIdAndSnapshot.languageId, langaugeIdAndSnapshot.snapshot);
|
|
63
75
|
cacheData.list = await cacheData.plugin.provideCompletionItems(document, position, completionContext, token);
|
|
64
76
|
if (!cacheData.list) {
|
|
65
77
|
continue;
|
|
@@ -90,7 +102,7 @@ function register(context) {
|
|
|
90
102
|
const sortedPlugins = [...context.plugins]
|
|
91
103
|
.filter(plugin => !context.disabledServicePlugins.has(plugin[1]))
|
|
92
104
|
.sort((a, b) => sortServices(a[1], b[1]));
|
|
93
|
-
const worker = async (document, position,
|
|
105
|
+
const worker = async (document, position, docs, codeInfo) => {
|
|
94
106
|
for (const plugin of sortedPlugins) {
|
|
95
107
|
if (token.isCancellationRequested) {
|
|
96
108
|
break;
|
|
@@ -132,33 +144,33 @@ function register(context) {
|
|
|
132
144
|
data: item.data,
|
|
133
145
|
},
|
|
134
146
|
pluginIndex,
|
|
135
|
-
embeddedDocumentUri:
|
|
147
|
+
embeddedDocumentUri: docs ? document.uri : undefined,
|
|
136
148
|
};
|
|
137
149
|
}
|
|
138
|
-
if (
|
|
139
|
-
completionList = (0, transform_1.transformCompletionList)(completionList, range =>
|
|
150
|
+
if (docs) {
|
|
151
|
+
completionList = (0, transform_1.transformCompletionList)(completionList, range => (0, featureWorkers_1.getSourceRange)(docs, range, language_core_1.isCompletionEnabled), document, context);
|
|
140
152
|
}
|
|
141
153
|
lastResult?.results.push({
|
|
142
|
-
embeddedDocumentUri:
|
|
154
|
+
embeddedDocumentUri: docs ? vscode_uri_1.URI.parse(document.uri) : undefined,
|
|
143
155
|
plugin: plugin[1],
|
|
144
156
|
list: completionList,
|
|
145
157
|
});
|
|
146
158
|
}
|
|
147
159
|
isFirstMapping = false;
|
|
148
160
|
};
|
|
149
|
-
if (sourceScript
|
|
150
|
-
for (const
|
|
161
|
+
if (sourceScript?.generated) {
|
|
162
|
+
for (const docs of (0, featureWorkers_1.forEachEmbeddedDocument)(context, sourceScript, sourceScript.generated.root)) {
|
|
151
163
|
let _data;
|
|
152
|
-
for (const mappedPosition of
|
|
164
|
+
for (const mappedPosition of (0, featureWorkers_1.getGeneratedPositions)(docs, position, data => {
|
|
153
165
|
_data = data;
|
|
154
166
|
return (0, language_core_1.isCompletionEnabled)(data);
|
|
155
167
|
})) {
|
|
156
|
-
await worker(
|
|
168
|
+
await worker(docs[1], mappedPosition, docs, _data);
|
|
157
169
|
}
|
|
158
170
|
}
|
|
159
171
|
}
|
|
160
172
|
else {
|
|
161
|
-
const document = context.documents.get(uri,
|
|
173
|
+
const document = context.documents.get(uri, langaugeIdAndSnapshot.languageId, langaugeIdAndSnapshot.snapshot);
|
|
162
174
|
await worker(document, position);
|
|
163
175
|
}
|
|
164
176
|
}
|
|
@@ -175,5 +187,4 @@ function register(context) {
|
|
|
175
187
|
}
|
|
176
188
|
};
|
|
177
189
|
}
|
|
178
|
-
exports.register = register;
|
|
179
190
|
//# sourceMappingURL=provideCompletionItems.js.map
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.register =
|
|
3
|
+
exports.register = register;
|
|
4
4
|
const vscode_uri_1 = require("vscode-uri");
|
|
5
5
|
const cancellation_1 = require("../utils/cancellation");
|
|
6
|
-
const common_1 = require("../utils/common");
|
|
7
6
|
const dedupe = require("../utils/dedupe");
|
|
8
7
|
const featureWorkers_1 = require("../utils/featureWorkers");
|
|
9
8
|
function register(context, apiName, isValidPosition) {
|
|
10
9
|
return (uri, position, token = cancellation_1.NoneCancellationToken) => {
|
|
11
|
-
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position,
|
|
10
|
+
return (0, featureWorkers_1.languageFeatureWorker)(context, uri, () => position, docs => (0, featureWorkers_1.getGeneratedPositions)(docs, position, isValidPosition), async (plugin, document, position) => {
|
|
12
11
|
if (token.isCancellationRequested) {
|
|
13
12
|
return;
|
|
14
13
|
}
|
|
@@ -33,15 +32,16 @@ function register(context, apiName, isValidPosition) {
|
|
|
33
32
|
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
34
33
|
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
35
34
|
const linkedCodeMap = virtualCode && sourceScript
|
|
36
|
-
? context.
|
|
35
|
+
? context.language.linkedCodeMaps.get(virtualCode)
|
|
37
36
|
: undefined;
|
|
38
|
-
if (linkedCodeMap) {
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
if (sourceScript && virtualCode && linkedCodeMap) {
|
|
38
|
+
const embeddedDocument = context.documents.get(context.encodeEmbeddedDocumentUri(sourceScript.id, virtualCode.id), virtualCode.languageId, virtualCode.snapshot);
|
|
39
|
+
for (const linkedPos of (0, featureWorkers_1.getLinkedCodePositions)(embeddedDocument, linkedCodeMap, definition.targetSelectionRange.start)) {
|
|
40
|
+
if (recursiveChecker.has({ uri: embeddedDocument.uri, range: { start: linkedPos, end: linkedPos } })) {
|
|
41
41
|
continue;
|
|
42
42
|
}
|
|
43
43
|
foundMirrorPosition = true;
|
|
44
|
-
await withLinkedCode(
|
|
44
|
+
await withLinkedCode(embeddedDocument, linkedPos, originDefinition ?? definition);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
if (!foundMirrorPosition) {
|
|
@@ -69,25 +69,28 @@ function register(context, apiName, isValidPosition) {
|
|
|
69
69
|
const decoded = context.decodeEmbeddedDocumentUri(vscode_uri_1.URI.parse(link.targetUri));
|
|
70
70
|
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
71
71
|
const targetVirtualFile = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
72
|
-
if (targetVirtualFile) {
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
if (sourceScript && targetVirtualFile) {
|
|
73
|
+
const embeddedDocument = context.documents.get(context.encodeEmbeddedDocumentUri(sourceScript.id, targetVirtualFile.id), targetVirtualFile.languageId, targetVirtualFile.snapshot);
|
|
74
|
+
for (const [targetScript, targetSourceMap] of context.language.maps.forEach(targetVirtualFile)) {
|
|
75
|
+
const sourceDocument = context.documents.get(targetScript.id, targetScript.languageId, targetScript.snapshot);
|
|
76
|
+
const docs = [sourceDocument, embeddedDocument, targetSourceMap];
|
|
77
|
+
const targetSelectionRange = (0, featureWorkers_1.getSourceRange)(docs, link.targetSelectionRange);
|
|
75
78
|
if (!targetSelectionRange) {
|
|
76
79
|
continue;
|
|
77
80
|
}
|
|
78
81
|
foundTargetSelectionRange = true;
|
|
79
|
-
let targetRange =
|
|
80
|
-
link.targetUri =
|
|
82
|
+
let targetRange = (0, featureWorkers_1.getSourceRange)(docs, link.targetRange);
|
|
83
|
+
link.targetUri = sourceDocument.uri;
|
|
81
84
|
// loose range mapping to for template slots, slot properties
|
|
82
85
|
link.targetRange = targetRange ?? targetSelectionRange;
|
|
83
86
|
link.targetSelectionRange = targetSelectionRange;
|
|
84
87
|
}
|
|
85
88
|
if (apiName === 'provideDefinition' && !foundTargetSelectionRange) {
|
|
86
|
-
for (const
|
|
87
|
-
if (
|
|
89
|
+
for (const [targetScript] of context.language.maps.forEach(targetVirtualFile)) {
|
|
90
|
+
if (targetScript.id.toString() !== uri.toString()) {
|
|
88
91
|
return {
|
|
89
92
|
...link,
|
|
90
|
-
targetUri:
|
|
93
|
+
targetUri: targetScript.id.toString(),
|
|
91
94
|
targetRange: {
|
|
92
95
|
start: { line: 0, character: 0 },
|
|
93
96
|
end: { line: 0, character: 0 },
|
|
@@ -103,13 +106,12 @@ function register(context, apiName, isValidPosition) {
|
|
|
103
106
|
}
|
|
104
107
|
}
|
|
105
108
|
return link;
|
|
106
|
-
}).filter(
|
|
109
|
+
}).filter(link => !!link), arr => dedupe.withLocationLinks(arr.flat()));
|
|
107
110
|
};
|
|
108
111
|
}
|
|
109
|
-
|
|
110
|
-
function toSourcePositionPreferSurroundedPosition(map, mappedRange, position) {
|
|
112
|
+
function toSourcePositionPreferSurroundedPosition(docs, mappedRange, position) {
|
|
111
113
|
let result;
|
|
112
|
-
for (const range of
|
|
114
|
+
for (const range of (0, featureWorkers_1.getSourceRanges)(docs, mappedRange)) {
|
|
113
115
|
if (!result) {
|
|
114
116
|
result = range;
|
|
115
117
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type CodeInformation } from '@volar/language-core';
|
|
2
2
|
import type * as vscode from 'vscode-languageserver-protocol';
|
|
3
3
|
import { URI } from 'vscode-uri';
|
|
4
|
-
import type { SourceMapWithDocuments } from '../documents';
|
|
5
4
|
import type { LanguageServiceContext } from '../types';
|
|
5
|
+
import { DocumentsAndMap } from '../utils/featureWorkers';
|
|
6
6
|
export declare function updateRange(range: vscode.Range, change: {
|
|
7
7
|
range: vscode.Range;
|
|
8
8
|
newEnd: vscode.Position;
|
|
@@ -20,4 +20,4 @@ export declare const errorMarkups: Map<URI, {
|
|
|
20
20
|
markup: vscode.MarkupContent;
|
|
21
21
|
}[]>;
|
|
22
22
|
export declare function register(context: LanguageServiceContext): (uri: URI, token?: vscode.CancellationToken, response?: (result: vscode.Diagnostic[]) => void) => Promise<vscode.Diagnostic[]>;
|
|
23
|
-
export declare function transformDiagnostic(context: LanguageServiceContext, error: vscode.Diagnostic,
|
|
23
|
+
export declare function transformDiagnostic(context: LanguageServiceContext, error: vscode.Diagnostic, docs: DocumentsAndMap | undefined, filter: (data: CodeInformation) => boolean): vscode.Diagnostic | undefined;
|