Cleaned up refactoring names, descriptions.

This commit is contained in:
Daniel Rosenwasser
2020-01-02 16:32:06 -08:00
parent ad0f0064ce
commit ff4fa1feb9
24 changed files with 72 additions and 79 deletions

View File

@@ -5341,14 +5341,10 @@
"category": "Message",
"code": 95095
},
"Convert string concatenation or template literal": {
"Convert to template string": {
"category": "Message",
"code": 95096
},
"Convert to template literal": {
"category": "Message",
"code": 95097
},
"No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": {
"category": "Error",

View File

@@ -1,10 +1,7 @@
/* @internal */
namespace ts.refactor.convertStringOrTemplateLiteral {
const refactorName = "Convert string concatenation or template literal";
const toTemplateLiteralActionName = "Convert to template literal";
const refactorDescription = getLocaleSpecificMessage(Diagnostics.Convert_string_concatenation_or_template_literal);
const toTemplateLiteralDescription = getLocaleSpecificMessage(Diagnostics.Convert_to_template_literal);
const refactorName = "Convert to template string";
const refactorDescription = getLocaleSpecificMessage(Diagnostics.Convert_to_template_string);
registerRefactor(refactorName, { getEditsForAction, getAvailableActions });
@@ -15,7 +12,7 @@ namespace ts.refactor.convertStringOrTemplateLiteral {
const refactorInfo: ApplicableRefactorInfo = { name: refactorName, description: refactorDescription, actions: [] };
if ((isBinaryExpression(maybeBinary) || isStringLiteral(maybeBinary)) && isStringConcatenationValid(maybeBinary)) {
refactorInfo.actions.push({ name: toTemplateLiteralActionName, description: toTemplateLiteralDescription });
refactorInfo.actions.push({ name: refactorName, description: refactorDescription });
return [refactorInfo];
}
return emptyArray;
@@ -36,12 +33,12 @@ namespace ts.refactor.convertStringOrTemplateLiteral {
return node;
}
function getEditsForAction(context: RefactorContext, actionName: typeof toTemplateLiteralActionName): RefactorEditInfo | undefined {
function getEditsForAction(context: RefactorContext, actionName: string): RefactorEditInfo | undefined {
const { file, startPosition } = context;
const node = getNodeOrParentOfParentheses(file, startPosition);
switch (actionName) {
case toTemplateLiteralActionName:
case refactorDescription:
return { edits: getEditsForToTemplateLiteral(context, node) };
default:
return Debug.fail("invalid action");