Skip to content

Commit a2027e9

Browse files
committed
refactor(language-core): remove invalid rename hooks
1 parent 34538b9 commit a2027e9

File tree

4 files changed

+7
-59
lines changed

4 files changed

+7
-59
lines changed

packages/language-core/lib/codegen/script/src.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,7 @@ export function* generateSrc(src: SfcBlockAttr): Generator<Code> {
2525
yield `export * from `;
2626
yield* generateSfcBlockAttrValue(src, text, {
2727
...codeFeatures.all,
28-
navigation: text === src.text
29-
? true
30-
: {
31-
shouldRename: () => false,
32-
resolveRenameEditText(newName) {
33-
if (newName.endsWith('.jsx') || newName.endsWith('.js')) {
34-
newName = newName.split('.').slice(0, -1).join('.');
35-
}
36-
if (src?.text.endsWith('.d.ts')) {
37-
newName = newName + '.d.ts';
38-
}
39-
else if (src?.text.endsWith('.ts')) {
40-
newName = newName + '.ts';
41-
}
42-
else if (src?.text.endsWith('.tsx')) {
43-
newName = newName + '.tsx';
44-
}
45-
return newName;
46-
},
47-
},
28+
...text === src.text ? codeFeatures.navigation : codeFeatures.navigationWithoutRename,
4829
});
4930
yield endOfLine;
5031
yield `export { default } from '${text}'${endOfLine}`;

packages/language-core/lib/codegen/template/element.ts

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as CompilerDOM from '@vue/compiler-dom';
22
import { camelize, capitalize } from '@vue/shared';
33
import type { Code, VueCodeInformation } from '../../types';
44
import { getSlotsPropertyName, hyphenateTag } from '../../utils/shared';
5+
import { codeFeatures } from '../codeFeatures';
56
import { createVBindShorthandInlayHintInfo } from '../inlayHints';
67
import { endOfLine, identifierRegex, newLine, normalizeAttributeValue } from '../utils';
78
import { generateCamelized } from '../utils/camelized';
@@ -102,13 +103,7 @@ export function* generateComponent(
102103
shouldCapitalize ? capitalize(node.tag) : node.tag,
103104
'template',
104105
tagOffset,
105-
{
106-
...ctx.codeFeatures.withoutHighlightAndCompletion,
107-
navigation: {
108-
resolveRenameNewName: camelizeComponentName,
109-
resolveRenameEditText: getTagRenameApply(node.tag),
110-
},
111-
}
106+
ctx.codeFeatures.withoutHighlightAndCompletion
112107
);
113108
}
114109
yield `, `;
@@ -171,18 +166,12 @@ export function* generateComponent(
171166
yield `/** @type {[`;
172167
for (const tagOffset of tagOffsets) {
173168
for (const shouldCapitalize of (node.tag[0] === node.tag[0].toUpperCase() ? [false] : [true, false])) {
174-
const expectName = shouldCapitalize ? capitalize(camelizedTag) : camelizedTag;
175169
yield `typeof __VLS_components.`;
176170
yield* generateCamelized(
177171
shouldCapitalize ? capitalize(node.tag) : node.tag,
178172
'template',
179173
tagOffset,
180-
{
181-
navigation: {
182-
resolveRenameNewName: node.tag !== expectName ? camelizeComponentName : undefined,
183-
resolveRenameEditText: getTagRenameApply(node.tag),
184-
},
185-
}
174+
codeFeatures.navigation
186175
);
187176
yield `, `;
188177
}
@@ -510,11 +499,3 @@ function hasVBindAttrs(
510499
)
511500
);
512501
}
513-
514-
function camelizeComponentName(newName: string) {
515-
return camelize('-' + newName);
516-
}
517-
518-
function getTagRenameApply(oldName: string) {
519-
return oldName === hyphenateTag(oldName) ? hyphenateTag : undefined;
520-
}

packages/language-core/lib/codegen/template/elementDirectives.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import * as CompilerDOM from '@vue/compiler-dom';
22
import { camelize } from '@vue/shared';
33
import type { Code } from '../../types';
4-
import { hyphenateAttr } from '../../utils/shared';
54
import { codeFeatures } from '../codeFeatures';
65
import { endOfLine } from '../utils';
76
import { generateCamelized } from '../utils/camelized';
@@ -77,10 +76,6 @@ function* generateIdentifier(
7776
// fix https://github.com/vuejs/language-tools/issues/1905
7877
...codeFeatures.additionalCompletion,
7978
verification: options.vueCompilerOptions.checkUnknownDirectives && !builtInDirectives.has(prop.name),
80-
navigation: {
81-
resolveRenameNewName: camelize,
82-
resolveRenameEditText: getPropRenameApply(prop.name),
83-
},
8479
})
8580
)
8681
);
@@ -187,7 +182,3 @@ function* generateValue(
187182
ctx.codeFeatures.all
188183
);
189184
}
190-
191-
function getPropRenameApply(oldName: string) {
192-
return oldName === hyphenateAttr(oldName) ? hyphenateAttr : undefined;
193-
}

packages/language-core/lib/codegen/template/elementProps.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export function* generateElementProps(
113113

114114
const shouldSpread = propName === 'style' || propName === 'class';
115115
const shouldCamelize = isComponent && getShouldCamelize(options, prop, propName);
116-
const codeInfo = getPropsCodeInfo(ctx, strictPropsCheck, shouldCamelize);
116+
const codeInfo = getPropsCodeInfo(ctx, strictPropsCheck);
117117

118118
if (shouldSpread) {
119119
yield `...{ `;
@@ -197,7 +197,7 @@ export function* generateElementProps(
197197

198198
const shouldSpread = prop.name === 'style' || prop.name === 'class';
199199
const shouldCamelize = isComponent && getShouldCamelize(options, prop, prop.name);
200-
const codeInfo = getPropsCodeInfo(ctx, strictPropsCheck, true);
200+
const codeInfo = getPropsCodeInfo(ctx, strictPropsCheck);
201201

202202
if (shouldSpread) {
203203
yield `...{ `;
@@ -378,15 +378,10 @@ function getShouldCamelize(
378378

379379
function getPropsCodeInfo(
380380
ctx: TemplateCodegenContext,
381-
strictPropsCheck: boolean,
382-
shouldCamelize: boolean
381+
strictPropsCheck: boolean
383382
): VueCodeInformation {
384383
return ctx.resolveCodeFeatures({
385384
...codeFeatures.withoutHighlightAndCompletion,
386-
navigation: {
387-
resolveRenameNewName: camelize,
388-
resolveRenameEditText: shouldCamelize ? hyphenateAttr : undefined,
389-
},
390385
verification: strictPropsCheck || {
391386
shouldReport(_source, code) {
392387
// https://typescript.tv/errors/#ts2353

0 commit comments

Comments
 (0)