tests for "Add 'const' modifier"
This commit is contained in:
@@ -82,7 +82,8 @@ public class AddConstModifierIntention : JetSelfTargetingIntention<JetProperty>(
|
||||
}
|
||||
|
||||
override fun isApplicableTo(element: JetProperty, caretOffset: Int): Boolean {
|
||||
if (element.isVar || element.hasDelegate() || element.initializer == null || element.getter?.hasBody() == true) {
|
||||
if (element.isLocal || element.isVar || element.hasDelegate() || element.initializer == null || element.getter?.hasBody() == true ||
|
||||
element.receiverTypeReference != null) {
|
||||
return false
|
||||
}
|
||||
val propertyDescriptor = element.descriptor as? VariableDescriptor ?: return false
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
val <caret>a = 1
|
||||
@@ -0,0 +1 @@
|
||||
const val <caret>a = 1
|
||||
@@ -0,0 +1,8 @@
|
||||
import constVal.ConstVal_before_MainKt;
|
||||
|
||||
class JavaClient {
|
||||
int foo() {
|
||||
return ConstVal_before_MainKt.i;
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -1,4 +1,6 @@
|
||||
// "Add 'const' modifier" "true"
|
||||
package constVal
|
||||
|
||||
const val i = 1
|
||||
|
||||
annotation class Fancy(val param: Int)
|
||||
+2
@@ -1,4 +1,6 @@
|
||||
// "Add 'const' modifier" "true"
|
||||
package constVal
|
||||
|
||||
val i = 1
|
||||
|
||||
annotation class Fancy(val param: Int)
|
||||
@@ -0,0 +1,8 @@
|
||||
import constVal.ConstVal_before_MainKt;
|
||||
|
||||
class JavaClient {
|
||||
int foo() {
|
||||
return ConstVal_before_MainKt.getI();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +92,21 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/intentions/addConstModifier")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class AddConstModifier extends AbstractIntentionTest {
|
||||
public void testAllFilesPresentInAddConstModifier() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/addConstModifier"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/addConstModifier/simple.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/intentions/addForLoopIndices")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
@@ -1160,6 +1160,12 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/modifiers"), Pattern.compile("^(\\w+)\\.before\\.Main\\.\\w+$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("constVal.before.Main.kt")
|
||||
public void testConstVal() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/modifiers/constVal.before.Main.kt");
|
||||
doTestWithExtraFile(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/quickfix/modifiers/addOpenToClassDeclaration")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
@@ -4223,12 +4223,6 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("constVal.kt")
|
||||
public void testConstVal() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/modifiers/constVal.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("finalTrait.kt")
|
||||
public void testFinalTrait() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/quickfix/modifiers/finalTrait.kt");
|
||||
|
||||
Reference in New Issue
Block a user