diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 4acfec04a5d..5d7f57dc3db 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -5349,10 +5349,6 @@ "category": "Message", "code": 95097 }, - "Convert to string concatenation": { - "category": "Message", - "code": 95098 - }, "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer.": { "category": "Error", diff --git a/src/services/refactors/convertStringOrTemplateLiteral.ts b/src/services/refactors/convertStringOrTemplateLiteral.ts index e78ad405d40..a05eab0df39 100644 --- a/src/services/refactors/convertStringOrTemplateLiteral.ts +++ b/src/services/refactors/convertStringOrTemplateLiteral.ts @@ -2,11 +2,9 @@ namespace ts.refactor.convertStringOrTemplateLiteral { const refactorName = "Convert string concatenation or template literal"; const toTemplateLiteralActionName = "Convert to template literal"; - const toStringConcatenationActionName = "Convert to string concatenation"; const refactorDescription = getLocaleSpecificMessage(Diagnostics.Convert_string_concatenation_or_template_literal); const toTemplateLiteralDescription = getLocaleSpecificMessage(Diagnostics.Convert_to_template_literal); - const toStringConcatenationDescription = getLocaleSpecificMessage(Diagnostics.Convert_to_string_concatenation); registerRefactor(refactorName, { getEditsForAction, getAvailableActions }); @@ -20,14 +18,6 @@ namespace ts.refactor.convertStringOrTemplateLiteral { refactorInfo.actions.push({ name: toTemplateLiteralActionName, description: toTemplateLiteralDescription }); return [refactorInfo]; } - - const templateLiteral = findAncestor(node, n => isTemplateLiteral(n)); - - if (templateLiteral && !isTaggedTemplateExpression(templateLiteral.parent)) { - refactorInfo.actions.push({ name: toStringConcatenationActionName, description: toStringConcatenationDescription }); - return [refactorInfo]; - } - return emptyArray; } @@ -46,17 +36,13 @@ namespace ts.refactor.convertStringOrTemplateLiteral { return node; } - function getEditsForAction(context: RefactorContext, actionName: string): RefactorEditInfo | undefined { + function getEditsForAction(context: RefactorContext, actionName: typeof toTemplateLiteralActionName): RefactorEditInfo | undefined { const { file, startPosition } = context; const node = getNodeOrParentOfParentheses(file, startPosition); switch (actionName) { case toTemplateLiteralActionName: return { edits: getEditsForToTemplateLiteral(context, node) }; - - case toStringConcatenationActionName: - return { edits: getEditsForToStringConcatenation(context, node) }; - default: return Debug.fail("invalid action"); } @@ -85,33 +71,6 @@ namespace ts.refactor.convertStringOrTemplateLiteral { } } - const templateSpanToExpressions = (file: SourceFile) => (templateSpan: TemplateSpan): Expression[] => { - const { expression, literal } = templateSpan; - const text = literal.text; - copyTrailingAsLeadingComments(templateSpan, expression, file, SyntaxKind.MultiLineCommentTrivia, /* hasTrailingNewLine */ false); - return text.length === 0 ? [expression] : [expression, createStringLiteral(text)]; - }; - - function getEditsForToStringConcatenation(context: RefactorContext, node: Node) { - const templateLiteral = findAncestor(node, n => isTemplateLiteral(n))! as TemplateLiteral; - - if (isTemplateExpression(templateLiteral)) { - const { head, templateSpans } = templateLiteral; - const spanToExpressionWithComment = templateSpanToExpressions(context.file); - const arrayOfNodes = templateSpans.map(spanToExpressionWithComment) - .reduce((accumulator, nextArray) => accumulator.concat(nextArray)); - - if (head.text.length !== 0) arrayOfNodes.unshift(createStringLiteral(head.text)); - - const singleExpressionOrBinary = makeSingleExpressionOrBinary(arrayOfNodes); - return textChanges.ChangeTracker.with(context, t => t.replaceNode(context.file, templateLiteral, singleExpressionOrBinary)); - } - else { - const stringLiteral = createStringLiteral(templateLiteral.text); - return textChanges.ChangeTracker.with(context, t => t.replaceNode(context.file, node, stringLiteral)); - } - } - function isNotEqualsOperator(node: BinaryExpression) { return node.operatorToken.kind !== SyntaxKind.EqualsToken; } @@ -123,26 +82,6 @@ namespace ts.refactor.convertStringOrTemplateLiteral { return expr; } - function makeSingleExpressionOrBinary(nodes: readonly Expression[]): Expression { - if (nodes.length > 1) { - const left = nodes[0]; - const right = nodes[1]; - - const binary = createBinary(left, SyntaxKind.PlusToken, right); - return arrayToTree(nodes, 2, binary); - } - - return nodes[0]; - } - - function arrayToTree(nodes: readonly Expression[], index: number, accumulator: BinaryExpression): Expression { - if (nodes.length === index) return accumulator; - - const right = nodes[index]; - const binary = createBinary(accumulator, SyntaxKind.PlusToken, right); - return arrayToTree(nodes, index + 1, binary); - } - function isStringConcatenationValid(node: Node): boolean { const { containsString, areOperatorsValid } = treeToArray(node); return containsString && areOperatorsValid; diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringAsFnArgument.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringAsFnArgument.ts deleted file mode 100644 index de79522269a..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringAsFnArgument.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -//// console.log(`/*x*/f/*y*/oobar is ${ 32 } years old`) - -goTo.select("x", "y"); -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to string concatenation", - actionDescription: "Convert to string concatenation", - newContent: -`console.log("foobar is " + 32 + " years old")`, -}); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringAvailability.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringAvailability.ts deleted file mode 100644 index 84db4c09f04..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringAvailability.ts +++ /dev/null @@ -1,39 +0,0 @@ -/// - -//// const age = 22 -//// const name = "Eddy" -//// const /*z*/f/*y*/oo = /*x*/`/*w*/M/*v*/r/*u*/ /*t*/$/*s*/{ /*r*/n/*q*/ame } is ${ /*p*/a/*o*/ge + 34 } years old` - -goTo.select("z", "y"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("x", "w"); -verify.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("v", "u"); -verify.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("t", "s"); -verify.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("r", "q"); -verify.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("p", "o"); -verify.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to string concatenation", - actionDescription: "Convert to string concatenation", - newContent: -`const age = 22 -const name = "Eddy" -const foo = "Mr " + name + " is " + (age + 34) + " years old"`, -}); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringAvailabilityTagged.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringAvailabilityTagged.ts deleted file mode 100644 index 0b02128f3e9..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringAvailabilityTagged.ts +++ /dev/null @@ -1,17 +0,0 @@ -/// - -//// function tag(literals: TemplateStringsArray, ...placeholders: any[]) { return "tagged" } -//// const alpha = tag/*z*/`/*y*/foobar` -//// const beta = tag/*x*/`/*w*/foobar ${/*v*/4/*u*/2}` - -goTo.select("z", "y"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("x", "w"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("v", "u"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringBinaryExpr.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringBinaryExpr.ts deleted file mode 100644 index 1850b40f22c..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringBinaryExpr.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -//// const foo = `/*x*/f/*y*/oobar is ${ 42 + 6 } years old` - -goTo.select("x", "y"); -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to string concatenation", - actionDescription: "Convert to string concatenation", - newContent: -`const foo = "foobar is " + (42 + 6) + " years old"`, -}); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringComment.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringComment.ts deleted file mode 100644 index d895c9c4306..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringComment.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -//// const foo = /* H */ `/*x*/H/*y*/EAD ${ /* C0 */ 42 /* C1 */} Span1 ${ /* C2 */ 43 /* C3 */} Span2 ${ /* C4 */ 44 /* C5 */} Span3` /* T */ - -goTo.select("x", "y"); -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to string concatenation", - actionDescription: "Convert to string concatenation", - newContent: -`const foo = /* H */ "HEAD " + /* C0 */ 42 /* C1 */ + " Span1 " + /* C2 */ 43 /* C3 */ + " Span2 " + /* C4 */ 44 /* C5 */ + " Span3" /* T */`, -}); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringCommentOnlyExpr.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringCommentOnlyExpr.ts deleted file mode 100644 index 07f1ddba4d9..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringCommentOnlyExpr.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -//// const foo = /*x*/`/*y*/${/* C0 */ 42 /* C1 */}` - -goTo.select("x", "y"); -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to string concatenation", - actionDescription: "Convert to string concatenation", - newContent: -`const foo = /* C0 */ 42 /* C1 */`, -}); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringCommentWithoutStr.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringCommentWithoutStr.ts deleted file mode 100644 index 18fe962e728..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringCommentWithoutStr.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -//// const foo = `/*x*/H/*y*/EAD | ${ /* C0 */ 42 /* C1 */}${ /* C2 */ 43 /* C3 */}${ /* C4 */ 44 /* C5 */}` - -goTo.select("x", "y"); -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to string concatenation", - actionDescription: "Convert to string concatenation", - newContent: -`const foo = "HEAD | " + /* C0 */ 42 /* C1 */ + /* C2 */ 43 /* C3 */ + /* C4 */ 44 /* C5 */`, -}); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringMultiExpr.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringMultiExpr.ts deleted file mode 100644 index 3fdd7fb6362..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringMultiExpr.ts +++ /dev/null @@ -1,16 +0,0 @@ -/// - -//// const age = 22 -//// const name = "Eddy" -//// const foo = `/*x*/$/*y*/{ name } is ${ age } years old` - -goTo.select("x", "y"); -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to string concatenation", - actionDescription: "Convert to string concatenation", - newContent: -`const age = 22 -const name = "Eddy" -const foo = name + " is " + age + " years old"`, -}); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringNestedInner.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringNestedInner.ts deleted file mode 100644 index 710d0f97489..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringNestedInner.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// - -//// const age = 42 -//// const foo = `foobar is a ${ age < 18 ? 'child' : /*x*/`/*y*/grown-up ${ age > 40 ? 'who needs probably assistance' : ''}` }` - -goTo.select("x", "y"); -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to string concatenation", - actionDescription: "Convert to string concatenation", - newContent: -`const age = 42 -const foo = \`foobar is a \${ age < 18 ? 'child' : "grown-up " + (age > 40 ? 'who needs probably assistance' : '') }\``, -}); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringNestedInnerNonSub.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringNestedInnerNonSub.ts deleted file mode 100644 index 83783e4d658..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringNestedInnerNonSub.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// - -//// const age = 42 -//// const foo = `foobar is a ${ `/*x*/3/*y*/4` }` - -goTo.select("x", "y"); -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to string concatenation", - actionDescription: "Convert to string concatenation", - newContent: -`const age = 42 -const foo = \`foobar is a \${ "34" }\``, -}); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringNestedOuter.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringNestedOuter.ts deleted file mode 100644 index fb09d7876b9..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringNestedOuter.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// - -//// const age = 42 -//// const foo = `foobar is a ${ /*x*/a/*y*/ge < 18 ? 'child' : `grown-up ${ age > 40 ? 'who needs probaply assistance': ''}` }` - -goTo.select("x", "y"); -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to string concatenation", - actionDescription: "Convert to string concatenation", - newContent: -`const age = 42 -const foo = "foobar is a " + (age < 18 ? 'child' : \`grown-up \${age > 40 ? 'who needs probaply assistance' : ''}\`)`, -}); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringOneExpr.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringOneExpr.ts deleted file mode 100644 index 0e5cb6ae257..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringOneExpr.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// - -//// const age = 42 -//// const foo = `/*x*/f/*y*/oobar is ${ age } years old` - -goTo.select("x", "y"); -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to string concatenation", - actionDescription: "Convert to string concatenation", - newContent: -`const age = 42 -const foo = "foobar is " + age + " years old"`, -}); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringOnlyExpr.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringOnlyExpr.ts deleted file mode 100644 index da84ef1c409..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringOnlyExpr.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -//// const foo = `/*x*/$/*y*/{42}` - -goTo.select("x", "y"); -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to string concatenation", - actionDescription: "Convert to string concatenation", - newContent: -`const foo = 42`, -}); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringOtherExprSeq.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringOtherExprSeq.ts deleted file mode 100644 index 2970dce1895..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringOtherExprSeq.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -//// const foo = `/*x*/f/*y*/oobar is ${ 42 * 6 % 4} years old` - -goTo.select("x", "y"); -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to string concatenation", - actionDescription: "Convert to string concatenation", - newContent: -`const foo = "foobar is " + 42 * 6 % 4 + " years old"`, -}); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringPlusExprSeq.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringPlusExprSeq.ts deleted file mode 100644 index 4b8e581b8c6..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringPlusExprSeq.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -//// const foo = `/*x*/f/*y*/oobar is ${ 42 }${ 6 } years old` - -goTo.select("x", "y"); -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to string concatenation", - actionDescription: "Convert to string concatenation", - newContent: -`const foo = "foobar is " + 42 + 6 + " years old"`, -}); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringSelectedFromExpr.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringSelectedFromExpr.ts deleted file mode 100644 index 7229e9e9f7a..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringSelectedFromExpr.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// - -//// const age = 42 -//// const foo = `foobar is ${ /*x*/a/*y*/ge } years old` - -goTo.select("x", "y"); -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to string concatenation", - actionDescription: "Convert to string concatenation", - newContent: -`const age = 42 -const foo = "foobar is " + age + " years old"`, -}); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringSelectedFromMiddle.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringSelectedFromMiddle.ts deleted file mode 100644 index c44e4ee646f..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringSelectedFromMiddle.ts +++ /dev/null @@ -1,14 +0,0 @@ -/// - -//// const age = 42 -//// const foo = `foobar is ${ age } /*x*/y/*y*/ears old ${ false }` - -goTo.select("x", "y"); -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to string concatenation", - actionDescription: "Convert to string concatenation", - newContent: -`const age = 42 -const foo = "foobar is " + age + " years old " + false`, -}); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringSimple.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringSimple.ts deleted file mode 100644 index 3da488fcf25..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToStringSimple.ts +++ /dev/null @@ -1,12 +0,0 @@ -/// - -//// const foo = `/*x*/f/*y*/oobar rocks` - -goTo.select("x", "y"); -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to string concatenation", - actionDescription: "Convert to string concatenation", - newContent: -`const foo = "foobar rocks"`, -}); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateAvailability.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateAvailability.ts deleted file mode 100644 index 2965cb42bed..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateAvailability.ts +++ /dev/null @@ -1,39 +0,0 @@ -/// - -//// const age = 22 -//// const name = "Eddy" -//// const /*z*/f/*y*/oo = /*x*/"/*w*/M/*v*/r/*u*/ " /*t*/+/*s*/ /*r*/n/*q*/ame + " is " + /*p*/a/*o*/ge * 4 / 2 + " years old" - -goTo.select("z", "y"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("x", "w"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("v", "u"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("t", "s"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("r", "q"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("p", "o"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to template literal", - actionDescription: "Convert to template literal", - newContent: -`const age = 22 -const name = "Eddy" -const foo = \`Mr \${name} is \${age * 4 / 2} years old\``, -}); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateAvailabilityMinus.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateAvailabilityMinus.ts deleted file mode 100644 index 50c7921836c..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateAvailabilityMinus.ts +++ /dev/null @@ -1,25 +0,0 @@ -/// - -//// const age = 22 -//// const name = "Eddy" -//// const /*z*/f/*y*/oo = /*x*/"/*w*/M/*v*/r/*u*/ " /*t*/+/*s*/ name + " is " - /*r*/a/*q*/ge - " years old" - -goTo.select("z", "y"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("x", "w"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("v", "u"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("t", "s"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("r", "q"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateAvailabilityNoStrings.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateAvailabilityNoStrings.ts deleted file mode 100644 index f015af3b3c7..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateAvailabilityNoStrings.ts +++ /dev/null @@ -1,19 +0,0 @@ -/// - -//// const /*z*/f/*y*/oo = /*x*/4/*w*/2 /*v*/-/*u*/ 56 + /*t*/2/*s*/2 * 4 / 33 - -goTo.select("z", "y"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("x", "w"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("v", "u"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("t", "s"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateAvailabilityPrecedingMinus.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateAvailabilityPrecedingMinus.ts deleted file mode 100644 index 11540519e0d..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateAvailabilityPrecedingMinus.ts +++ /dev/null @@ -1,33 +0,0 @@ -/// - -//// const age = 22 -//// const /*z*/f/*y*/oo = /*x*/a/*w*/ge * 4 /*v*/-/*u*/ 2 / 4 /*t*/+/*s*/ " /*r*/y/*q*/ears old" - -goTo.select("z", "y"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("x", "w"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("v", "u"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("t", "s"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("r", "q"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to template literal", - actionDescription: "Convert to template literal", - newContent: -`const age = 22 -const foo = \`\${age * 4 - 2 / 4} years old\``, -}); diff --git a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateAvailabilityReassignment.ts b/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateAvailabilityReassignment.ts deleted file mode 100644 index 3c3200559fe..00000000000 --- a/tests/cases/fourslash/refactorConvertStringOrTemplateLiteral_ToTemplateAvailabilityReassignment.ts +++ /dev/null @@ -1,25 +0,0 @@ -/// - -//// let foo = "" -//// /*z*/f/*y*/oo = "/*x*/M/*w*/r Bar" + " is" + /*v*/4/*u*/2 + " years old" - -goTo.select("z", "y"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("x", "w"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -goTo.select("v", "u"); -verify.not.refactorAvailable("Convert string concatenation or template literal", "Convert to string concatenation"); -verify.refactorAvailable("Convert string concatenation or template literal", "Convert to template literal"); - -edit.applyRefactor({ - refactorName: "Convert string concatenation or template literal", - actionName: "Convert to template literal", - actionDescription: "Convert to template literal", - newContent: -`let foo = "" -foo = \`Mr Bar is\${42} years old\``, -});