Preserve annotation arguments in "Add use-site target" intention

So #KT-23634 Fixed
This commit is contained in:
Toshiaki Kameyama
2018-04-06 05:04:26 +03:00
committed by Mikhail Glukhikh
parent a5aad22fe7
commit 1cbaab1531
4 changed files with 23 additions and 1 deletions
@@ -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 = ""
}
@@ -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");