Add intention to introduce import alias

#KT-16118 Fixed
 #KT-30007 Fixed
This commit is contained in:
Dmitry Gridin
2019-02-21 10:38:43 +03:00
parent 6bf119b262
commit 147521d6cb
94 changed files with 893 additions and 4 deletions
@@ -1,5 +1,6 @@
// "Add annotation target" "false"
// WITH_RUNTIME
// ACTION: Introduce import alias
// ACTION: Make internal
// ACTION: Make private
// ACTION: Make protected
@@ -1,4 +1,5 @@
// "Add annotation target" "false"
// ACTION: Introduce import alias
// ACTION: Make internal
// ACTION: Make private
// ACTION: Make protected
@@ -1,5 +1,6 @@
// "Add annotation target" "false"
// WITH_RUNTIME
// ACTION: Introduce import alias
// ACTION: Make internal
// ACTION: Make private
// ERROR: '@field:' annotations could be applied only to properties with backing fields
@@ -1,4 +1,5 @@
// "Add annotation target" "false"
// ACTION: Introduce import alias
// ACTION: Make internal
// ACTION: Make private
// ACTION: Specify type explicitly
@@ -1,6 +1,7 @@
// "Add default constructor to expect class" "false"
// ENABLE_MULTIPLATFORM
// ACTION: Create subclass
// ACTION: Introduce import alias
// ACTION: Remove constructor call
// ERROR: This class does not have a constructor
@@ -1,5 +1,6 @@
// "Add default constructor to expect class" "false"
// ACTION: Create subclass
// ACTION: Introduce import alias
// ACTION: Remove constructor call
// ERROR: This class does not have a constructor
@@ -3,6 +3,7 @@
// ERROR: Expression 'Some()' of type 'Some' cannot be invoked as a function. The function 'invoke()' is not found
// ACTION: Create extension function 'Some.invoke'
// ACTION: Create member function 'Some.invoke'
// ACTION: Introduce import alias
package testing
@@ -3,6 +3,7 @@
// ERROR: Destructuring declaration initializer of type Some must have a 'component1()' function
// ACTION: Create extension function 'Some.component1'
// ACTION: Create member function 'Some.component1'
// ACTION: Introduce import alias
package testing
@@ -1,4 +1,5 @@
// "Convert to anonymous object" "false"
// ACTION: Introduce import alias
// ERROR: Interface I does not have constructors
interface I {
fun foo(): String
@@ -1,4 +1,5 @@
// "Create type parameter in class 'X'" "false"
// ACTION: Introduce import alias
// ERROR: 2 type arguments expected for class X<T, U>
class X<T, U>
fun Y(x: X<<caret>String>) {}
@@ -1,4 +1,5 @@
// "Create type parameter in class 'X'" "false"
// ACTION: Introduce import alias
// ERROR: No type arguments expected for class X
class X
@@ -1,5 +1,6 @@
// "Create property 'address2' as constructor parameter" "false"
// ACTION: Create property 'address' as constructor parameter
// ACTION: Introduce import alias
// ACTION: Make 'Person' data class
// ERROR: Destructuring declaration initializer of type Person must have a 'component3()' function
// ERROR: Destructuring declaration initializer of type Person must have a 'component4()' function
@@ -1,5 +1,6 @@
// "Make 'foo' private" "false"
// ACTION: Convert receiver to parameter
// ACTION: Introduce import alias
// ACTION: Make 'Private' protected
// ACTION: Make 'Private' public
// ERROR: 'protected (in My)' member exposes its 'private' receiver type argument Private
@@ -1,5 +1,6 @@
// "Make '<init>' internal" "false"
// DISABLE-ERRORS
// ACTION: Introduce import alias
// ACTION: Make 'My' public
internal class My
@@ -1,5 +1,6 @@
// "Replace with 'New<T, U>'" "false"
// ACTION: Convert to block body
// ACTION: Introduce import alias
// ACTION: Remove explicit type specification
@Deprecated("Use New", replaceWith = ReplaceWith("New<T, U>"))
@@ -1,4 +1,5 @@
// "Replace with 'NewClass'" "false"
// ACTION: Introduce import alias
// ACTION: Introduce local variable
// ACTION: Replace usages of 'typealias Old = OldClass' in whole project
// ACTION: Replace with 'New'
@@ -1,5 +1,6 @@
// "Replace with 'New'" "false"
// ACTION: Convert to block body
// ACTION: Introduce import alias
// ACTION: Introduce local variable
// ACTION: Replace usages of '<init>(): Old /* = OldClass */' in whole project
// ACTION: Replace with 'NewClass(12)'
@@ -1,5 +1,6 @@
// "Replace with 'NewClass'" "false"
// ACTION: Convert to block body
// ACTION: Introduce import alias
// ACTION: Remove explicit type specification
@@ -1,5 +1,6 @@
// "Replace with 'NewClass'" "false"
// ACTION: Convert to block body
// ACTION: Introduce import alias
// ACTION: Introduce local variable
+1
View File
@@ -2,6 +2,7 @@
// COMPILER_ARGUMENTS: -version -Xuse-experimental=Something
// DISABLE-ERRORS
// WITH_RUNTIME
// ACTION: Introduce import alias
// ACTION: Make internal
// ACTION: Make private
+1
View File
@@ -5,6 +5,7 @@
// ACTION: Add '@MyExperimentalAPI' annotation to containing class 'Inner'
// ACTION: Add '@UseExperimental(MyExperimentalAPI::class)' annotation to 'bar'
// ACTION: Add '-Xuse-experimental=MyExperimentalAPI' to module light_idea_test_case compiler arguments
// ACTION: Introduce import alias
// ERROR: This declaration is experimental and its usage must be marked with '@MyExperimentalAPI' or '@UseExperimental(MyExperimentalAPI::class)'
@Experimental
@@ -1,5 +1,6 @@
// "Make '<init>' public" "false"
// "Make '<init>' internal" "false"
// ACTION: Introduce import alias
// ERROR: Cannot access '<init>': it is private in 'SealedClass'
// ERROR: This type is sealed, so it can be inherited by only its own nested classes or objects
@@ -2,5 +2,6 @@
// ERROR: This type is final, so it cannot be inherited from
// ACTION: Add names to call arguments
// ACTION: Do not show hints for current method
// ACTION: Introduce import alias
data class A(val x: Int)
class B: A<caret>(42)
@@ -1,4 +1,5 @@
// "class org.jetbrains.kotlin.idea.quickfix.AddModifierFix" "false"
// ERROR: This type is final, so it cannot be inherited from
// ACTION: Create test
// ACTION: Introduce import alias
class foo : <caret>JavaClass() {}
@@ -1,5 +1,6 @@
// "class org.jetbrains.kotlin.idea.quickfix.AddModifierFix" "false"
// ACTION: Create test
// ACTION: Inline type parameter
// ACTION: Introduce import alias
// ACTION: Remove final upper bound
class foo<T : <caret>JavaClass>() {}
@@ -1,5 +1,6 @@
// "Add 'lateinit' modifier" "false"
// ACTION: Add initializer
// ACTION: Introduce import alias
// ACTION: Make 'a' abstract
// ACTION: Move to constructor parameters
// ACTION: Move to constructor
+1
View File
@@ -1,4 +1,5 @@
// "Make bar suspend" "false"
// ACTION: Introduce import alias
// ERROR: Suspend function 'foo' should be called only from a coroutine or another suspend function
suspend fun foo() {}
+1
View File
@@ -1,5 +1,6 @@
// "Make bar suspend" "false"
// ACTION: Convert property initializer to getter
// ACTION: Introduce import alias
// ERROR: Suspend function 'foo' should be called only from a coroutine or another suspend function
suspend fun foo() = 42
@@ -1,6 +1,7 @@
// "Move annotation to receiver type" "false"
// ERROR: This annotation is not applicable to target 'declaration' and use site target '@receiver'
// ACTION: Make internal
// ACTION: Introduce import alias
// ACTION: Make private
// ACTION: Add annotation target
@@ -1,6 +1,7 @@
// "Move annotation to receiver type" "false"
// ERROR: This annotation is not applicable to target 'declaration' and use site target '@receiver'
// ACTION: Make internal
// ACTION: Introduce import alias
// ACTION: Make private
// ACTION: Specify type explicitly
// ACTION: Add annotation target
@@ -1,4 +1,5 @@
// "Optimize imports" "false"
// ACTION: Introduce import alias
import p1.SomeAlias<caret>
import p1.AnnAlias
@@ -1,5 +1,6 @@
// "Change type of overriden property 'A.x' to '(Int) -> Int'" "false"
// ACTION: Change type to '(String) -> Int'
// ACTION: Introduce import alias
// 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
@@ -1,6 +1,7 @@
// "Change 'B.foo' function return type to 'Int'" "false"
// "Change 'B.foo' function return type to 'Long'" "false"
// "Remove explicitly specified return type" "false"
// ACTION: Introduce import alias
// ERROR: Return type of 'foo' is not a subtype of the return type of the overridden member 'public abstract fun foo(): Int defined in A'
abstract class A {
abstract fun foo() : Int;
@@ -1,4 +1,5 @@
// "Change to constructor invocation" "false"
// ACTION: Introduce import alias
// ERROR: This type has a constructor, and thus must be initialized here
// ERROR: This type is sealed, so it can be inherited by only its own nested classes or objects
sealed class A
@@ -1,4 +1,5 @@
// "Change to constructor invocation" "false"
// ACTION: Introduce import alias
// ERROR: This type has a constructor, and thus must be initialized here
// ERROR: This type is sealed, so it can be inherited by only its own nested classes or objects
@@ -1,5 +1,6 @@
// "Cast expression 'Foo<Number>()' to 'Foo<Int>'" "false"
// ACTION: Change return type of enclosing function 'foo' to 'Foo<Number>'
// ACTION: Introduce import alias
// ERROR: Type mismatch: inferred type is Foo<Number> but Foo<Int> was expected
class Foo<T>
@@ -1,5 +1,6 @@
// "Change type to '(String) -> [ERROR : Ay]'" "false"
// ACTION: Change type of base property 'A.x' to '(Int) -> Int'
// ACTION: Introduce import alias
// 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 {
@@ -4,6 +4,7 @@
// ACTION: Change parameter 'block' type of function 'str' to 'Object'
// ACTION: Create function 'str'
// ACTION: Edit method contract of 'Object'
// ACTION: Introduce import alias
fun fn() {
str(<caret>Object())
}
+1
View File
@@ -1,5 +1,6 @@
// "Replace array of boxed with array of primitive" "false"
// ERROR: Invalid type of annotation member
// ACTION: Introduce import alias
// ACTION: Put parameters on one line
annotation class SuperAnnotation(
val foo: <caret>Array<*>,
@@ -1,5 +1,6 @@
// "Replace array of boxed with array of primitive" "false"
// ACTION: Put parameters on one line
// ACTION: Introduce import alias
// ACTION: Convert to vararg parameter (may break code)
annotation class SuperAnnotation(
val str: <caret>Array<String>
@@ -1,6 +1,7 @@
// "Change to val" "false"
// ACTION: Create extension function 'Delegate.getValue'
// ACTION: Create member function 'Delegate.getValue'
// ACTION: Introduce import alias
// ERROR: Missing 'getValue(Nothing?, KProperty<*>)' method on delegate of type 'Delegate'
import kotlin.reflect.KProperty
@@ -1,6 +1,7 @@
// "Change to val" "false"
// ACTION: Create extension function 'Delegate.getValue', function 'Delegate.setValue'
// ACTION: Create member function 'Delegate.getValue', function 'Delegate.setValue'
// ACTION: Introduce import alias
// ERROR: Missing 'getValue(Nothing?, KProperty<*>)' method on delegate of type 'Delegate'
// ERROR: Missing 'setValue(Nothing?, KProperty<*>, String)' method on delegate of type 'Delegate'
import kotlin.reflect.KProperty
@@ -1,6 +1,7 @@
// "Wrap with '?.let { ... }' call" "false"
// WITH_RUNTIME
// ACTION: Add non-null asserted (!!) call
// ACTION: Introduce import alias
// ACTION: Introduce local variable
// ACTION: Replace with safe (this?.) call
// ERROR: Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type String?