Fix MovePropertyToConstructorIntention and broken tests
This commit is contained in:
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.idea.util.CommentSaver
|
||||
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
|
||||
import org.jetbrains.kotlin.lexer.KtTokens.LATEINIT_KEYWORD
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
import org.jetbrains.kotlin.resolve.AnnotationChecker
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
@@ -55,6 +56,7 @@ class MovePropertyToConstructorIntention :
|
||||
&& element.getter == null
|
||||
&& element.setter == null
|
||||
&& !element.hasModifier(LATEINIT_KEYWORD)
|
||||
&& element.getStrictParentOfType<KtClassOrObject>() is KtClass
|
||||
|
||||
override fun applyTo(element: KtProperty, editor: Editor?) {
|
||||
val parentClass = PsiTreeUtil.getParentOfType(element, KtClass::class.java) ?: return
|
||||
|
||||
+1
@@ -3,6 +3,7 @@
|
||||
// ACTION: Create parameter 'foo'
|
||||
// ACTION: Create property 'foo'
|
||||
// ACTION: Rename reference
|
||||
// ACTION: Move to constructor
|
||||
// ERROR: Unresolved reference: foo
|
||||
|
||||
class A {
|
||||
|
||||
+1
@@ -1,6 +1,7 @@
|
||||
// "Make bar internal" "false"
|
||||
// ACTION: Convert property initializer to getter
|
||||
// ACTION: Add names to call arguments
|
||||
// ACTION: Move to constructor
|
||||
// ERROR: Cannot access 'bar': it is private in 'First'
|
||||
|
||||
private data class Data(val x: Int)
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// "Change type of overriden property 'A.x' to '(Int) -> Int'" "false"
|
||||
// ACTION: Change type to '(String) -> Int'
|
||||
// ACTION: Move to constructor
|
||||
// ERROR: Type of 'x' is not a subtype of the overridden property 'public abstract val x: (String) -> Int defined in A'
|
||||
interface A {
|
||||
val x: (String) -> Int
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// ACTION: Convert property to function
|
||||
// ACTION: Introduce backing property
|
||||
// ACTION: Move to companion object
|
||||
// ACTION: Move to constructor
|
||||
// ERROR: Unresolved reference: foo
|
||||
|
||||
class A() {
|
||||
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// "Change type to '(String) -> [ERROR : Ay]'" "false"
|
||||
// ACTION: Change type of base property 'A.x' to '(Int) -> Int'
|
||||
// ACTION: Move to constructor
|
||||
// ERROR: Type of 'x' is not a subtype of the overridden property 'public abstract val x: (String) -> [ERROR : Ay] defined in A'
|
||||
// ERROR: Unresolved reference: Ay
|
||||
interface A {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// "Replace array of boxed with array of primitive" "false"
|
||||
// ACTION: Convert to secondary constructor
|
||||
// ACTION: Move to class body
|
||||
// ERROR: Invalid type of annotation member
|
||||
annotation class SuperAnnotation(
|
||||
val foo: <caret>Array<*>,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// "Replace array of boxed with array of primitive" "false"
|
||||
// ACTION: Convert to secondary constructor
|
||||
// ACTION: Move to class body
|
||||
annotation class SuperAnnotation(
|
||||
val str: <caret>Array<String>
|
||||
)
|
||||
+1
@@ -4,5 +4,6 @@
|
||||
// ACTION: Make protected
|
||||
// ACTION: Create test
|
||||
// ACTION: Convert to secondary constructor
|
||||
// ACTION: Move to class body
|
||||
class C(<caret>val x: String) {
|
||||
}
|
||||
Reference in New Issue
Block a user