Fixed bug in join lines
This commit is contained in:
+5
-5
@@ -38,7 +38,8 @@ public class JetDeclarationJoinLinesHandler : JoinRawLinesHandlerDelegate {
|
||||
.firstOrNull() ?: return -1
|
||||
val (property, assignment) = pair
|
||||
|
||||
return doJoin(property, assignment).getTextRange()!!.getStartOffset()
|
||||
doJoin(property, assignment)
|
||||
return property.getTextRange()!!.getStartOffset()
|
||||
}
|
||||
|
||||
override fun tryJoinLines(document: Document, file: PsiFile, start: Int, end: Int)
|
||||
@@ -58,10 +59,9 @@ public class JetDeclarationJoinLinesHandler : JoinRawLinesHandlerDelegate {
|
||||
return property to assignment
|
||||
}
|
||||
|
||||
private fun doJoin(property: JetProperty, assignment: JetBinaryExpression): JetProperty {
|
||||
val newProperty = DeclarationUtils.changePropertyInitializer(property, assignment.getRight())
|
||||
property.getParent()!!.deleteChildRange(property.getNextSibling(), assignment)
|
||||
return property.replace(newProperty) as JetProperty
|
||||
private fun doJoin(property: JetProperty, assignment: JetBinaryExpression) {
|
||||
property.setInitializer(assignment.getRight())
|
||||
property.getParent()!!.deleteChildRange(property.getNextSibling(), assignment) //TODO: should we remove range?
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun foo() {
|
||||
<caret>[volatile] var v: Int
|
||||
v = 1
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo() {
|
||||
<caret>[volatile] var v: Int = 1
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fun foo(n: Int) {
|
||||
// foo3
|
||||
<caret>val x: String = "" // bar3
|
||||
<caret>val /* foo */ x: String = "" // bar3
|
||||
/* baz */
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fun foo(n: Int) {
|
||||
// foo3
|
||||
<caret>val x: String = "" // bar3
|
||||
<caret>val /* foo */ x: String = "" // bar3
|
||||
/* baz */
|
||||
}
|
||||
+7
-5
@@ -17,13 +17,9 @@
|
||||
package org.jetbrains.jet.plugin.intentions.declarations;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
import org.jetbrains.jet.JUnit3RunnerWithInners;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -50,6 +46,12 @@ public class JoinLinesTestGenerated extends AbstractJoinLinesTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("propertyWithAnnotation.kt")
|
||||
public void testPropertyWithAnnotation() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/joinLines/propertyWithAnnotation.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleInit.kt")
|
||||
public void testSimpleInit() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/joinLines/simpleInit.kt");
|
||||
|
||||
Reference in New Issue
Block a user