Add quickfix for migrating Java annotation method calls

This commit is contained in:
Denis Zharkov
2015-04-21 19:06:05 +03:00
parent 634b1a9568
commit 3cb6b61a47
9 changed files with 177 additions and 0 deletions
@@ -0,0 +1,6 @@
// "Replace method call with property access" "true"
// WITH_RUNTIME
fun foo(ann: Ann) {
ann.value
}
@@ -0,0 +1,6 @@
// "Replace method call with property access" "true"
// WITH_RUNTIME
fun foo(ann: Ann) {
ann.value()<caret>
}
@@ -0,0 +1,3 @@
public @interface Ann {
int value();
}
@@ -0,0 +1,32 @@
// "Replace deprecated method calls with property access in current file" "true"
// WITH_RUNTIME
class A {
fun foo() {}
}
fun bar(x: Int) {
javaClass<A>().getAnnotation(javaClass<Ann>()).args[0]
javaClass<A>().getAnnotation(javaClass<Ann>()).y
}
fun foo(ann: Ann, a: A) {
ann.value
bar(ann.x + (ann).y)
a.foo()
a.equals(a)
a.toString()
a.hashCode()
class Local {
val prop = ann.arg
fun baz() {
val v = ann.args
val summ = ann.x * ann.ext()
}
fun Ann.ext(): Int = -y
}
}
@@ -0,0 +1,32 @@
// "Replace deprecated method calls with property access in current file" "true"
// WITH_RUNTIME
class A {
fun foo() {}
}
fun bar(x: Int) {
javaClass<A>().getAnnotation(javaClass<Ann>()).args()[0]
javaClass<A>().getAnnotation(javaClass<Ann>()).y()
}
fun foo(ann: Ann, a: A) {
ann.value()<caret>
bar(ann.x() + (ann).y())
a.foo()
a.equals(a)
a.toString()
a.hashCode()
class Local {
val prop = ann.arg()
fun baz() {
val v = ann.args()
val summ = ann.x() * ann.ext()
}
fun Ann.ext(): Int = -y()
}
}
@@ -0,0 +1,7 @@
public @interface Ann {
Class<?> value();
int x() default 1;
int y() default 2;
Class<?> arg() default String;
Class<?>[] args() default {};
}