Create from usage: Support generation of nested Java classes from usages in Kotlin code

This commit is contained in:
Alexey Sedunov
2015-02-19 13:59:14 +03:00
parent 5cd477279b
commit 60d02dab0f
169 changed files with 1452 additions and 40 deletions
@@ -0,0 +1,8 @@
class J {
public static @interface bar {
String s();
int i();
}
}
@@ -0,0 +1,8 @@
// "Create annotation 'bar'" "true"
// ERROR: Unresolved reference: foo
// ERROR: Unresolved reference: bar
[foo(1, "2", J.bar("3", 4))] fun test() {
}
@@ -0,0 +1,7 @@
// "Create annotation 'bar'" "true"
// ERROR: Unresolved reference: foo
// ERROR: Unresolved reference: bar
[foo(1, "2", J.<caret>bar("3", 4))] fun test() {
}
@@ -0,0 +1,9 @@
import org.jetbrains.annotations.NotNull;
class J {
public static class Foo {
public Foo(int abc, @NotNull A ghi, @NotNull String def) {
}
}
}
@@ -0,0 +1,7 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A(val n: Int)
fun test() = J.Foo(abc = 1, ghi = A(2), def = "s")
@@ -0,0 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A(val n: Int)
fun test() = J.<caret>Foo(abc = 1, ghi = A(2), def = "s")
@@ -0,0 +1,6 @@
// "Create class 'Foo'" "false"
// ACTION: Create function 'Foo'
// ACTION: Convert to block body
// ERROR: Unresolved reference: Foo
fun test(): A = <caret>Foo(2, "2")
@@ -0,0 +1,10 @@
class J<T> {
public J(T n) {
}
public class Foo<U> {
public Foo(U u) {
}
}
}
@@ -0,0 +1,7 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
fun test<U>(u: U) {
val a = J(u).Foo(u)
}
@@ -0,0 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
fun test<U>(u: U) {
val a = J(u).<caret>Foo(u)
}
@@ -0,0 +1,4 @@
// "Create class 'Foo'" "false"
// ERROR: Unresolved reference: Foo
fun test() = J.<caret>Foo(2, "2")
@@ -0,0 +1,7 @@
class J {
public static class Foo {
public Foo(int i) {
}
}
}
@@ -0,0 +1,7 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
fun test() {
val a = J.Foo(2)
}
@@ -0,0 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
fun test() {
val a = J.<caret>Foo(2)
}
@@ -0,0 +1,7 @@
class J {
public class Foo {
public Foo(int i) {
}
}
}
@@ -0,0 +1,7 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
fun test() {
val a = J().Foo(2)
}
@@ -1,9 +1,6 @@
// "Create class 'Foo'" "false"
// ACTION: Create extension function 'Foo'
// ACTION: Create function 'Foo'
// ACTION: Convert to expression body
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
fun test(): Int {
return A().<caret>Foo(1, "2")
fun test() {
val a = J().<caret>Foo(2)
}
@@ -0,0 +1,10 @@
import kotlin.properties.ReadOnlyProperty;
import org.jetbrains.annotations.NotNull;
class J {
public static class Foo<T> implements ReadOnlyProperty<A<T>, B> {
public Foo(T t, @NotNull String s) {
}
}
}
@@ -0,0 +1,10 @@
// "Create class 'Foo'" "true"
// WITH_RUNTIME
// ERROR: Unresolved reference: Foo
open class B
class A<T>(val t: T) {
val x: B by J.Foo(t, "")
}
@@ -0,0 +1,9 @@
// "Create class 'Foo'" "true"
// WITH_RUNTIME
// ERROR: Unresolved reference: Foo
open class B
class A<T>(val t: T) {
val x: B by J.<caret>Foo(t, "")
}
@@ -0,0 +1,9 @@
import org.jetbrains.annotations.NotNull;
class J {
public static class Foo extends A {
public Foo(int i, @NotNull String s) {
}
}
}
@@ -0,0 +1,7 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
open class A
fun test(): A = J.Foo(2, "2")
@@ -0,0 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
open class A
fun test(): A = J.<caret>Foo(2, "2")
@@ -0,0 +1,10 @@
import org.jetbrains.annotations.NotNull;
class J {
public static class Foo extends A {
public Foo(int i, @NotNull String s) {
super();
}
}
}
@@ -0,0 +1,7 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
open class A(val n: Int)
fun test(): A = J.Foo(2, "2")
@@ -0,0 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
open class A(val n: Int)
fun test(): A = J.<caret>Foo(2, "2")
@@ -0,0 +1,9 @@
import org.jetbrains.annotations.NotNull;
class J {
public static class Foo implements T {
public Foo(int i, @NotNull String s) {
}
}
}
@@ -0,0 +1,7 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
trait T
fun test(): T = J.Foo(2, "2")
@@ -0,0 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
trait T
fun test(): T = J.<caret>Foo(2, "2")
@@ -0,0 +1,8 @@
class B<T> {
final T t = null;
public static class Foo<U, V> {
public Foo(U u, V v) {
}
}
}
@@ -0,0 +1,7 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = B.Foo<Int, String>(2, "2")
}
@@ -0,0 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = B.<caret>Foo<Int, String>(2, "2")
}
@@ -0,0 +1,8 @@
class B<T> {
final T t = null;
public class Foo<U, V> {
public Foo(U u, V v) {
}
}
}
@@ -0,0 +1,7 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = b.Foo<Int, String>(2, "2")
}
@@ -0,0 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = b.<caret>Foo<Int, String>(2, "2")
}
@@ -0,0 +1,8 @@
class B<T> {
final T t = null;
public class Foo<U> {
public Foo(int i, U u) {
}
}
}
@@ -0,0 +1,7 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = b.Foo<String>(2, "2")
}
@@ -0,0 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = b.<caret>Foo<String>(2, "2")
}
@@ -0,0 +1,8 @@
class B<T> {
final T t = null;
public class Foo<U, V, W> {
public Foo(V v, W w) {
}
}
}
@@ -0,0 +1,7 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = b.Foo<T, Int, String>(2, "2")
}
@@ -0,0 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = b.<caret>Foo<T, Int, String>(2, "2")
}
@@ -0,0 +1,8 @@
class B<T> {
final T t = null;
public static class Foo<U> {
public Foo(int i, U u) {
}
}
}
@@ -0,0 +1,7 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = B.Foo<String>(2, "2")
}
@@ -0,0 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = B.<caret>Foo<String>(2, "2")
}