提交 c44ecded 编写于 作者: M Mikhail Glukhikh

Refactoring: MoveAssignmentToInitializer --> JoinDeclarationAndAssignment

上级 d4995c07
<html>
<body>
This intention joins the declaration of a property / variable and the first assignment into the property / variable
</body>
</html>
<html>
<body>
This intention moves an assignment to a property into the initializer of that property.
</body>
</html>
......@@ -1254,7 +1254,7 @@
</intentionAction>
<intentionAction>
<className>org.jetbrains.kotlin.idea.intentions.MoveAssignmentToInitializerIntention</className>
<className>org.jetbrains.kotlin.idea.intentions.JoinDeclarationAndAssignmentIntention</className>
<category>Kotlin</category>
</intentionAction>
......
......@@ -29,8 +29,8 @@ import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.*
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
class MoveAssignmentToInitializerIntention :
SelfTargetingIntention<KtBinaryExpression>(KtBinaryExpression::class.java, "Move assignment to initializer") {
class JoinDeclarationAndAssignmentIntention :
SelfTargetingIntention<KtBinaryExpression>(KtBinaryExpression::class.java, "Join declaration and assignment") {
override fun isApplicableTo(element: KtBinaryExpression, caretOffset: Int): Boolean {
if (element.operationToken != KtTokens.EQ) {
......
org.jetbrains.kotlin.idea.intentions.JoinDeclarationAndAssignmentIntention
\ No newline at end of file
org.jetbrains.kotlin.idea.intentions.MoveAssignmentToInitializerIntention
\ No newline at end of file
......@@ -8038,6 +8038,57 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
}
@TestMetadata("idea/testData/intentions/joinDeclarationAndAssignment")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class JoinDeclarationAndAssignment extends AbstractIntentionTest {
public void testAllFilesPresentInJoinDeclarationAndAssignment() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/joinDeclarationAndAssignment"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("cannotRemoveType.kt")
public void testCannotRemoveType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/joinDeclarationAndAssignment/cannotRemoveType.kt");
doTest(fileName);
}
@TestMetadata("cannotRemoveType2.kt")
public void testCannotRemoveType2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/joinDeclarationAndAssignment/cannotRemoveType2.kt");
doTest(fileName);
}
@TestMetadata("cannotRemoveType3.kt")
public void testCannotRemoveType3() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/joinDeclarationAndAssignment/cannotRemoveType3.kt");
doTest(fileName);
}
@TestMetadata("comment.kt")
public void testComment() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/joinDeclarationAndAssignment/comment.kt");
doTest(fileName);
}
@TestMetadata("deleteInitBlock.kt")
public void testDeleteInitBlock() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/joinDeclarationAndAssignment/deleteInitBlock.kt");
doTest(fileName);
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/joinDeclarationAndAssignment/simple.kt");
doTest(fileName);
}
@TestMetadata("usedLocal.kt")
public void testUsedLocal() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/joinDeclarationAndAssignment/usedLocal.kt");
doTest(fileName);
}
}
@TestMetadata("idea/testData/intentions/loopToCallChain")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
......@@ -9592,57 +9643,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
}
}
@TestMetadata("idea/testData/intentions/moveAssignmentToInitializer")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class MoveAssignmentToInitializer extends AbstractIntentionTest {
public void testAllFilesPresentInMoveAssignmentToInitializer() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/moveAssignmentToInitializer"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("cannotRemoveType.kt")
public void testCannotRemoveType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/moveAssignmentToInitializer/cannotRemoveType.kt");
doTest(fileName);
}
@TestMetadata("cannotRemoveType2.kt")
public void testCannotRemoveType2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/moveAssignmentToInitializer/cannotRemoveType2.kt");
doTest(fileName);
}
@TestMetadata("cannotRemoveType3.kt")
public void testCannotRemoveType3() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/moveAssignmentToInitializer/cannotRemoveType3.kt");
doTest(fileName);
}
@TestMetadata("comment.kt")
public void testComment() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/moveAssignmentToInitializer/comment.kt");
doTest(fileName);
}
@TestMetadata("deleteInitBlock.kt")
public void testDeleteInitBlock() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/moveAssignmentToInitializer/deleteInitBlock.kt");
doTest(fileName);
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/moveAssignmentToInitializer/simple.kt");
doTest(fileName);
}
@TestMetadata("usedLocal.kt")
public void testUsedLocal() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/moveAssignmentToInitializer/usedLocal.kt");
doTest(fileName);
}
}
@TestMetadata("idea/testData/intentions/moveLambdaInsideParentheses")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册