Create import list psi element even if no directives are present
Fix a problem where deleting last import directive via "optimize imports" could lead to incorrect psi structure resulting in CCE, see EA-64291 New imports are inserted at the head (after package directive if present) of the file (before any comments) if no imports were present Add test for inserting import to file where a first statement is a comment Drop code dealing with non-existing import list in ImportInsertHelperImpl AbstractQuickFixTest: check for unexpected actions before changes to the file are made as it relies on the first line having specific format
This commit is contained in:
+2
-2
@@ -1,8 +1,8 @@
|
||||
import TestData.TestSample
|
||||
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: TestSample
|
||||
|
||||
import TestData.TestSample
|
||||
|
||||
fun test() {
|
||||
val a = TestSample
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import ppp.XXX
|
||||
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: XXX
|
||||
|
||||
import ppp.XXX
|
||||
|
||||
fun f() {
|
||||
XXX { 1 }
|
||||
}
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import importTrait.data.TestTrait
|
||||
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: TestTrait
|
||||
|
||||
import importTrait.data.TestTrait
|
||||
|
||||
fun test() {
|
||||
val a = <caret>TestTrait
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import test.Test
|
||||
|
||||
// "Import" "true"
|
||||
// ERROR: Unresolved reference: Nested
|
||||
|
||||
import test.Test
|
||||
|
||||
val a = <caret>Test.Nested
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import java.util.LinkedHashSet
|
||||
|
||||
// "Add parameter to function 'foo'" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
import java.util.LinkedHashSet
|
||||
|
||||
fun foo(x: Int, linkedHashSet: LinkedHashSet<Int>) {
|
||||
foo(, java.util.LinkedHashSet<Int>());
|
||||
foo(1, java.util.LinkedHashSet<Int>());
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import kotlin.properties.ReadOnlyProperty
|
||||
|
||||
// "Create class 'Foo'" "true"
|
||||
// ERROR: <html>Class 'Foo' must be declared abstract or implement abstract member<br/><b>public</b> <b>abstract</b> <b>fun</b> get(thisRef: A<T>, desc: kotlin.PropertyMetadata): B <i>defined in</i> kotlin.properties.ReadOnlyProperty</html>
|
||||
|
||||
import kotlin.properties.ReadOnlyProperty
|
||||
|
||||
open class B
|
||||
|
||||
class A<T>(val t: T) {
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
|
||||
// "Create class 'Foo'" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
|
||||
open class B
|
||||
|
||||
class A<T>(val t: T) {
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import kotlin.properties.ReadOnlyProperty
|
||||
|
||||
// "Create object 'Foo'" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
import kotlin.properties.ReadOnlyProperty
|
||||
|
||||
open class B
|
||||
|
||||
class A {
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
|
||||
// "Create object 'Foo'" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
|
||||
open class B
|
||||
|
||||
class A {
|
||||
|
||||
Vendored
+2
-2
@@ -1,7 +1,7 @@
|
||||
// "Create function 'foo'" "true"
|
||||
|
||||
import kotlin.properties.ReadOnlyProperty
|
||||
|
||||
// "Create function 'foo'" "true"
|
||||
|
||||
class A<T>(val t: T) {
|
||||
val x: A<Int> by foo(t, "")
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -1,7 +1,7 @@
|
||||
// "Create function 'foo'" "true"
|
||||
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
|
||||
// "Create function 'foo'" "true"
|
||||
|
||||
class A<T>(val t: T) {
|
||||
var x: A<Int> by foo(t, "")
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
// "Create extension function 'set'" "true"
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
// "Create extension function 'set'" "true"
|
||||
|
||||
class Foo<T> {
|
||||
fun <T> x (y: Any, w: java.util.ArrayList<T>) {
|
||||
y["", w] = w
|
||||
|
||||
Vendored
+2
-2
@@ -1,9 +1,9 @@
|
||||
import kotlin.properties.ReadOnlyProperty
|
||||
|
||||
// "Create property 'foo'" "true"
|
||||
// ERROR: Property must be initialized or be abstract
|
||||
// ERROR: Variable 'foo' must be initialized
|
||||
|
||||
import kotlin.properties.ReadOnlyProperty
|
||||
|
||||
class A<T> {
|
||||
private val foo: ReadOnlyProperty<A<T>, A<Int>>
|
||||
val x: A<Int> by foo
|
||||
|
||||
Vendored
+2
-2
@@ -1,9 +1,9 @@
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
|
||||
// "Create property 'foo'" "true"
|
||||
// ERROR: Property must be initialized or be abstract
|
||||
// ERROR: Variable 'foo' must be initialized
|
||||
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
|
||||
class A<T> {
|
||||
private val foo: ReadWriteProperty<A<T>, A<Int>>
|
||||
var x: A<Int> by foo
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// "Replace with 'newFun(java.io.File.separatorChar)'" "true"
|
||||
|
||||
import java.io.File
|
||||
|
||||
// "Replace with 'newFun(java.io.File.separatorChar)'" "true"
|
||||
|
||||
@deprecated("", ReplaceWith("newFun(java.io.File.separatorChar)"))
|
||||
fun oldFun() { }
|
||||
|
||||
fun newFun(separator: Char){}
|
||||
|
||||
fun foo() {
|
||||
<caret>newFun(File.separatorChar)
|
||||
newFun(File.separatorChar)
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
// "Replace with 'newFun(this)'" "true"
|
||||
|
||||
import dependency.C
|
||||
|
||||
// "Replace with 'newFun(this)'" "true"
|
||||
|
||||
fun foo(c: dependency.C) {
|
||||
C.<caret>newFun(c)
|
||||
}
|
||||
Vendored
+2
-2
@@ -1,8 +1,8 @@
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
// "Replace Class<T> with KClass<T> in whole annotation" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
annotation class Ann(val arg: Array<KClass<*>>)
|
||||
|
||||
Ann(arg = array(String::class, Double::class)) class MyClass
|
||||
|
||||
Vendored
+2
-2
@@ -1,8 +1,8 @@
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
// "Replace Class<T> with KClass<T> in whole annotation" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
annotation class Ann(val arg1: KClass<*>, val arg2: KClass<out Any?>)
|
||||
|
||||
Ann(String::class, Int::class) class MyClass
|
||||
|
||||
Vendored
+2
-2
@@ -1,8 +1,8 @@
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
// "Replace Class<T> with KClass<T> in whole annotation" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
annotation class Ann(
|
||||
val arg1: Int,
|
||||
val arg2: KClass<*> = Int::class,
|
||||
|
||||
Vendored
+2
-2
@@ -1,8 +1,8 @@
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
// "Replace Class<T> with KClass<T> for each annotation in project" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
annotation class Ann1(val arg: KClass<*>)
|
||||
|
||||
Ann1(String::class) class MyClass1
|
||||
|
||||
+2
-2
@@ -1,3 +1,5 @@
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
// "Replace Class<T> with KClass<T> in whole annotation" "true"
|
||||
// ERROR: <html>Type inference failed. Expected type mismatch: <table><tr><td>required: </td><td><b>kotlin.reflect.KClass<*></b></td></tr><tr><td>found: </td><td><font color=red><b>java.lang.Class<???></b></font></td></tr></table></html>
|
||||
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.reflect.KClass<*></td></tr><tr><td>Found:</td><td>java.lang.Class<[ERROR : Err]></td></tr></table></html>
|
||||
@@ -5,8 +7,6 @@
|
||||
// ERROR: Unresolved reference: Err
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
annotation class Ann(vararg val arg: KClass<*>)
|
||||
|
||||
Ann(String::class, javaClass<Err>()) class MyClass1
|
||||
|
||||
Vendored
+2
-2
@@ -1,8 +1,8 @@
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
// "Replace Class<T> with KClass<T> in whole annotation" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
annotation class Ann(vararg val arg: KClass<*>)
|
||||
|
||||
Ann(String::class, Double::class, *array(Char::class)) class MyClass
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import java.lang.Number
|
||||
|
||||
// "Replace javaClass<T>() with T::class in whole project" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
import java.lang.Number
|
||||
|
||||
Ann(arg = array(Int::class, String::class)) class MyClass1
|
||||
|
||||
Ann(arg = array<java.lang.Class<*>>(Number::class, String::class)) class MyClass2
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import java.util.Random
|
||||
|
||||
// "Replace javaClass<T>() with T::class" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
import java.util.Random
|
||||
|
||||
Ann(A::class, A::class, *array(A::class), arg1 = A.B::class, arg2 = Random::class) class MyClass
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import java.lang
|
||||
|
||||
// "Replace javaClass<T>() with T::class" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
import java.lang
|
||||
|
||||
Ann(String::class, x = 2, arg = (Int::class), args = array((Any::class), lang.String::class)) class MyClass
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import java.lang
|
||||
|
||||
// "Replace javaClass<T>() with T::class" "true"
|
||||
// WITH_RUNTIME
|
||||
|
||||
import java.lang
|
||||
|
||||
Ann(
|
||||
String::class,
|
||||
Int::class,
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
// "Change getter type to HashSet<Int>" "true"
|
||||
|
||||
import java.util.HashSet
|
||||
|
||||
// "Change getter type to HashSet<Int>" "true"
|
||||
|
||||
class A() {
|
||||
val i: java.util.HashSet<Int>
|
||||
get(): HashSet<Int> = java.util.LinkedHashSet<Int>()
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
import java.util.LinkedHashSet
|
||||
|
||||
// "Cast expression 'module' to 'LinkedHashSet<Int>'" "true"
|
||||
// DISABLE-ERRORS
|
||||
|
||||
import java.util.LinkedHashSet
|
||||
|
||||
fun foo(): java.util.LinkedHashSet<Int> {
|
||||
val module: java.util.HashSet<Int> = java.util.LinkedHashSet<Int>()
|
||||
return module as LinkedHashSet<Int>
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
// "Change type from 'String' to '(LinkedHashSet<Int>) -> HashSet<Int>'" "true"
|
||||
|
||||
import java.util.HashSet
|
||||
import java.util.LinkedHashSet
|
||||
|
||||
// "Change type from 'String' to '(LinkedHashSet<Int>) -> HashSet<Int>'" "true"
|
||||
|
||||
fun foo(f: ((java.util.LinkedHashSet<Int>) -> java.util.HashSet<Int>) -> String) {
|
||||
foo {
|
||||
(f: (LinkedHashSet<Int>) -> HashSet<Int>) -> "42"
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
// "Change 'bar' function return type to 'HashSet<Int>'" "true"
|
||||
|
||||
import java.util.HashSet
|
||||
|
||||
// "Change 'bar' function return type to 'HashSet<Int>'" "true"
|
||||
|
||||
fun bar(): HashSet<Int> = java.util.LinkedHashSet<Int>()
|
||||
fun foo(): java.util.HashSet<Int> = bar()
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
// "Change type from 'String' to 'HashSet<Int>'" "true"
|
||||
|
||||
import java.util.HashSet
|
||||
|
||||
// "Change type from 'String' to 'HashSet<Int>'" "true"
|
||||
|
||||
fun foo(f: (java.util.HashSet<Int>) -> String) {
|
||||
foo {
|
||||
(x: HashSet<Int>) -> ""
|
||||
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
// "Change 'f' type to '(Delegates) -> Unit'" "true"
|
||||
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
// "Change 'f' type to '(Delegates) -> Unit'" "true"
|
||||
|
||||
fun foo() {
|
||||
var f: (Delegates) -> Unit = { (x: kotlin.properties.Delegates) -> }<caret>
|
||||
var f: (Delegates) -> Unit = { (x: kotlin.properties.Delegates) -> }
|
||||
}
|
||||
Reference in New Issue
Block a user