@vue/typescript-plugin 3.2.2 → 3.2.3
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/lib/common.js +92 -6
- package/package.json +4 -4
package/lib/common.js
CHANGED
|
@@ -10,10 +10,10 @@ const language_core_1 = require("@vue/language-core");
|
|
|
10
10
|
const shared_1 = require("@vue/shared");
|
|
11
11
|
const windowsPathReg = /\\/g;
|
|
12
12
|
function preprocessLanguageService(languageService, getLanguage) {
|
|
13
|
-
const { getQuickInfoAtPosition, getSuggestionDiagnostics, getCompletionsAtPosition, getCodeFixesAtPosition, } = languageService;
|
|
13
|
+
const { getQuickInfoAtPosition, getSuggestionDiagnostics, getCompletionsAtPosition, getCodeFixesAtPosition, findRenameLocations, } = languageService;
|
|
14
14
|
languageService.getQuickInfoAtPosition = (fileName, position, ...rests) => {
|
|
15
15
|
const result = getQuickInfoAtPosition(fileName, position, ...rests);
|
|
16
|
-
if (!result) {
|
|
16
|
+
if (!result || result.tags?.length) {
|
|
17
17
|
return result;
|
|
18
18
|
}
|
|
19
19
|
const language = getLanguage();
|
|
@@ -32,10 +32,7 @@ function preprocessLanguageService(languageService, getLanguage) {
|
|
|
32
32
|
const variableName = serviceScript.code.snapshot.getText(generateRange2[0] - leadingOffset, generateRange2[1] - leadingOffset);
|
|
33
33
|
if (codegen?.getSetupExposed().has(variableName)) {
|
|
34
34
|
const extraInfo = getQuickInfoAtPosition(fileName, generateRange2[0], ...rests);
|
|
35
|
-
|
|
36
|
-
result.tags ??= [];
|
|
37
|
-
result.tags.push(...extraInfo.tags ?? []);
|
|
38
|
-
}
|
|
35
|
+
result.tags = extraInfo?.tags;
|
|
39
36
|
}
|
|
40
37
|
}
|
|
41
38
|
}
|
|
@@ -132,6 +129,95 @@ function preprocessLanguageService(languageService, getLanguage) {
|
|
|
132
129
|
}
|
|
133
130
|
return result;
|
|
134
131
|
};
|
|
132
|
+
languageService.findRenameLocations = (fileName, position, ...rests) => {
|
|
133
|
+
// @ts-expect-error
|
|
134
|
+
const result = findRenameLocations(fileName, position, ...rests);
|
|
135
|
+
if (!result?.length) {
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
138
|
+
const language = getLanguage();
|
|
139
|
+
if (!language) {
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
const [serviceScript, _targetScript, sourceScript] = (0, utils_1.getServiceScript)(language, fileName);
|
|
143
|
+
if (!serviceScript || !(sourceScript?.generated?.root instanceof language_core_1.VueVirtualCode)) {
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
146
|
+
const map = language.maps.get(serviceScript.code, sourceScript);
|
|
147
|
+
const leadingOffset = sourceScript.snapshot.getLength();
|
|
148
|
+
const isShorthand = (data) => !!data.__shorthandExpression;
|
|
149
|
+
// { foo: __VLS_ctx.foo }
|
|
150
|
+
// ^^^ ^^^
|
|
151
|
+
// if the rename is triggered directly on the shorthand,
|
|
152
|
+
// skip the entire request on the generated property name
|
|
153
|
+
if ([...map.toSourceLocation(position - leadingOffset, isShorthand)].length === 0) {
|
|
154
|
+
for (const [offset] of map.toSourceLocation(position - leadingOffset, () => true)) {
|
|
155
|
+
for (const _ of map.toGeneratedLocation(offset, isShorthand)) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const preferAlias = typeof rests[2] === 'boolean'
|
|
161
|
+
? rests[2]
|
|
162
|
+
: rests[2]?.providePrefixAndSuffixTextForRename ?? true;
|
|
163
|
+
if (!preferAlias) {
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
const locations = [...result];
|
|
167
|
+
outer: for (let i = 0; i < locations.length; i++) {
|
|
168
|
+
const { textSpan } = locations[i];
|
|
169
|
+
const generatedLeft = textSpan.start - leadingOffset;
|
|
170
|
+
const generatedRight = textSpan.start + textSpan.length - leadingOffset;
|
|
171
|
+
// { foo: __VLS_ctx.foo }
|
|
172
|
+
// ^^^
|
|
173
|
+
for (const [start, end, { data }] of map.toSourceRange(generatedLeft, generatedRight, true, isShorthand)) {
|
|
174
|
+
locations.splice(i, 1, {
|
|
175
|
+
...locations[i],
|
|
176
|
+
...getPrefixAndSuffixForShorthandRename(data.__shorthandExpression, 'right', sourceScript.snapshot.getText(start, end)),
|
|
177
|
+
});
|
|
178
|
+
continue outer;
|
|
179
|
+
}
|
|
180
|
+
// { foo: __VLS_ctx.foo }
|
|
181
|
+
// ^^^
|
|
182
|
+
for (const [start, end] of map.toSourceRange(generatedLeft, generatedRight, true, () => true)) {
|
|
183
|
+
for (const [, , { data }] of map.toGeneratedRange(start, end, true, isShorthand)) {
|
|
184
|
+
locations.splice(i, 1, {
|
|
185
|
+
...locations[i],
|
|
186
|
+
...getPrefixAndSuffixForShorthandRename(data.__shorthandExpression, 'left', sourceScript.snapshot.getText(start, end)),
|
|
187
|
+
});
|
|
188
|
+
continue outer;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return locations;
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function getPrefixAndSuffixForShorthandRename(type, target, originalText) {
|
|
196
|
+
if (type === 'html') {
|
|
197
|
+
if (target === 'left') {
|
|
198
|
+
return {
|
|
199
|
+
suffixText: `="${(0, shared_1.camelize)(originalText)}"`,
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
return {
|
|
204
|
+
prefixText: `${originalText}="`,
|
|
205
|
+
suffixText: `"`,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
if (target === 'left') {
|
|
211
|
+
return {
|
|
212
|
+
suffixText: `: ${originalText}`,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
return {
|
|
217
|
+
prefixText: `${originalText}: `,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
135
221
|
}
|
|
136
222
|
function postprocessLanguageService(ts, language, languageService, vueOptions, asScriptId) {
|
|
137
223
|
const proxyCache = new Map();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/typescript-plugin",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@volar/typescript": "2.4.27",
|
|
17
|
-
"@vue/language-core": "3.2.
|
|
17
|
+
"@vue/language-core": "3.2.3",
|
|
18
18
|
"@vue/shared": "^3.5.0",
|
|
19
19
|
"path-browserify": "^1.0.1",
|
|
20
|
-
"vue-component-meta": "3.2.
|
|
20
|
+
"vue-component-meta": "3.2.3"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/node": "^22.10.4",
|
|
24
24
|
"@types/path-browserify": "^1.0.1"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "efc6882ab62a518b41ab5c8dc1d762c41c862ebc"
|
|
27
27
|
}
|