@vue/language-service 3.0.2 → 3.0.4
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 +1 -12
- package/index.js +14 -15
- package/lib/plugins/css.js +9 -17
- package/lib/plugins/typescript-semantic-tokens.d.ts +2 -2
- package/lib/plugins/typescript-semantic-tokens.js +6 -14
- package/lib/plugins/utils.d.ts +8 -2
- package/lib/plugins/utils.js +39 -6
- package/lib/plugins/vue-autoinsert-dotvalue.d copy.d.ts +2 -0
- package/lib/plugins/vue-autoinsert-dotvalue.d copy.js +3 -0
- package/lib/plugins/vue-autoinsert-dotvalue.d.ts +2 -2
- package/lib/plugins/vue-autoinsert-dotvalue.js +15 -32
- package/lib/plugins/vue-compiler-dom-errors.js +17 -35
- package/lib/plugins/vue-component-semantic-tokens.d.ts +2 -2
- package/lib/plugins/vue-component-semantic-tokens.js +35 -49
- package/lib/plugins/vue-destructured-props-hints.d.ts +7 -0
- package/lib/plugins/vue-destructured-props-hints.js +220 -0
- package/lib/plugins/vue-document-drop.d.ts +2 -2
- package/lib/plugins/vue-document-drop.js +12 -26
- package/lib/plugins/vue-document-highlights.d.ts +1 -2
- package/lib/plugins/vue-document-highlights.js +6 -13
- package/lib/plugins/vue-extract-file.d.ts +2 -2
- package/lib/plugins/vue-extract-file.js +10 -25
- package/lib/plugins/vue-global-types-error.js +28 -14
- package/lib/plugins/vue-inlayhints.js +14 -15
- package/lib/plugins/vue-missing-props-hints.d.ts +2 -2
- package/lib/plugins/vue-missing-props-hints.js +7 -23
- package/lib/plugins/vue-scoped-class-links.d.ts +2 -0
- package/lib/plugins/vue-scoped-class-links.js +62 -0
- package/lib/plugins/vue-sfc.js +140 -143
- package/lib/plugins/vue-suggest-define-assignment.js +3 -13
- package/lib/plugins/vue-template-ref-links.d.ts +2 -0
- package/lib/plugins/vue-template-ref-links.js +57 -0
- package/lib/plugins/vue-template.d.ts +2 -2
- package/lib/plugins/vue-template.js +320 -353
- package/lib/plugins/vue-twoslash-queries.d.ts +2 -2
- package/lib/plugins/vue-twoslash-queries.js +6 -15
- package/package.json +7 -7
|
@@ -3,46 +3,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.create = create;
|
|
4
4
|
const language_core_1 = require("@vue/language-core");
|
|
5
5
|
const html = require("vscode-html-languageservice");
|
|
6
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
7
6
|
const nameCasing_1 = require("../nameCasing");
|
|
8
|
-
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
function create(tsPluginClient) {
|
|
9
9
|
return {
|
|
10
10
|
name: 'vue-missing-props-hints',
|
|
11
11
|
capabilities: {
|
|
12
12
|
inlayHintProvider: {},
|
|
13
13
|
},
|
|
14
14
|
create(context) {
|
|
15
|
-
const tsPluginClient = getTsPluginClient?.(context);
|
|
16
15
|
let intrinsicElementNames;
|
|
17
16
|
return {
|
|
18
17
|
async provideInlayHints(document, range, cancellationToken) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
if (!context.project.vue) {
|
|
18
|
+
const info = (0, utils_1.getEmbeddedInfo)(context, document, 'template');
|
|
19
|
+
if (!info) {
|
|
23
20
|
return;
|
|
24
21
|
}
|
|
22
|
+
const { sourceScript, root } = info;
|
|
25
23
|
const enabled = await context.env.getConfiguration?.('vue.inlayHints.missingProps') ?? false;
|
|
26
24
|
if (!enabled) {
|
|
27
25
|
return;
|
|
28
26
|
}
|
|
29
|
-
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
30
|
-
const decoded = context.decodeEmbeddedDocumentUri(uri);
|
|
31
|
-
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
32
|
-
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
33
|
-
if (!virtualCode) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const root = sourceScript?.generated?.root;
|
|
37
|
-
if (!(root instanceof language_core_1.VueVirtualCode)) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
27
|
const scanner = getScanner(context, document);
|
|
41
28
|
if (!scanner) {
|
|
42
29
|
return;
|
|
43
30
|
}
|
|
44
31
|
const result = [];
|
|
45
|
-
const casing = await (0, nameCasing_1.checkCasing)(context,
|
|
32
|
+
const casing = await (0, nameCasing_1.checkCasing)(context, sourceScript.id);
|
|
46
33
|
const components = await tsPluginClient?.getComponentNames(root.fileName) ?? [];
|
|
47
34
|
const componentProps = {};
|
|
48
35
|
intrinsicElementNames ??= new Set(await tsPluginClient?.getElementNames(root.fileName) ?? []);
|
|
@@ -99,7 +86,7 @@ function create(getTsPluginClient) {
|
|
|
99
86
|
attrText = attrText.slice('v-model:'.length);
|
|
100
87
|
}
|
|
101
88
|
else if (attrText === 'v-model') {
|
|
102
|
-
attrText =
|
|
89
|
+
attrText = root.vueCompilerOptions.target >= 3 ? 'modelValue' : 'value'; // TODO: support for experimentalModelPropName?
|
|
103
90
|
}
|
|
104
91
|
else if (attrText.startsWith('v-on:')) {
|
|
105
92
|
attrText = 'on-' + (0, language_core_1.hyphenateAttr)(attrText.slice('v-on:'.length));
|
|
@@ -151,8 +138,5 @@ function create(getTsPluginClient) {
|
|
|
151
138
|
}
|
|
152
139
|
}
|
|
153
140
|
}
|
|
154
|
-
function isSupportedDocument(document) {
|
|
155
|
-
return document.languageId === 'jade' || document.languageId === 'html';
|
|
156
|
-
}
|
|
157
141
|
}
|
|
158
142
|
//# sourceMappingURL=vue-missing-props-hints.js.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.create = create;
|
|
4
|
+
const language_core_1 = require("@vue/language-core");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
function create() {
|
|
7
|
+
return {
|
|
8
|
+
name: 'vue-scoped-class-links',
|
|
9
|
+
capabilities: {
|
|
10
|
+
documentLinkProvider: {},
|
|
11
|
+
},
|
|
12
|
+
create(context) {
|
|
13
|
+
return {
|
|
14
|
+
provideDocumentLinks(document) {
|
|
15
|
+
const info = (0, utils_1.getEmbeddedInfo)(context, document, 'template');
|
|
16
|
+
if (!info) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const { sourceScript, root } = info;
|
|
20
|
+
const { sfc } = root;
|
|
21
|
+
const codegen = language_core_1.tsCodegen.get(sfc);
|
|
22
|
+
const option = root.vueCompilerOptions.resolveStyleClassNames;
|
|
23
|
+
const scopedClasses = codegen?.getGeneratedTemplate()?.scopedClasses ?? [];
|
|
24
|
+
const styleClasses = new Map();
|
|
25
|
+
for (let i = 0; i < sfc.styles.length; i++) {
|
|
26
|
+
const style = sfc.styles[i];
|
|
27
|
+
if (option !== true && !(option === 'scoped' && style.scoped)) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const styleDocumentUri = context.encodeEmbeddedDocumentUri(sourceScript.id, 'style_' + i);
|
|
31
|
+
const styleVirtualCode = sourceScript.generated.embeddedCodes.get('style_' + i);
|
|
32
|
+
if (!styleVirtualCode) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const styleDocument = context.documents.get(styleDocumentUri, styleVirtualCode.languageId, styleVirtualCode.snapshot);
|
|
36
|
+
for (const { text, offset } of style.classNames) {
|
|
37
|
+
const start = styleDocument.positionAt(offset);
|
|
38
|
+
const end = styleDocument.positionAt(offset + text.length);
|
|
39
|
+
const target = styleDocumentUri
|
|
40
|
+
+ `#L${start.line + 1},${start.character + 1}-L${end.line + 1},${end.character + 1}`;
|
|
41
|
+
if (!styleClasses.has(text)) {
|
|
42
|
+
styleClasses.set(text, []);
|
|
43
|
+
}
|
|
44
|
+
styleClasses.get(text).push(target);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return scopedClasses.flatMap(({ className, offset }) => {
|
|
48
|
+
const range = {
|
|
49
|
+
start: document.positionAt(offset),
|
|
50
|
+
end: document.positionAt(offset + className.length),
|
|
51
|
+
};
|
|
52
|
+
return styleClasses.get('.' + className)?.map(target => ({
|
|
53
|
+
range,
|
|
54
|
+
target,
|
|
55
|
+
})) ?? [];
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=vue-scoped-class-links.js.map
|
package/lib/plugins/vue-sfc.js
CHANGED
|
@@ -4,8 +4,8 @@ exports.create = create;
|
|
|
4
4
|
const language_core_1 = require("@vue/language-core");
|
|
5
5
|
const volar_service_html_1 = require("volar-service-html");
|
|
6
6
|
const html = require("vscode-html-languageservice");
|
|
7
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
8
7
|
const data_1 = require("./data");
|
|
8
|
+
const utils_1 = require("./utils");
|
|
9
9
|
let sfcDataProvider;
|
|
10
10
|
function create() {
|
|
11
11
|
const htmlService = (0, volar_service_html_1.create)({
|
|
@@ -16,25 +16,28 @@ function create() {
|
|
|
16
16
|
return [sfcDataProvider];
|
|
17
17
|
},
|
|
18
18
|
async getFormattingOptions(document, options, context) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
19
|
+
const info = (0, utils_1.getEmbeddedInfo)(context, document, 'root_tags');
|
|
20
|
+
if (!info) {
|
|
21
|
+
return {};
|
|
22
|
+
}
|
|
23
|
+
const { root } = info;
|
|
24
|
+
const formatSettings = await context.env.getConfiguration?.('html.format') ?? {};
|
|
25
|
+
const blockTypes = ['template', 'script', 'style'];
|
|
26
|
+
for (const customBlock of root.sfc.customBlocks) {
|
|
27
|
+
blockTypes.push(customBlock.type);
|
|
28
|
+
}
|
|
29
|
+
return {
|
|
30
|
+
...options,
|
|
31
|
+
...formatSettings,
|
|
32
|
+
wrapAttributes: await context.env.getConfiguration?.('vue.format.wrapAttributes') ?? 'auto',
|
|
33
|
+
unformatted: '',
|
|
34
|
+
contentUnformatted: blockTypes.join(','),
|
|
35
|
+
endWithNewline: options.insertFinalNewline
|
|
36
|
+
? true
|
|
37
|
+
: options.trimFinalNewlines
|
|
38
|
+
? false
|
|
39
|
+
: document.getText().endsWith('\n'),
|
|
40
|
+
};
|
|
38
41
|
},
|
|
39
42
|
});
|
|
40
43
|
return {
|
|
@@ -72,123 +75,129 @@ function create() {
|
|
|
72
75
|
}
|
|
73
76
|
return options;
|
|
74
77
|
},
|
|
75
|
-
provideDiagnostics(document, token) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
78
|
+
async provideDiagnostics(document, token) {
|
|
79
|
+
const info = (0, utils_1.getEmbeddedInfo)(context, document, 'root_tags');
|
|
80
|
+
if (!info) {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
const { root } = info;
|
|
84
|
+
const { vueSfc, sfc } = root;
|
|
85
|
+
if (!vueSfc) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const originalResult = await htmlServiceInstance.provideDiagnostics?.(document, token);
|
|
89
|
+
const sfcErrors = [];
|
|
90
|
+
const { template } = sfc;
|
|
91
|
+
const { startTagEnd = Infinity, endTagStart = -Infinity, } = template ?? {};
|
|
92
|
+
for (const error of vueSfc.errors) {
|
|
93
|
+
if ('code' in error) {
|
|
94
|
+
const start = error.loc?.start.offset ?? 0;
|
|
95
|
+
const end = error.loc?.end.offset ?? 0;
|
|
96
|
+
if (end < startTagEnd || start >= endTagStart) {
|
|
97
|
+
sfcErrors.push({
|
|
98
|
+
range: {
|
|
99
|
+
start: document.positionAt(start),
|
|
100
|
+
end: document.positionAt(end),
|
|
101
|
+
},
|
|
102
|
+
severity: 1,
|
|
103
|
+
code: error.code,
|
|
104
|
+
source: 'vue',
|
|
105
|
+
message: error.message,
|
|
106
|
+
});
|
|
101
107
|
}
|
|
102
108
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
109
|
+
}
|
|
110
|
+
return [
|
|
111
|
+
...originalResult ?? [],
|
|
112
|
+
...sfcErrors,
|
|
113
|
+
];
|
|
108
114
|
},
|
|
109
115
|
provideDocumentSymbols(document) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
result.push({
|
|
164
|
-
name,
|
|
165
|
-
kind: 2,
|
|
166
|
-
range: {
|
|
167
|
-
start: document.positionAt(style.start),
|
|
168
|
-
end: document.positionAt(style.end),
|
|
169
|
-
},
|
|
170
|
-
selectionRange: {
|
|
171
|
-
start: document.positionAt(style.start),
|
|
172
|
-
end: document.positionAt(style.startTagEnd),
|
|
173
|
-
},
|
|
174
|
-
});
|
|
116
|
+
const info = (0, utils_1.getEmbeddedInfo)(context, document, 'root_tags');
|
|
117
|
+
if (!info) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
const { root } = info;
|
|
121
|
+
const result = [];
|
|
122
|
+
const { sfc } = root;
|
|
123
|
+
if (sfc.template) {
|
|
124
|
+
result.push({
|
|
125
|
+
name: 'template',
|
|
126
|
+
kind: 2,
|
|
127
|
+
range: {
|
|
128
|
+
start: document.positionAt(sfc.template.start),
|
|
129
|
+
end: document.positionAt(sfc.template.end),
|
|
130
|
+
},
|
|
131
|
+
selectionRange: {
|
|
132
|
+
start: document.positionAt(sfc.template.start),
|
|
133
|
+
end: document.positionAt(sfc.template.startTagEnd),
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
if (sfc.script) {
|
|
138
|
+
result.push({
|
|
139
|
+
name: 'script',
|
|
140
|
+
kind: 2,
|
|
141
|
+
range: {
|
|
142
|
+
start: document.positionAt(sfc.script.start),
|
|
143
|
+
end: document.positionAt(sfc.script.end),
|
|
144
|
+
},
|
|
145
|
+
selectionRange: {
|
|
146
|
+
start: document.positionAt(sfc.script.start),
|
|
147
|
+
end: document.positionAt(sfc.script.startTagEnd),
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
if (sfc.scriptSetup) {
|
|
152
|
+
result.push({
|
|
153
|
+
name: 'script setup',
|
|
154
|
+
kind: 2,
|
|
155
|
+
range: {
|
|
156
|
+
start: document.positionAt(sfc.scriptSetup.start),
|
|
157
|
+
end: document.positionAt(sfc.scriptSetup.end),
|
|
158
|
+
},
|
|
159
|
+
selectionRange: {
|
|
160
|
+
start: document.positionAt(sfc.scriptSetup.start),
|
|
161
|
+
end: document.positionAt(sfc.scriptSetup.startTagEnd),
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
for (const style of sfc.styles) {
|
|
166
|
+
let name = 'style';
|
|
167
|
+
if (style.scoped) {
|
|
168
|
+
name += ' scoped';
|
|
175
169
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
name: `${customBlock.type}`,
|
|
179
|
-
kind: 2,
|
|
180
|
-
range: {
|
|
181
|
-
start: document.positionAt(customBlock.start),
|
|
182
|
-
end: document.positionAt(customBlock.end),
|
|
183
|
-
},
|
|
184
|
-
selectionRange: {
|
|
185
|
-
start: document.positionAt(customBlock.start),
|
|
186
|
-
end: document.positionAt(customBlock.startTagEnd),
|
|
187
|
-
},
|
|
188
|
-
});
|
|
170
|
+
if (style.module) {
|
|
171
|
+
name += ' module';
|
|
189
172
|
}
|
|
190
|
-
|
|
191
|
-
|
|
173
|
+
result.push({
|
|
174
|
+
name,
|
|
175
|
+
kind: 2,
|
|
176
|
+
range: {
|
|
177
|
+
start: document.positionAt(style.start),
|
|
178
|
+
end: document.positionAt(style.end),
|
|
179
|
+
},
|
|
180
|
+
selectionRange: {
|
|
181
|
+
start: document.positionAt(style.start),
|
|
182
|
+
end: document.positionAt(style.startTagEnd),
|
|
183
|
+
},
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
for (const customBlock of sfc.customBlocks) {
|
|
187
|
+
result.push({
|
|
188
|
+
name: `${customBlock.type}`,
|
|
189
|
+
kind: 2,
|
|
190
|
+
range: {
|
|
191
|
+
start: document.positionAt(customBlock.start),
|
|
192
|
+
end: document.positionAt(customBlock.end),
|
|
193
|
+
},
|
|
194
|
+
selectionRange: {
|
|
195
|
+
start: document.positionAt(customBlock.start),
|
|
196
|
+
end: document.positionAt(customBlock.startTagEnd),
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
return result;
|
|
192
201
|
},
|
|
193
202
|
async provideCompletionItems(document, position, context, token) {
|
|
194
203
|
const result = await htmlServiceInstance.provideCompletionItems?.(document, position, context, token);
|
|
@@ -262,18 +271,6 @@ function create() {
|
|
|
262
271
|
};
|
|
263
272
|
},
|
|
264
273
|
};
|
|
265
|
-
function worker(document, context, callback) {
|
|
266
|
-
if (document.languageId !== 'vue-root-tags') {
|
|
267
|
-
return;
|
|
268
|
-
}
|
|
269
|
-
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
270
|
-
const decoded = context.decodeEmbeddedDocumentUri(uri);
|
|
271
|
-
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
272
|
-
const root = sourceScript?.generated?.root;
|
|
273
|
-
if (root instanceof language_core_1.VueVirtualCode) {
|
|
274
|
-
return callback(root);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
274
|
}
|
|
278
275
|
function getStyleCompletionItem(styleItem, lang, attr) {
|
|
279
276
|
return {
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.create = create;
|
|
4
4
|
const language_core_1 = require("@vue/language-core");
|
|
5
|
-
const vscode_uri_1 = require("vscode-uri");
|
|
6
5
|
const utils_1 = require("./utils");
|
|
7
6
|
function create() {
|
|
8
7
|
return {
|
|
@@ -14,24 +13,15 @@ function create() {
|
|
|
14
13
|
return {
|
|
15
14
|
isAdditionalCompletion: true,
|
|
16
15
|
async provideCompletionItems(document) {
|
|
17
|
-
|
|
16
|
+
const info = (0, utils_1.getEmbeddedInfo)(context, document, id => id.startsWith('script_'));
|
|
17
|
+
if (!info) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
+
const { virtualCode, root } = info;
|
|
20
21
|
const enabled = await context.env.getConfiguration?.('vue.suggest.defineAssignment') ?? true;
|
|
21
22
|
if (!enabled) {
|
|
22
23
|
return;
|
|
23
24
|
}
|
|
24
|
-
const uri = vscode_uri_1.URI.parse(document.uri);
|
|
25
|
-
const decoded = context.decodeEmbeddedDocumentUri(uri);
|
|
26
|
-
const sourceScript = decoded && context.language.scripts.get(decoded[0]);
|
|
27
|
-
const virtualCode = decoded && sourceScript?.generated?.embeddedCodes.get(decoded[1]);
|
|
28
|
-
if (!sourceScript?.generated || !virtualCode) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
const root = sourceScript.generated.root;
|
|
32
|
-
if (!(root instanceof language_core_1.VueVirtualCode)) {
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
25
|
const { sfc } = root;
|
|
36
26
|
const codegen = language_core_1.tsCodegen.get(sfc);
|
|
37
27
|
const scriptSetup = sfc.scriptSetup;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.create = create;
|
|
4
|
+
const language_core_1 = require("@vue/language-core");
|
|
5
|
+
const utils_1 = require("./utils");
|
|
6
|
+
function create() {
|
|
7
|
+
return {
|
|
8
|
+
name: 'vue-template-ref-links',
|
|
9
|
+
capabilities: {
|
|
10
|
+
documentLinkProvider: {},
|
|
11
|
+
},
|
|
12
|
+
create(context) {
|
|
13
|
+
return {
|
|
14
|
+
provideDocumentLinks(document) {
|
|
15
|
+
const info = (0, utils_1.getEmbeddedInfo)(context, document, 'scriptsetup_raw');
|
|
16
|
+
if (!info) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const { sourceScript, root } = info;
|
|
20
|
+
const { sfc } = root;
|
|
21
|
+
const codegen = language_core_1.tsCodegen.get(sfc);
|
|
22
|
+
if (!sfc.scriptSetup) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
const templateVirtualCode = sourceScript.generated.embeddedCodes.get('template');
|
|
26
|
+
if (!templateVirtualCode) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const templateDocumentUri = context.encodeEmbeddedDocumentUri(sourceScript.id, 'template');
|
|
30
|
+
const templateDocument = context.documents.get(templateDocumentUri, templateVirtualCode.languageId, templateVirtualCode.snapshot);
|
|
31
|
+
const templateRefs = codegen?.getGeneratedTemplate()?.templateRefs;
|
|
32
|
+
const useTemplateRefs = codegen?.getScriptSetupRanges()?.useTemplateRef ?? [];
|
|
33
|
+
return useTemplateRefs.flatMap(({ arg }) => {
|
|
34
|
+
if (!arg) {
|
|
35
|
+
return [];
|
|
36
|
+
}
|
|
37
|
+
const name = sfc.scriptSetup.content.slice(arg.start + 1, arg.end - 1);
|
|
38
|
+
const range = {
|
|
39
|
+
start: document.positionAt(arg.start + 1),
|
|
40
|
+
end: document.positionAt(arg.end - 1),
|
|
41
|
+
};
|
|
42
|
+
return templateRefs?.get(name)?.map(({ offset }) => {
|
|
43
|
+
const start = templateDocument.positionAt(offset);
|
|
44
|
+
const end = templateDocument.positionAt(offset + name.length);
|
|
45
|
+
return {
|
|
46
|
+
range,
|
|
47
|
+
target: templateDocumentUri
|
|
48
|
+
+ `#L${start.line + 1},${start.character + 1}-L${end.line + 1},${end.character + 1}`,
|
|
49
|
+
};
|
|
50
|
+
}) ?? [];
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=vue-template-ref-links.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function create(mode: 'html' | 'pug',
|
|
1
|
+
import type { LanguageServicePlugin } from '@volar/language-service';
|
|
2
|
+
export declare function create(mode: 'html' | 'pug', tsPluginClient: import('@vue/typescript-plugin/lib/requests').Requests | undefined): LanguageServicePlugin;
|