Move to constructor: change default use-site target: property -> field

So #KT-23801 Fixed
This commit is contained in:
Toshiaki Kameyama
2018-04-17 06:52:58 +03:00
committed by Mikhail Glukhikh
parent 012227dd73
commit c43311ba9a
6 changed files with 7 additions and 6 deletions
@@ -24,6 +24,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.descriptors.ParameterDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
import org.jetbrains.kotlin.descriptors.annotations.KotlinTarget
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.resolveToCall
@@ -77,7 +78,7 @@ class MovePropertyToConstructorIntention :
val propertyAnnotationsText = element.modifierList?.annotationEntries?.joinToString(separator = " ") {
if (it.isApplicableToConstructorParameter()) {
it.getTextWithUseSiteIfMissing("property")
it.getTextWithUseSiteIfMissing(AnnotationUseSiteTarget.FIELD.renderName)
} else {
it.text
}
@@ -4,5 +4,5 @@ annotation class Annotation3(val a: Int = 0)
class TestClass(@Annotation1(42) @Annotation3(42) initialText: String = "LoremIpsum") {
private @Annotation1(42) @field:Annotation2(42) val <caret>text = initialText
private @Annotation1(42) @property:Annotation2(42) val <caret>text = initialText
}
@@ -3,5 +3,5 @@ annotation class Annotation2(val a: Int = 0)
annotation class Annotation3(val a: Int = 0)
class TestClass(private @property:Annotation1(42) @field:Annotation2(42) @Annotation1(42) @Annotation3(42) val text: String = "LoremIpsum") {
class TestClass(private @field:Annotation1(42) @property:Annotation2(42) @Annotation1(42) @Annotation3(42) val text: String = "LoremIpsum") {
}
@@ -1,4 +1,4 @@
annotation class SuperAnnotation
class TestClass(@property:SuperAnnotation val text: String) {
class TestClass(@field:SuperAnnotation val text: String) {
}
@@ -4,5 +4,5 @@ annotation class Annotation3(val a: Int = 0)
class TestClass(@Annotation1(42) @Annotation3(42) initialText: String = "LoremIpsum") {
private @Annotation1(42) @field:Annotation2(42) val <caret>text = "dolor sit amet"
private @Annotation1(42) @property:Annotation2(42) val <caret>text = "dolor sit amet"
}
@@ -3,5 +3,5 @@ annotation class Annotation2(val a: Int = 0)
annotation class Annotation3(val a: Int = 0)
class TestClass(@Annotation1(42) @Annotation3(42) initialText: String = "LoremIpsum", private @property:Annotation1(42) @field:Annotation2(42) val text: String = "dolor sit amet") {
class TestClass(@Annotation1(42) @Annotation3(42) initialText: String = "LoremIpsum", private @field:Annotation1(42) @property:Annotation2(42) val text: String = "dolor sit amet") {
}