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:
Pavel V. Talanov
2015-06-08 15:13:33 +03:00
parent 4c4f730c53
commit 07d35d305e
461 changed files with 1275 additions and 472 deletions
@@ -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
@@ -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
@@ -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,
@@ -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
@@ -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&lt;*&gt;</b></td></tr><tr><td>found: </td><td><font color=red><b>java.lang.Class&lt;???&gt;</b></font></td></tr></table></html>
// ERROR: <html>Type mismatch.<table><tr><td>Required:</td><td>kotlin.reflect.KClass&lt;*&gt;</td></tr><tr><td>Found:</td><td>java.lang.Class&lt;[ERROR : Err]&gt;</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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -1,8 +1,8 @@
import java.lang
// "Replace javaClass<T>() with T::class" "true"
// WITH_RUNTIME
import java.lang
Ann(
String::class,
Int::class,