Convert property to function: remove annotation use-site target
#KT-36834 Fixed
This commit is contained in:
committed by
Vladimir Dolzhenko
parent
d5e71ebef1
commit
d8ab046136
@@ -83,6 +83,11 @@ class ConvertPropertyToFunctionIntention : SelfTargetingIntention<KtProperty>(Kt
|
||||
}
|
||||
}
|
||||
property.setName(newName)
|
||||
property.annotationEntries.forEach {
|
||||
if (it.useSiteTarget != null) {
|
||||
it.replace(psiFactory.createAnnotationEntry("@${it.shortName}${it.valueArgumentList?.text ?: ""}"))
|
||||
}
|
||||
}
|
||||
|
||||
originalProperty.replace(psiFactory.createFunction(property.text))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
annotation class A
|
||||
annotation class B
|
||||
|
||||
interface Foo {
|
||||
@get:A
|
||||
@B
|
||||
val <caret>bar: String
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
annotation class A
|
||||
annotation class B
|
||||
|
||||
interface Foo {
|
||||
@A
|
||||
@B
|
||||
fun getBar(): String
|
||||
}
|
||||
@@ -5893,6 +5893,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("idea/testData/intentions/convertPropertyToFunction"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), null, true);
|
||||
}
|
||||
|
||||
@TestMetadata("annotationUseSiteTarget.kt")
|
||||
public void testAnnotationUseSiteTarget() throws Exception {
|
||||
runTest("idea/testData/intentions/convertPropertyToFunction/annotationUseSiteTarget.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockBody.kt")
|
||||
public void testBlockBody() throws Exception {
|
||||
runTest("idea/testData/intentions/convertPropertyToFunction/blockBody.kt");
|
||||
|
||||
Reference in New Issue
Block a user