Skip to content

Commit ff4fa1f

Browse files
Cleaned up refactoring names, descriptions.
1 parent ad0f006 commit ff4fa1f

File tree

24 files changed

+72
-79
lines changed

24 files changed

+72
-79
lines changed

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5341,14 +5341,10 @@
53415341
"category": "Message",
53425342
"code": 95095
53435343
},
5344-
"Convert string concatenation or template literal": {
5344+
"Convert to template string": {
53455345
"category": "Message",
53465346
"code": 95096
53475347
},
5348-
"Convert to template literal": {
5349-
"category": "Message",
5350-
"code": 95097
5351-
},
53525348

53535349
"No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": {
53545350
"category": "Error",

src/services/refactors/convertStringOrTemplateLiteral.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
/* @internal */
22
namespace ts.refactor.convertStringOrTemplateLiteral {
3-
const refactorName = "Convert string concatenation or template literal";
4-
const toTemplateLiteralActionName = "Convert to template literal";
5-
6-
const refactorDescription = getLocaleSpecificMessage(Diagnostics.Convert_string_concatenation_or_template_literal);
7-
const toTemplateLiteralDescription = getLocaleSpecificMessage(Diagnostics.Convert_to_template_literal);
3+
const refactorName = "Convert to template string";
4+
const refactorDescription = getLocaleSpecificMessage(Diagnostics.Convert_to_template_string);
85

96
registerRefactor(refactorName, { getEditsForAction, getAvailableActions });
107

@@ -15,7 +12,7 @@ namespace ts.refactor.convertStringOrTemplateLiteral {
1512
const refactorInfo: ApplicableRefactorInfo = { name: refactorName, description: refactorDescription, actions: [] };
1613

1714
if ((isBinaryExpression(maybeBinary) || isStringLiteral(maybeBinary)) && isStringConcatenationValid(maybeBinary)) {
18-
refactorInfo.actions.push({ name: toTemplateLiteralActionName, description: toTemplateLiteralDescription });
15+
refactorInfo.actions.push({ name: refactorName, description: refactorDescription });
1916
return [refactorInfo];
2017
}
2118
return emptyArray;
@@ -36,12 +33,12 @@ namespace ts.refactor.convertStringOrTemplateLiteral {
3633
return node;
3734
}
3835

39-
function getEditsForAction(context: RefactorContext, actionName: typeof toTemplateLiteralActionName): RefactorEditInfo | undefined {
36+
function getEditsForAction(context: RefactorContext, actionName: string): RefactorEditInfo | undefined {
4037
const { file, startPosition } = context;
4138
const node = getNodeOrParentOfParentheses(file, startPosition);
4239

4340
switch (actionName) {
44-
case toTemplateLiteralActionName:
41+
case refactorDescription:
4542
return { edits: getEditsForToTemplateLiteral(context, node) };
4643
default:
4744
return Debug.fail("invalid action");

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateAsFnArgument.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
`console.log(\`foobar is \${32} years old\`)`,
1212
});

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateBackTick.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
"const foo = `with back\\`tick`",
1212
});

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateBinaryExpr.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
`const foo = \`foobar is \${42 + 6} years old\``,
1212
});

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateBinaryExprInEnding.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
"const foo = `foobar is \${42 + 6}`",
1212
});

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateComment.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
"const foo = /* C0 */ `foo is\${ /* C1 */ /* C2 */42 /* C3 */} and bar is\${ /* C4 */ /* C5 */52 /* C6 */}`",
1212
});

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateCommentAfterOperator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
"const foo = /* C0 */ `foo is\${ /* C1 */ /* C2 */42 /* C3 */} and bar is\${ /* C4 */ /* C5 */52 /* C6 */}`",
1212
});

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateCommentNoExpr.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
"const foo = /* C0 */ `foo is` /* C1 */ /* C2 */ /* C3 */",
1212
});

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateCommentParenth.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
"const foo = `foobar is\${/* C1 */ 42 /* C2 */ /* C3 */} years old`",
1212
});

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateCommentTrailingExpr.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
"const foo = /* C0 */ `foo is\${ /* C1 */ /* C2 */42 /* C3 */}`",
1212
});

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateCommentTrailingStr.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
"const foo = /* C0 */ `foo is\${ /* C1 */ /* C2 */42} years old` /* C3 */",
1212
});

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateConsecutiveStr.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
`const foo = \`foobar is \${42} years old and \${6} cars are missing\``,
1212
});

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateMultiExpr.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
goTo.select("x", "y");
88
edit.applyRefactor({
9-
refactorName: "Convert string concatenation or template literal",
10-
actionName: "Convert to template literal",
11-
actionDescription: "Convert to template literal",
9+
refactorName: "Convert to template string",
10+
actionName: "Convert to template string",
11+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1212
newContent:
1313
`const age = 22
1414
const name = "Eddy"

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateOneExpr.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
goTo.select("x", "y");
77
edit.applyRefactor({
8-
refactorName: "Convert string concatenation or template literal",
9-
actionName: "Convert to template literal",
10-
actionDescription: "Convert to template literal",
8+
refactorName: "Convert to template string",
9+
actionName: "Convert to template string",
10+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1111
newContent:
1212
`const age = 42
1313
const foo = \`foobar is \${age} years old\``,

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateOnlyStr.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
"const foo = `foobar rocks fantastically`",
1212
});

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateOtherExprSeq.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
`const foo = \`foobar is \${42 * 6 / 4} years old\``,
1212
});

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateParenthFromExpr.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
`const foo = \`foobar is \${42 + 6} years old\``,
1212
});

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateParenthFromOpening.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
`const foo = \`foobar is \${42 + 6} years old\``,
1212
});

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateParenthFromStr.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
`const foo = "foobar is " + (\`\${42 + 6}str\`) + " years old"`,
1212
});

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplatePlusExprSeq.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
`const foo = \`foobar is \${42}\${6} years old\``,
1212
});

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplatePrefixExpr.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
`const foo = \`\${42 - 6 * 4 + 23 / 12} years old\``,
1212
});

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateSimple.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
`const foo = \`foobar rocks\``,
1212
});

tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateSingleQuote.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
goTo.select("x", "y");
66
edit.applyRefactor({
7-
refactorName: "Convert string concatenation or template literal",
8-
actionName: "Convert to template literal",
9-
actionDescription: "Convert to template literal",
7+
refactorName: "Convert to template string",
8+
actionName: "Convert to template string",
9+
actionDescription: ts.Diagnostics.Convert_to_template_string.message,
1010
newContent:
1111
`const foo = \`foobar rocks\``,
1212
});

0 commit comments

Comments
 (0)