Remove "Move to class body" intention for annotation parameters (#1076)

#KT-17708 Fixed
This commit is contained in:
Nadia Humbert-Labeaumaz
2017-05-09 09:27:37 +02:00
committed by Dmitry Jemerov
parent 80e17cbe9c
commit e76f1acc0b
3 changed files with 5 additions and 3 deletions
@@ -29,7 +29,9 @@ import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
class MovePropertyToClassBodyIntention : SelfTargetingIntention<KtParameter>(KtParameter::class.java, "Move to class body") {
override fun isApplicableTo(element: KtParameter, caretOffset: Int): Boolean = element.isPropertyParameter()
override fun isApplicableTo(element: KtParameter, caretOffset: Int): Boolean {
return element.isPropertyParameter() && (element.ownerFunction as KtPrimaryConstructor).isNotContainedInAnnotation()
}
override fun applyTo(element: KtParameter, editor: Editor?) {
val parentClass = PsiTreeUtil.getParentOfType(element, KtClass::class.java) ?: return
@@ -97,4 +99,6 @@ class MovePropertyToClassBodyIntention : SelfTargetingIntention<KtParameter>(KtP
nextSibling?.delete() // ':' symbol after use site
delete()
}
fun KtPrimaryConstructor.isNotContainedInAnnotation() = !getContainingClassOrObject().isAnnotation()
}
-1
View File
@@ -1,5 +1,4 @@
// "Replace array of boxed with array of primitive" "false"
// ACTION: Move to class body
// ERROR: Invalid type of annotation member
annotation class SuperAnnotation(
val foo: <caret>Array<*>,
@@ -1,5 +1,4 @@
// "Replace array of boxed with array of primitive" "false"
// ACTION: Move to class body
annotation class SuperAnnotation(
val str: <caret>Array<String>
)