"Join lines" works incorrectly in case of line containing more than one string literal (KT-22374)

#KT-22374 Fixed
This commit is contained in:
Toshiaki Kameyama
2018-01-25 23:54:21 +09:00
committed by Nikolay Krasko
parent cc346aef64
commit 7e417272b2
4 changed files with 18 additions and 1 deletions
@@ -49,7 +49,9 @@ class JoinToStringTemplateHandler : JoinRawLinesHandlerDelegate {
var rightText = ConvertToStringTemplateIntention.buildText(binaryExpr.right, false)
var left = binaryExpr.left
while (left is KtBinaryExpression && left.joinable() && left.parent.getLineCount() >= lineCount) {
while (left is KtBinaryExpression && left.joinable()) {
val leftLeft = (left as? KtBinaryExpression)?.left ?: break
if (leftLeft.lineCount() < lineCount) break
rightText = ConvertToStringTemplateIntention.buildText(left.right, false) + rightText
left = left.left
}
+5
View File
@@ -0,0 +1,5 @@
fun test() {
val s = "1" +
"2" +<caret>
"3"
}
@@ -0,0 +1,4 @@
fun test() {
val s = "1" +
"2<caret>3"
}
@@ -458,5 +458,11 @@ public class JoinLinesTestGenerated extends AbstractJoinLinesTest {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/joinLines/stringTemplate/threeLines.kt");
doTest(fileName);
}
@TestMetadata("threeLines2.kt")
public void testThreeLines2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/joinLines/stringTemplate/threeLines2.kt");
doTest(fileName);
}
}
}