Preserve annotation arguments in "Add use-site target" intention
So #KT-23634 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
a5aad22fe7
commit
1cbaab1531
+1
-1
@@ -141,6 +141,6 @@ private fun KtAnnotationEntry.applicableUseSiteTargets(): List<AnnotationUseSite
|
||||
|
||||
private fun KtAnnotationEntry.addUseSiteTarget(useSiteTarget: AnnotationUseSiteTarget, project: Project) {
|
||||
project.executeWriteCommand("Add use-site target") {
|
||||
replace(KtPsiFactory(this).createAnnotationEntry("@${useSiteTarget.renderName}:$shortName"))
|
||||
replace(KtPsiFactory(this).createAnnotationEntry("@${useSiteTarget.renderName}:$shortName${valueArgumentList?.text ?: ""}"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// CHOOSE_USE_SITE_TARGET: field
|
||||
|
||||
annotation class A(val s: String)
|
||||
|
||||
class Test {
|
||||
@A("...")<caret>
|
||||
val foo: String = ""
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// CHOOSE_USE_SITE_TARGET: field
|
||||
|
||||
annotation class A(val s: String)
|
||||
|
||||
class Test {
|
||||
@field:A("...")
|
||||
val foo: String = ""
|
||||
}
|
||||
@@ -33,6 +33,12 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/addAnnotationUseSiteTarget"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("hasAnnotationArgs.kt")
|
||||
public void testHasAnnotationArgs() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addAnnotationUseSiteTarget/hasAnnotationArgs.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("hasTarget1.kt")
|
||||
public void testHasTarget1() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/addAnnotationUseSiteTarget/hasTarget1.kt");
|
||||
|
||||
Reference in New Issue
Block a user