Added ConvertToConcatenatedStringIntention
This commit is contained in:
committed by
Nikolay Krasko
parent
8e2878a6eb
commit
b2858e5b82
@@ -393,6 +393,7 @@ fun main(args: Array<String>) {
|
||||
model("intentions/replaceWithInfixFunctionCall", testMethod = "doTestReplaceWithInfixFunctionCall")
|
||||
model("intentions/removeCurlyBracesFromTemplate", testMethod = "doTestRemoveCurlyFromTemplate")
|
||||
model("intentions/convertToStringTemplateIntention", testMethod = "doTestConvertToStringTemplate")
|
||||
model("intentions/convertToConcatenatedStringIntention", testMethod = "doTestConvertToConcatenatedStringIntention")
|
||||
model("intentions/insertCurlyBracestsToTemplate", testMethod = "doTestInsertCurlyToTemplate")
|
||||
model("intentions/moveLambdaInsideParentheses", testMethod = "doTestMoveLambdaInsideParentheses")
|
||||
model("intentions/moveLambdaOutsideParentheses", testMethod = "doTestMoveLambdaOutsideParentheses")
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
val x = "World"
|
||||
val y = <spot>"Hello " + x</spot>
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
val x = "World"
|
||||
val y = <spot>"Hello $x"</spot>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
Converts a statement that builds a String using a String Template to one that builds a String using '+'
|
||||
</body>
|
||||
</html>
|
||||
@@ -719,6 +719,11 @@
|
||||
<category>Kotlin</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>org.jetbrains.jet.plugin.intentions.ConvertToConcatenatedStringIntention</className>
|
||||
<category>Kotlin</category>
|
||||
</intentionAction>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.jet.plugin.inspections.ExplicitGetInspection"
|
||||
displayName="Explicit 'get'"
|
||||
groupName="Kotlin"
|
||||
|
||||
@@ -324,6 +324,8 @@ convert.to.for.each.function.call.intention=Replace with a forEach function call
|
||||
convert.to.for.each.function.call.intention.family=Replace with a forEach Function Call
|
||||
convert.to.string.template=Convert concatenation to template
|
||||
convert.to.string.template.family=Convert Concatenation to Template
|
||||
convert.to.concatenated.string.intention=Convert template to concatenated string
|
||||
convert.to.concatenated.string.intention.family=Convert Template to Concatenated String
|
||||
|
||||
property.is.implemented.too.many=Has implementations
|
||||
property.is.overridden.too.many=Is overridden in subclasses
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package org.jetbrains.jet.plugin.intentions
|
||||
|
||||
import org.jetbrains.jet.lang.psi.JetStringTemplateExpression
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||
import org.jetbrains.jet.lang.psi.JetStringTemplateEntry
|
||||
import org.jetbrains.jet.lang.psi.JetBinaryExpression
|
||||
import org.jetbrains.jet.lang.psi.JetStringTemplateEntryWithExpression
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
||||
import org.jetbrains.jet.lang.psi.JetIfExpression
|
||||
import org.jetbrains.jet.lang.psi.JetBlockExpression
|
||||
|
||||
public class ConvertToConcatenatedStringIntention : JetSelfTargetingIntention<JetStringTemplateExpression>("convert.to.concatenated.string.intention", javaClass()) {
|
||||
override fun isApplicableTo(element: JetStringTemplateExpression): Boolean {
|
||||
return element.getEntries().any { it is JetStringTemplateEntryWithExpression }
|
||||
}
|
||||
|
||||
override fun applyTo(element: JetStringTemplateExpression, editor: Editor) {
|
||||
val tripleQuoted = isTripleQuoted(element.getText()!!)
|
||||
val quote = if (tripleQuoted) "\"\"\"" else "\""
|
||||
val entries = element.getEntries()
|
||||
|
||||
val result = entries.stream()
|
||||
.withIndices()
|
||||
.map { indexToEntry ->
|
||||
val (index, entry) = indexToEntry
|
||||
entry.toSeparateString(quote, convertExplicitly = index == 0, isFinalEntry = index == entries.size - 1)
|
||||
}
|
||||
.makeString(separator = "+")
|
||||
.replaceAll("""$quote\+$quote""", "")
|
||||
|
||||
val replacement = JetPsiFactory.createExpression(element.getProject(), result)
|
||||
|
||||
element.replace(replacement)
|
||||
}
|
||||
|
||||
private fun isTripleQuoted(str: String) = str.startsWith("\"\"\"") && str.endsWith("\"\"\"")
|
||||
|
||||
private fun JetStringTemplateEntry.toSeparateString(quote: String, convertExplicitly: Boolean, isFinalEntry: Boolean): String {
|
||||
if (this !is JetStringTemplateEntryWithExpression) return getText()!!.quote(quote)
|
||||
|
||||
val expression = getExpression()!!
|
||||
|
||||
val expressionText = if (needsParenthesis(expression, isFinalEntry)) "(${expression.getText()})" else expression.getText()!!
|
||||
return if (convertExplicitly && !expression.isStringExpression()) {
|
||||
expressionText + ".toString()"
|
||||
}
|
||||
else {
|
||||
expressionText
|
||||
}
|
||||
}
|
||||
|
||||
private fun needsParenthesis(expression: JetExpression, isFinalEntry: Boolean) = when (expression) {
|
||||
is JetBinaryExpression -> true
|
||||
is JetIfExpression -> expression.getElse() !is JetBlockExpression && !isFinalEntry
|
||||
else -> false
|
||||
}
|
||||
|
||||
private fun String.quote(quote: String) = quote + this + quote
|
||||
|
||||
private fun JetExpression.isStringExpression(): Boolean {
|
||||
val context = AnalyzerFacadeWithCache.getContextForElement(this)
|
||||
val elementType = BindingContextUtils.getRecordedTypeInfo(this, context)?.getType()
|
||||
|
||||
return KotlinBuiltIns.getInstance().isString(elementType)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>) {
|
||||
val x = "<caret>${if (true) 42 else 12}abc${if (true) 12 else 42}"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>) {
|
||||
val x = (if (true) 42 else 12).toString() + "abc" + if (true) 12 else 42
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun main(args: Array<String>) {
|
||||
val x = "<caret>${if (true) 42 else {
|
||||
12
|
||||
} }abc${if (true) 12 else 42}"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun main(args: Array<String>) {
|
||||
val x = if (true) 42 else {
|
||||
12
|
||||
}.toString() + "abc" + if (true) 12 else 42
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun main(args: Array<String>){
|
||||
var t = "t"
|
||||
val x = "<caret>abc\n${t}bar\tfoo"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fun main(args: Array<String>){
|
||||
var t = "t"
|
||||
val x = "<caret>abc\n" + t + "bar\tfoo"
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "<caret>${"abc"}${"def"}"
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abcdef"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun main(args: Array<String>){
|
||||
val a = "abc"
|
||||
val c = "bcd"
|
||||
val x = "<caret>${a}b$c"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun main(args: Array<String>){
|
||||
val a = "abc"
|
||||
val c = "bcd"
|
||||
val x = a + "b" + c
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "<caret>abc${'d'}"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc" + 'd'
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "<caret>abc${1}${2}${'a'}${3.2}"
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc" + 1 + 2 + 'a' + 3.2
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>){
|
||||
val x = mapOf("a" to "b")
|
||||
val y = "<caret>abcd${x["a"]}"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>){
|
||||
val x = mapOf("a" to "b")
|
||||
val y = "abcd" + x["a"]
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>){
|
||||
val x = "abcd"
|
||||
val y = "<caret>$x${x.reverse()}"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>){
|
||||
val x = "abcd"
|
||||
val y = x + x.reverse()
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc"
|
||||
val y = "<caret>${x}d"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc"
|
||||
val y = x + "d"
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "<caret>abc${0.32}"
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc" + 0.32
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "<caret>abc${32}"
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc" + 32
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc"
|
||||
val y = "<caret>d$x"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc"
|
||||
val y = "d" + x
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun main(args: Array<String>){
|
||||
var r = "a"
|
||||
val x = """<caret>foobar
|
||||
$r"""
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun main(args: Array<String>){
|
||||
var r = "a"
|
||||
val x = """foobar
|
||||
""" + r
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fun main(args: Array<String>){
|
||||
val a = "<caret>${when (1) {
|
||||
1 -> 42
|
||||
else -> 3
|
||||
}}asdfas${when (1) {
|
||||
1 -> 42
|
||||
else -> 3
|
||||
}}"
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
fun main(args: Array<String>){
|
||||
val a = when (1) {
|
||||
1 -> 42
|
||||
else -> 3
|
||||
}.toString() + "asdfas" + when (1) {
|
||||
1 -> 42
|
||||
else -> 3
|
||||
}
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc"
|
||||
val y = "<caret>$x.bar"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc"
|
||||
val y = x + ".bar"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>){
|
||||
var a = 'a'
|
||||
val x = "x$a{}<caret>
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>){
|
||||
val x = "xyz<caret>\n\n"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>){
|
||||
val x = "<caret>\$d"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun main(args: Array<String>){
|
||||
val a = "a"
|
||||
val x = "<caret>$a"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun main(args: Array<String>){
|
||||
val a = "a"
|
||||
val x = a
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun main(args: Array<String>){
|
||||
val a = 1
|
||||
val x = "<caret>$a!!!!"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun main(args: Array<String>){
|
||||
val a = 1
|
||||
val x = a.toString() + "!!!!"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun main(args: Array<String>){
|
||||
val a = "abc"
|
||||
val b = "bcd"
|
||||
val x = "<caret>$a$b"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun main(args: Array<String>){
|
||||
val a = "abc"
|
||||
val b = "bcd"
|
||||
val x = a + b
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun compute1(): Int = 777
|
||||
fun main(args: Array<String>){
|
||||
val a = "a"
|
||||
"<caret>a = $a, b = ${compute1() + 222} :)"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun compute1(): Int = 777
|
||||
fun main(args: Array<String>){
|
||||
val a = "a"
|
||||
"a = " + a + ", b = " + (compute1() + 222) + " :)"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>){
|
||||
val y = "cde"
|
||||
val z = "<caret>${listOf(1, 2)}$y.bar"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>){
|
||||
val y = "cde"
|
||||
val z = listOf(1, 2).toString() + y + ".bar"
|
||||
}
|
||||
@@ -67,6 +67,10 @@ public abstract class AbstractCodeTransformationTest extends LightCodeInsightTes
|
||||
doTestIntention(path, new ConvertToStringTemplateIntention());
|
||||
}
|
||||
|
||||
public void doTestConvertToConcatenatedStringIntention(@NotNull String path) throws Exception {
|
||||
doTestIntention(path, new ConvertToConcatenatedStringIntention());
|
||||
}
|
||||
|
||||
public void doTestFoldIfToAssignment(@NotNull String path) throws Exception {
|
||||
doTestIntention(path, new FoldIfToAssignmentIntention());
|
||||
}
|
||||
|
||||
+130
-1
@@ -30,7 +30,7 @@ import org.jetbrains.jet.plugin.intentions.AbstractCodeTransformationTest;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@InnerTestClasses({CodeTransformationTestGenerated.DoubleBangToIfThen.class, CodeTransformationTestGenerated.IfThenToDoubleBang.class, CodeTransformationTestGenerated.ElvisToIfThen.class, CodeTransformationTestGenerated.IfThenToElvis.class, CodeTransformationTestGenerated.SafeAccessToIfThen.class, CodeTransformationTestGenerated.IfThenToSafeAccess.class, CodeTransformationTestGenerated.IfToAssignment.class, CodeTransformationTestGenerated.IfToReturn.class, CodeTransformationTestGenerated.IfToReturnAsymmetrically.class, CodeTransformationTestGenerated.WhenToAssignment.class, CodeTransformationTestGenerated.WhenToReturn.class, CodeTransformationTestGenerated.AssignmentToIf.class, CodeTransformationTestGenerated.AssignmentToWhen.class, CodeTransformationTestGenerated.PropertyToIf.class, CodeTransformationTestGenerated.PropertyToWhen.class, CodeTransformationTestGenerated.ReturnToIf.class, CodeTransformationTestGenerated.ReturnToWhen.class, CodeTransformationTestGenerated.IfToWhen.class, CodeTransformationTestGenerated.WhenToIf.class, CodeTransformationTestGenerated.Flatten.class, CodeTransformationTestGenerated.Merge.class, CodeTransformationTestGenerated.IntroduceSubject.class, CodeTransformationTestGenerated.EliminateSubject.class, CodeTransformationTestGenerated.Split.class, CodeTransformationTestGenerated.Join.class, CodeTransformationTestGenerated.ConvertMemberToExtension.class, CodeTransformationTestGenerated.ReconstructedType.class, CodeTransformationTestGenerated.RemoveUnnecessaryParentheses.class, CodeTransformationTestGenerated.ReplaceWithDotQualifiedMethodCall.class, CodeTransformationTestGenerated.ReplaceWithInfixFunctionCall.class, CodeTransformationTestGenerated.RemoveCurlyBracesFromTemplate.class, CodeTransformationTestGenerated.ConvertToStringTemplateIntention.class, CodeTransformationTestGenerated.MoveLambdaInsideParentheses.class, CodeTransformationTestGenerated.MoveLambdaOutsideParentheses.class, CodeTransformationTestGenerated.ReplaceExplicitFunctionLiteralParamWithIt.class, CodeTransformationTestGenerated.ReplaceItWithExplicitFunctionLiteralParam.class, CodeTransformationTestGenerated.RemoveBraces.class, CodeTransformationTestGenerated.AddBraces.class, CodeTransformationTestGenerated.ReplaceGetIntention.class, CodeTransformationTestGenerated.ReplaceContainsIntention.class, CodeTransformationTestGenerated.ReplaceBinaryInfixIntention.class, CodeTransformationTestGenerated.ReplaceUnaryPrefixIntention.class, CodeTransformationTestGenerated.ReplaceInvokeIntention.class, CodeTransformationTestGenerated.SimplifyNegatedBinaryExpressionIntention.class, CodeTransformationTestGenerated.ConvertNegatedBooleanSequence.class, CodeTransformationTestGenerated.ConvertNegatedExpressionWithDemorgansLaw.class, CodeTransformationTestGenerated.SwapBinaryExpression.class, CodeTransformationTestGenerated.SplitIf.class, CodeTransformationTestGenerated.ReplaceWithOperatorAssign.class, CodeTransformationTestGenerated.ReplaceWithTraditionalAssignment.class, CodeTransformationTestGenerated.SimplifyBooleanWithConstants.class, CodeTransformationTestGenerated.InsertExplicitTypeArguments.class, CodeTransformationTestGenerated.RemoveExplicitTypeArguments.class, CodeTransformationTestGenerated.ConvertAssertToIf.class, CodeTransformationTestGenerated.ConvertIfToAssert.class, CodeTransformationTestGenerated.MakeTypeExplicitInLambda.class, CodeTransformationTestGenerated.MakeTypeImplicitInLambda.class, CodeTransformationTestGenerated.InvertIfCondition.class, CodeTransformationTestGenerated.OperatorToFunction.class, CodeTransformationTestGenerated.ConvertToForEachLoop.class, CodeTransformationTestGenerated.ConvertToForEachFunctionCall.class})
|
||||
@InnerTestClasses({CodeTransformationTestGenerated.DoubleBangToIfThen.class, CodeTransformationTestGenerated.IfThenToDoubleBang.class, CodeTransformationTestGenerated.ElvisToIfThen.class, CodeTransformationTestGenerated.IfThenToElvis.class, CodeTransformationTestGenerated.SafeAccessToIfThen.class, CodeTransformationTestGenerated.IfThenToSafeAccess.class, CodeTransformationTestGenerated.IfToAssignment.class, CodeTransformationTestGenerated.IfToReturn.class, CodeTransformationTestGenerated.IfToReturnAsymmetrically.class, CodeTransformationTestGenerated.WhenToAssignment.class, CodeTransformationTestGenerated.WhenToReturn.class, CodeTransformationTestGenerated.AssignmentToIf.class, CodeTransformationTestGenerated.AssignmentToWhen.class, CodeTransformationTestGenerated.PropertyToIf.class, CodeTransformationTestGenerated.PropertyToWhen.class, CodeTransformationTestGenerated.ReturnToIf.class, CodeTransformationTestGenerated.ReturnToWhen.class, CodeTransformationTestGenerated.IfToWhen.class, CodeTransformationTestGenerated.WhenToIf.class, CodeTransformationTestGenerated.Flatten.class, CodeTransformationTestGenerated.Merge.class, CodeTransformationTestGenerated.IntroduceSubject.class, CodeTransformationTestGenerated.EliminateSubject.class, CodeTransformationTestGenerated.Split.class, CodeTransformationTestGenerated.Join.class, CodeTransformationTestGenerated.ConvertMemberToExtension.class, CodeTransformationTestGenerated.ReconstructedType.class, CodeTransformationTestGenerated.RemoveUnnecessaryParentheses.class, CodeTransformationTestGenerated.ReplaceWithDotQualifiedMethodCall.class, CodeTransformationTestGenerated.ReplaceWithInfixFunctionCall.class, CodeTransformationTestGenerated.RemoveCurlyBracesFromTemplate.class, CodeTransformationTestGenerated.ConvertToStringTemplateIntention.class, CodeTransformationTestGenerated.ConvertToConcatenatedStringIntention.class, CodeTransformationTestGenerated.MoveLambdaInsideParentheses.class, CodeTransformationTestGenerated.MoveLambdaOutsideParentheses.class, CodeTransformationTestGenerated.ReplaceExplicitFunctionLiteralParamWithIt.class, CodeTransformationTestGenerated.ReplaceItWithExplicitFunctionLiteralParam.class, CodeTransformationTestGenerated.RemoveBraces.class, CodeTransformationTestGenerated.AddBraces.class, CodeTransformationTestGenerated.ReplaceGetIntention.class, CodeTransformationTestGenerated.ReplaceContainsIntention.class, CodeTransformationTestGenerated.ReplaceBinaryInfixIntention.class, CodeTransformationTestGenerated.ReplaceUnaryPrefixIntention.class, CodeTransformationTestGenerated.ReplaceInvokeIntention.class, CodeTransformationTestGenerated.SimplifyNegatedBinaryExpressionIntention.class, CodeTransformationTestGenerated.ConvertNegatedBooleanSequence.class, CodeTransformationTestGenerated.ConvertNegatedExpressionWithDemorgansLaw.class, CodeTransformationTestGenerated.SwapBinaryExpression.class, CodeTransformationTestGenerated.SplitIf.class, CodeTransformationTestGenerated.ReplaceWithOperatorAssign.class, CodeTransformationTestGenerated.ReplaceWithTraditionalAssignment.class, CodeTransformationTestGenerated.SimplifyBooleanWithConstants.class, CodeTransformationTestGenerated.InsertExplicitTypeArguments.class, CodeTransformationTestGenerated.RemoveExplicitTypeArguments.class, CodeTransformationTestGenerated.ConvertAssertToIf.class, CodeTransformationTestGenerated.ConvertIfToAssert.class, CodeTransformationTestGenerated.MakeTypeExplicitInLambda.class, CodeTransformationTestGenerated.MakeTypeImplicitInLambda.class, CodeTransformationTestGenerated.InvertIfCondition.class, CodeTransformationTestGenerated.OperatorToFunction.class, CodeTransformationTestGenerated.ConvertToForEachLoop.class, CodeTransformationTestGenerated.ConvertToForEachFunctionCall.class})
|
||||
public class CodeTransformationTestGenerated extends AbstractCodeTransformationTest {
|
||||
@TestMetadata("idea/testData/intentions/branched/doubleBangToIfThen")
|
||||
public static class DoubleBangToIfThen extends AbstractCodeTransformationTest {
|
||||
@@ -2310,6 +2310,134 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/intentions/convertToConcatenatedStringIntention")
|
||||
public static class ConvertToConcatenatedStringIntention extends AbstractCodeTransformationTest {
|
||||
public void testAllFilesPresentInConvertToConcatenatedStringIntention() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/intentions/convertToConcatenatedStringIntention"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("embeddedIf.kt")
|
||||
public void testEmbeddedIf() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/embeddedIf.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("embeddedIfBraces.kt")
|
||||
public void testEmbeddedIfBraces() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/embeddedIfBraces.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("handlesEscapeString.kt")
|
||||
public void testHandlesEscapeString() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/handlesEscapeString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolate2StringConstants.kt")
|
||||
public void testInterpolate2StringConstants() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/interpolate2StringConstants.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolate3.kt")
|
||||
public void testInterpolate3() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/interpolate3.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateChar.kt")
|
||||
public void testInterpolateChar() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/interpolateChar.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateConstants.kt")
|
||||
public void testInterpolateConstants() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/interpolateConstants.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateMapAccess.kt")
|
||||
public void testInterpolateMapAccess() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/interpolateMapAccess.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateMethodInvoke.kt")
|
||||
public void testInterpolateMethodInvoke() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/interpolateMethodInvoke.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateSimpleWithBraces.kt")
|
||||
public void testInterpolateSimpleWithBraces() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/interpolateSimpleWithBraces.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateStringWithFloat.kt")
|
||||
public void testInterpolateStringWithFloat() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/interpolateStringWithFloat.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateStringWithInt.kt")
|
||||
public void testInterpolateStringWithInt() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/interpolateStringWithInt.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lastExprIsNamedExpression.kt")
|
||||
public void testLastExprIsNamedExpression() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/lastExprIsNamedExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("multilineString.kt")
|
||||
public void testMultilineString() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/multilineString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("multilineWhenExpr.kt")
|
||||
public void testMultilineWhenExpr() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/multilineWhenExpr.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("namedExprBetweenConstants.kt")
|
||||
public void testNamedExprBetweenConstants() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/namedExprBetweenConstants.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notApplicableForErrorElement.kt")
|
||||
public void testNotApplicableForErrorElement() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/notApplicableForErrorElement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notApplicableForSimple.kt")
|
||||
public void testNotApplicableForSimple() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/notApplicableForSimple.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notAvailableForDollarSignLiteral.kt")
|
||||
public void testNotAvailableForDollarSignLiteral() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/notAvailableForDollarSignLiteral.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("singleVar.kt")
|
||||
public void testSingleVar() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/singleVar.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("startsWithInt.kt")
|
||||
public void testStartsWithInt() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/startsWithInt.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("startsWithStringExpression.kt")
|
||||
public void testStartsWithStringExpression() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/startsWithStringExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("tricky.kt")
|
||||
public void testTricky() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/tricky.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("withAndWithoutBraces.kt")
|
||||
public void testWithAndWithoutBraces() throws Exception {
|
||||
doTestConvertToConcatenatedStringIntention("idea/testData/intentions/convertToConcatenatedStringIntention/withAndWithoutBraces.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/intentions/moveLambdaInsideParentheses")
|
||||
public static class MoveLambdaInsideParentheses extends AbstractCodeTransformationTest {
|
||||
public void testAllFilesPresentInMoveLambdaInsideParentheses() throws Exception {
|
||||
@@ -4654,6 +4782,7 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT
|
||||
suite.addTestSuite(ReplaceWithInfixFunctionCall.class);
|
||||
suite.addTestSuite(RemoveCurlyBracesFromTemplate.class);
|
||||
suite.addTestSuite(ConvertToStringTemplateIntention.class);
|
||||
suite.addTestSuite(ConvertToConcatenatedStringIntention.class);
|
||||
suite.addTestSuite(MoveLambdaInsideParentheses.class);
|
||||
suite.addTestSuite(MoveLambdaOutsideParentheses.class);
|
||||
suite.addTestSuite(ReplaceExplicitFunctionLiteralParamWithIt.class);
|
||||
|
||||
Reference in New Issue
Block a user