Move to constructor: change default use-site target: property -> field
So #KT-23801 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
012227dd73
commit
c43311ba9a
@@ -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
|
||||
}
|
||||
|
||||
+1
-1
@@ -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
|
||||
}
|
||||
+1
-1
@@ -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
-1
@@ -1,4 +1,4 @@
|
||||
annotation class SuperAnnotation
|
||||
|
||||
class TestClass(@property:SuperAnnotation val text: String) {
|
||||
class TestClass(@field:SuperAnnotation val text: String) {
|
||||
}
|
||||
+1
-1
@@ -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"
|
||||
}
|
||||
+1
-1
@@ -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") {
|
||||
}
|
||||
Reference in New Issue
Block a user