Introduce Property: Forbid extension properties with initializers and lazy
ones
This commit is contained in:
+2
@@ -326,6 +326,7 @@ enum class ExtractionTarget(val name: String) {
|
|||||||
&& checkSimpleControlFlow(descriptor)
|
&& checkSimpleControlFlow(descriptor)
|
||||||
&& checkSimpleBody(descriptor)
|
&& checkSimpleBody(descriptor)
|
||||||
&& checkNotTrait(descriptor)
|
&& checkNotTrait(descriptor)
|
||||||
|
&& descriptor.receiverParameter == null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -340,6 +341,7 @@ enum class ExtractionTarget(val name: String) {
|
|||||||
return checkSignatureAndParent(descriptor)
|
return checkSignatureAndParent(descriptor)
|
||||||
&& checkSimpleControlFlow(descriptor)
|
&& checkSimpleControlFlow(descriptor)
|
||||||
&& checkNotTrait(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>
|
||||||
|
}
|
||||||
+1
@@ -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
|
||||||
+12
@@ -2053,6 +2053,12 @@ public class JetExtractionTestGenerated extends AbstractJetExtractionTest {
|
|||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/refactoring/introduceProperty"), Pattern.compile("^(.+)\\.kt$"), true);
|
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")
|
@TestMetadata("extractFromDefaultValueInConstructor.kt")
|
||||||
public void testExtractFromDefaultValueInConstructor() throws Exception {
|
public void testExtractFromDefaultValueInConstructor() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/introduceProperty/extractFromDefaultValueInConstructor.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/introduceProperty/extractFromDefaultValueInConstructor.kt");
|
||||||
@@ -2065,6 +2071,12 @@ public class JetExtractionTestGenerated extends AbstractJetExtractionTest {
|
|||||||
doIntroducePropertyTest(fileName);
|
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")
|
@TestMetadata("extractLazyMultipleExpressions.kt")
|
||||||
public void testExtractLazyMultipleExpressions() throws Exception {
|
public void testExtractLazyMultipleExpressions() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/introduceProperty/extractLazyMultipleExpressions.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/refactoring/introduceProperty/extractLazyMultipleExpressions.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user