Introduce Property: Forbid extension properties with initializers and lazy

ones
This commit is contained in:
Alexey Sedunov
2015-05-12 13:21:15 +03:00
parent b69b66feab
commit 02006126f5
6 changed files with 26 additions and 0 deletions
@@ -326,6 +326,7 @@ enum class ExtractionTarget(val name: String) {
&& checkSimpleControlFlow(descriptor)
&& checkSimpleBody(descriptor)
&& checkNotTrait(descriptor)
&& descriptor.receiverParameter == null
}
}
@@ -340,6 +341,7 @@ enum class ExtractionTarget(val name: String) {
return checkSignatureAndParent(descriptor)
&& checkSimpleControlFlow(descriptor)
&& checkNotTrait(descriptor)
&& descriptor.receiverParameter == null
}
}
@@ -0,0 +1,5 @@
// EXTRACTION_TARGET: property with initializer
// SIBLING:
class A(val a: Int){
fun foo() = <selection>a + 1</selection>
}
@@ -0,0 +1 @@
Can't generate property with initializer: a + 1
@@ -0,0 +1,5 @@
// EXTRACTION_TARGET: lazy property
// SIBLING:
class A(val a: Int){
fun foo() = <selection>a + 1</selection>
}
@@ -0,0 +1 @@
Can't generate lazy property: a + 1
@@ -2053,6 +2053,12 @@ public class JetExtractionTestGenerated extends AbstractJetExtractionTest {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceProperty"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("extractExtensionWithInitializer.kt")
public void testExtractExtensionWithInitializer() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/introduceProperty/extractExtensionWithInitializer.kt");
doIntroducePropertyTest(fileName);
}
@TestMetadata("extractFromDefaultValueInConstructor.kt")
public void testExtractFromDefaultValueInConstructor() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/introduceProperty/extractFromDefaultValueInConstructor.kt");
@@ -2065,6 +2071,12 @@ public class JetExtractionTestGenerated extends AbstractJetExtractionTest {
doIntroducePropertyTest(fileName);
}
@TestMetadata("extractLazyExtension.kt")
public void testExtractLazyExtension() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/introduceProperty/extractLazyExtension.kt");
doIntroducePropertyTest(fileName);
}
@TestMetadata("extractLazyMultipleExpressions.kt")
public void testExtractLazyMultipleExpressions() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/introduceProperty/extractLazyMultipleExpressions.kt");