Added String Concat -> Interpolation Intention (KT-4750)
This commit is contained in:
committed by
Nikolay Krasko
parent
380f1875b8
commit
42f186b33f
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -826,6 +826,10 @@ public class KotlinBuiltIns {
|
||||
return !(type instanceof PackageType) && type.equals(getUnitType());
|
||||
}
|
||||
|
||||
public boolean isString(@Nullable JetType type) {
|
||||
return !(type instanceof PackageType) && getStringType().equals(type);
|
||||
}
|
||||
|
||||
public boolean isData(@NotNull ClassDescriptor classDescriptor) {
|
||||
return containsAnnotation(classDescriptor, getDataClassAnnotation());
|
||||
}
|
||||
|
||||
@@ -390,6 +390,7 @@ fun main(args: Array<String>) {
|
||||
model("intentions/replaceWithDotQualifiedMethodCall", testMethod = "doTestReplaceWithDotQualifiedMethodCall")
|
||||
model("intentions/replaceWithInfixFunctionCall", testMethod = "doTestReplaceWithInfixFunctionCall")
|
||||
model("intentions/removeCurlyBracesFromTemplate", testMethod = "doTestRemoveCurlyFromTemplate")
|
||||
model("intentions/convertToStringTemplateIntention", testMethod = "doTestConvertToStringTemplate")
|
||||
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>
|
||||
@@ -0,0 +1,5 @@
|
||||
<html>
|
||||
<body>
|
||||
Converts a statement that builds a String using '+' to one that builds a String using a String template
|
||||
</body>
|
||||
</html>
|
||||
@@ -709,6 +709,11 @@
|
||||
<category>Kotlin</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>org.jetbrains.jet.plugin.intentions.ConvertToStringTemplateIntention</className>
|
||||
<category>Kotlin</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>org.jetbrains.jet.plugin.intentions.OperatorToFunctionIntention</className>
|
||||
<category>Kotlin</category>
|
||||
@@ -749,14 +754,8 @@
|
||||
level="WARNING"
|
||||
/>
|
||||
|
||||
<intentionAction>
|
||||
<className>org.jetbrains.jet.plugin.intentions.InvertIfConditionIntention</className>
|
||||
<category>Kotlin</category>
|
||||
</intentionAction>
|
||||
|
||||
<project.converterProvider implementation="org.jetbrains.jet.plugin.converters.JetRunConfigurationSettingsFormatConverterProvider"/>
|
||||
|
||||
|
||||
</extensions>
|
||||
|
||||
<extensionPoints>
|
||||
|
||||
@@ -320,6 +320,8 @@ convert.to.for.each.loop.intention=Replace with a for each loop
|
||||
convert.to.for.each.loop.intention.family=Replace with a For Each Loop
|
||||
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
|
||||
|
||||
property.is.implemented.too.many=Has implementations
|
||||
property.is.overridden.too.many=Is overridden in subclasses
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright 2010-2014 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.plugin.intentions
|
||||
|
||||
import org.jetbrains.jet.lang.psi.JetBinaryExpression
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import org.jetbrains.jet.plugin.project.AnalyzerFacadeWithCache
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
||||
import org.jetbrains.jet.lang.psi.JetExpression
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory
|
||||
import org.jetbrains.jet.lang.psi.JetSimpleNameExpression
|
||||
import org.jetbrains.jet.lang.psi.JetConstantExpression
|
||||
import org.jetbrains.jet.lang.psi.JetStringTemplateExpression
|
||||
import org.jetbrains.jet.lang.evaluate.ConstantExpressionEvaluator
|
||||
import org.jetbrains.jet.lang.resolve.DelegatingBindingTrace
|
||||
import org.jetbrains.jet.lang.resolve.constants.IntegerValueTypeConstant
|
||||
import org.jetbrains.jet.lexer.JetTokens
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.psi.util.PsiUtilCore
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
|
||||
|
||||
|
||||
public class ConvertToStringTemplateIntention : JetSelfTargetingIntention<JetBinaryExpression>("convert.to.string.template", javaClass()) {
|
||||
override fun isApplicableTo(element: JetBinaryExpression): Boolean {
|
||||
if (element.getOperationToken() != JetTokens.PLUS) return false
|
||||
|
||||
val context = AnalyzerFacadeWithCache.getContextForElement(element)
|
||||
val elementType = BindingContextUtils.getRecordedTypeInfo(element, context)?.getType()
|
||||
if (!(KotlinBuiltIns.getInstance().isString(elementType))) return false
|
||||
|
||||
val (left, right) = Pair(element.getLeft(), element.getRight())
|
||||
if (left == null || right == null) return false
|
||||
|
||||
return !(PsiUtilCore.hasErrorElementChild(left) || PsiUtilCore.hasErrorElementChild(right))
|
||||
}
|
||||
|
||||
override fun applyTo(element: JetBinaryExpression, editor: Editor) {
|
||||
val parent = element.getParent()
|
||||
if (parent is JetBinaryExpression && isApplicableTo(parent)) {
|
||||
return applyTo(parent, editor)
|
||||
}
|
||||
|
||||
val rightStr = mkString(element.getRight(), false)
|
||||
val resultStr = fold(element.getLeft(), rightStr)
|
||||
val expr = JetPsiFactory.createExpression(element.getProject(), resultStr)
|
||||
|
||||
element.replace(expr)
|
||||
}
|
||||
|
||||
private fun fold(left: JetExpression?, right: String): String {
|
||||
val needsBraces = !right.isEmpty() && right.first() != '$' && Character.isJavaIdentifierPart(right.first())
|
||||
if (left is JetBinaryExpression && isApplicableTo(left)) {
|
||||
val l_right = mkString(left.getRight(), needsBraces)
|
||||
val newBase = "%s%s".format(l_right, right)
|
||||
return fold(left.getLeft(), newBase)
|
||||
}
|
||||
else {
|
||||
val leftStr = mkString(left, needsBraces)
|
||||
return "\"%s%s\"".format(leftStr, right)
|
||||
}
|
||||
}
|
||||
|
||||
private fun mkString(expr: JetExpression?, needsBraces: Boolean): String {
|
||||
val expression = JetPsiUtil.deparenthesize(expr)
|
||||
val expressionText = expression?.getText() ?: ""
|
||||
return when (expression) {
|
||||
is JetConstantExpression -> {
|
||||
val context = AnalyzerFacadeWithCache.getContextForElement(expression)
|
||||
val trace = DelegatingBindingTrace(context, "Trace for evaluating constant")
|
||||
val constant = ConstantExpressionEvaluator.evaluate(expression, trace, null)
|
||||
if (constant is IntegerValueTypeConstant) {
|
||||
val elementType = BindingContextUtils.getRecordedTypeInfo(expression, context)?.getType()
|
||||
constant.getValue(elementType!!).toString()
|
||||
}
|
||||
else {
|
||||
constant?.getValue().toString()
|
||||
}
|
||||
}
|
||||
is JetStringTemplateExpression -> {
|
||||
val base = if (expressionText.startsWith("\"\"\"") && (expressionText.endsWith("\"\"\""))) {
|
||||
val unquoted = expressionText.substring(3, expressionText.length - 3)
|
||||
StringUtil.escapeStringCharacters(unquoted)
|
||||
}
|
||||
else {
|
||||
StringUtil.unquoteString(expressionText)
|
||||
}
|
||||
if (needsBraces && base.endsWith('$')) {
|
||||
base.substring(0, base.length - 1) + "\\$"
|
||||
}
|
||||
else {
|
||||
base
|
||||
}
|
||||
}
|
||||
is JetSimpleNameExpression ->
|
||||
if (needsBraces) "\${${expressionText}}" else "\$${expressionText}"
|
||||
null -> ""
|
||||
else -> "\${${expressionText.replaceAll("\n+", " ")}}"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "foo" +<caret> """bar\n
|
||||
"""
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "foobar\\n\n "
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "" +<caret> ""
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = ""
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc" +<caret> 1 + 2 + 'a' + 3.2
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc12a3.2"
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc" + 1 +<caret> 2 + 'a' + 3.2
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc12a3.2"
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>){
|
||||
val y = "abcd" +<caret> listOf( 1,
|
||||
|
||||
|
||||
|
||||
2 )
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>){
|
||||
val y = "abcd${listOf(1, 2)}"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc"
|
||||
val y = "cde"
|
||||
val z = "$y" +<caret> "$x.bar"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc"
|
||||
val y = "cde"
|
||||
val z = "$y$x.bar"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>){
|
||||
val y = "cde"
|
||||
val z = "${listOf(1, 2)}" +<caret> "$y.bar"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>){
|
||||
val y = "cde"
|
||||
val z = "${listOf(1, 2)}$y.bar"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc"
|
||||
val y = x +<caret> "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 = "abc" +<caret> "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 b = "bcd"
|
||||
val x = a +<caret> b
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun main(args: Array<String>){
|
||||
val a = "abc"
|
||||
val b = "bcd"
|
||||
val x = "$a$b"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun main(args: Array<String>){
|
||||
val a = "abc"
|
||||
val c = "bcd"
|
||||
val x = a +<caret> "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,5 @@
|
||||
fun main(args: Array<String>){
|
||||
val a = "abc"
|
||||
val c = "bcd"
|
||||
val x = a + "b" +<caret> 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 = "abc" +<caret> 'd'
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abcd"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "$" +<caret> 'd'
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "\$d"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>){
|
||||
val x = mapOf("a" to "b")
|
||||
val y = "abcd" +<caret> 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"]}"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>){
|
||||
val x = "abcd"
|
||||
val y = x +<caret> x.reverse()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>){
|
||||
val x = "abcd"
|
||||
val y = "$x${x.reverse()}"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>){
|
||||
val y = "abcd" +<caret> listOf( 1,
|
||||
2 )
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>){
|
||||
val y = "abcd${listOf(1, 2)}"
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc" +<caret> 0.320
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc0.32"
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc" +<caret> 32
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc32"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun main(args: Array<String>){
|
||||
var r = "a"
|
||||
val x = "foo" +<caret> """bar
|
||||
$r"""
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun main(args: Array<String>){
|
||||
var r = "a"
|
||||
val x = "foobar\n $r"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc"
|
||||
val y = "d" <caret>+ x
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc"
|
||||
val y = "d$x"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc"
|
||||
val y = x +<caret> ".bar"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fun main(args: Array<String>){
|
||||
val x = "abc"
|
||||
val y = "$x.bar"
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>){
|
||||
val x = "x" +<caret> "
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: Unresolved reference: /
|
||||
fun main(args: Array<String>){
|
||||
val x = "def" /<caret> "abc"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>){
|
||||
val x = 23 +<caret> 76
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>){
|
||||
var x = "abcd"
|
||||
x +=<caret> "42"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun compute1(): Int = 777
|
||||
fun main(args: Array<String>){
|
||||
val a = "a"
|
||||
"a = " + a +<caret> ", b = " + (compute1() + 222) + " :)"
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
fun compute1(): Int = 777
|
||||
fun main(args: Array<String>){
|
||||
val a = "a"
|
||||
"a = $a, b = ${compute1() + 222} :)"
|
||||
}
|
||||
@@ -63,6 +63,10 @@ public abstract class AbstractCodeTransformationTest extends LightCodeInsightTes
|
||||
doTestIntention(path, new IfThenToSafeAccessIntention());
|
||||
}
|
||||
|
||||
public void doTestConvertToStringTemplate(@NotNull String path) throws Exception {
|
||||
doTestIntention(path, new ConvertToStringTemplateIntention());
|
||||
}
|
||||
|
||||
public void doTestFoldIfToAssignment(@NotNull String path) throws Exception {
|
||||
doTestIntention(path, new FoldIfToAssignmentIntention());
|
||||
}
|
||||
|
||||
+145
-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.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.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 {
|
||||
@@ -2157,6 +2157,149 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/intentions/convertToStringTemplateIntention")
|
||||
public static class ConvertToStringTemplateIntention extends AbstractCodeTransformationTest {
|
||||
public void testAllFilesPresentInConvertToStringTemplateIntention() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("idea/testData/intentions/convertToStringTemplateIntention"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("backslashNMultilineString.kt")
|
||||
public void testBackslashNMultilineString() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/backslashNMultilineString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("combineEmptyStrings.kt")
|
||||
public void testCombineEmptyStrings() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/combineEmptyStrings.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("combinesNonStringsAsStrings.kt")
|
||||
public void testCombinesNonStringsAsStrings() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/combinesNonStringsAsStrings.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("combinesNonStringsAsStrings2.kt")
|
||||
public void testCombinesNonStringsAsStrings2() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/combinesNonStringsAsStrings2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("consecutiveNewlines.kt")
|
||||
public void testConsecutiveNewlines() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/consecutiveNewlines.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("doesNotCorruptExistingTemplate.kt")
|
||||
public void testDoesNotCorruptExistingTemplate() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/doesNotCorruptExistingTemplate.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("doesNotCorruptExistingTemplateWithBraces.kt")
|
||||
public void testDoesNotCorruptExistingTemplateWithBraces() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/doesNotCorruptExistingTemplateWithBraces.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("insertBracesForSimpleNamedExpression.kt")
|
||||
public void testInsertBracesForSimpleNamedExpression() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/insertBracesForSimpleNamedExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolate2StringConstants.kt")
|
||||
public void testInterpolate2StringConstants() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/interpolate2StringConstants.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolate2Vals.kt")
|
||||
public void testInterpolate2Vals() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/interpolate2Vals.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolate3Left.kt")
|
||||
public void testInterpolate3Left() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/interpolate3Left.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolate3Right.kt")
|
||||
public void testInterpolate3Right() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/interpolate3Right.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateChar.kt")
|
||||
public void testInterpolateChar() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/interpolateChar.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateDollarSign.kt")
|
||||
public void testInterpolateDollarSign() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/interpolateDollarSign.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateMapAccess.kt")
|
||||
public void testInterpolateMapAccess() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/interpolateMapAccess.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateMethodInvoke.kt")
|
||||
public void testInterpolateMethodInvoke() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/interpolateMethodInvoke.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateMultiline.kt")
|
||||
public void testInterpolateMultiline() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/interpolateMultiline.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateStringWithFloat.kt")
|
||||
public void testInterpolateStringWithFloat() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/interpolateStringWithFloat.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("interpolateStringWithInt.kt")
|
||||
public void testInterpolateStringWithInt() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/interpolateStringWithInt.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("multilineString.kt")
|
||||
public void testMultilineString() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/multilineString.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noBracesForLastSimpleExpression.kt")
|
||||
public void testNoBracesForLastSimpleExpression() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/noBracesForLastSimpleExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noBracesSimpleFollowedByDot.kt")
|
||||
public void testNoBracesSimpleFollowedByDot() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/noBracesSimpleFollowedByDot.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notApplicableForErrorElement.kt")
|
||||
public void testNotApplicableForErrorElement() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/notApplicableForErrorElement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("onlyForConcat.kt")
|
||||
public void testOnlyForConcat() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/onlyForConcat.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("onlyForStrings.kt")
|
||||
public void testOnlyForStrings() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/onlyForStrings.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("requiresPlusOperator.kt")
|
||||
public void testRequiresPlusOperator() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/requiresPlusOperator.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("tricky.kt")
|
||||
public void testTricky() throws Exception {
|
||||
doTestConvertToStringTemplate("idea/testData/intentions/convertToStringTemplateIntention/tricky.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/intentions/moveLambdaInsideParentheses")
|
||||
public static class MoveLambdaInsideParentheses extends AbstractCodeTransformationTest {
|
||||
public void testAllFilesPresentInMoveLambdaInsideParentheses() throws Exception {
|
||||
@@ -4455,6 +4598,7 @@ public class CodeTransformationTestGenerated extends AbstractCodeTransformationT
|
||||
suite.addTestSuite(ReplaceWithDotQualifiedMethodCall.class);
|
||||
suite.addTestSuite(ReplaceWithInfixFunctionCall.class);
|
||||
suite.addTestSuite(RemoveCurlyBracesFromTemplate.class);
|
||||
suite.addTestSuite(ConvertToStringTemplateIntention.class);
|
||||
suite.addTestSuite(MoveLambdaInsideParentheses.class);
|
||||
suite.addTestSuite(MoveLambdaOutsideParentheses.class);
|
||||
suite.addTestSuite(ReplaceExplicitFunctionLiteralParamWithIt.class);
|
||||
|
||||
Reference in New Issue
Block a user