KT-7135 Java to Kotlin converter should update usages in Java and Koltin code in the rest of the project

#KT-7135 Fixed
This commit is contained in:
Valentin Kipyatkov
2015-04-07 13:06:31 +03:00
parent b810ebbb0e
commit 1afbb961ee
50 changed files with 962 additions and 156 deletions
@@ -0,0 +1,11 @@
package test;
class JavaClass {
public int field = 0;
protected int myProperty = 0;
public int getProperty() {
return myProperty;
}
}
@@ -0,0 +1,8 @@
package test
open class JavaClass {
public var field: Int = 0
public var property: Int = 0
protected set
}
@@ -0,0 +1,12 @@
package test;
class C extends JavaClass {
public void foo(JavaClass javaClass) {
javaClass.field++;
--javaClass.field;
myProperty = javaClass.field;
javaClass.field -= field;
field = myProperty;
field *= 2;
}
}
@@ -0,0 +1,12 @@
package test;
class C extends JavaClass {
public void foo(JavaClass javaClass) {
javaClass.setField(javaClass.getField() + 1);
javaClass.setField(javaClass.getField() - 1);
setProperty(javaClass.getField());
javaClass.setField(javaClass.getField() - getField());
setField(getProperty());
setField(getField() * 2);
}
}
@@ -0,0 +1,10 @@
package test
class C : JavaClass() {
public fun foo(javaClass: JavaClass) {
javaClass.field++
myProperty = javaClass.field
field = myProperty
field *= 2
}
}
@@ -0,0 +1,10 @@
package test
class C : JavaClass() {
public fun foo(javaClass: JavaClass) {
javaClass.field++
property = javaClass.field
field = property
field *= 2
}
}
@@ -0,0 +1,11 @@
fun foo1(a: AAA) {
a.setX(a.getX() + 1)
}
fun foo2(a: AAA?) {
a?.setX((a?.getX() ?: 0) + 1)
}
fun AAA.foo() {
setX(getX() + 1)
}
@@ -0,0 +1,11 @@
fun foo1(a: AAA) {
a.x = a.x + 1
}
fun foo2(a: AAA?) {
a?.x = (a?.x ?: 0) + 1
}
fun AAA.foo() {
x = x + 1
}
@@ -0,0 +1,3 @@
void foo(AAA a) {
a.setX(a.getX() + 1)
}
@@ -0,0 +1,3 @@
void foo(AAA a) {
a.setX(a.getX() + 1)
}
@@ -0,0 +1,14 @@
package test;
class ClassWithStatics {
public void instanceMethod(){}
public static void staticMethod(int p) {}
public static final int staticField = 1;
protected static int ourValue = 0;
public static int getValue() { return ourValue; }
public static void setValue(int value) { ourValue = value; }
}
@@ -0,0 +1,16 @@
package test
open class ClassWithStatics {
public fun instanceMethod() {
}
companion object {
public fun staticMethod(p: Int) {
}
public val staticField: Int = 1
public var value: Int = 0
}
}
@@ -0,0 +1,16 @@
package test;
class C {
void foo(ClassWithStatics c) {
ClassWithStatics.staticMethod(ClassWithStatics.staticField);
c.instanceMethod();
ClassWithStatics.staticField += 2;
}
}
class D extends ClassWithStatics {
void foo() {
staticMethod(staticField);
ourValue *= 2;
}
}
@@ -0,0 +1,16 @@
package test;
class C {
void foo(ClassWithStatics c) {
ClassWithStatics.Companion.staticMethod(ClassWithStatics.staticField);
c.instanceMethod();
ClassWithStatics.staticField += 2;
}
}
class D extends ClassWithStatics {
void foo() {
Companion.staticMethod(staticField);
value *= 2;
}
}
@@ -0,0 +1,5 @@
package test
fun foo() {
ClassWithStatics.staticMethod(ClassWithStatics.staticField)
}
@@ -0,0 +1,5 @@
package test
fun foo() {
ClassWithStatics.staticMethod(ClassWithStatics.staticField)
}
@@ -0,0 +1,6 @@
package test;
class PureUtils {
public static void foo1(int p) {}
public static int foo2() { return 1; }
}
@@ -0,0 +1,10 @@
package test
object PureUtils {
public fun foo1(p: Int) {
}
public fun foo2(): Int {
return 1
}
}
@@ -0,0 +1,8 @@
package test;
class Utils {
public static void foo1(int p) {}
public static int foo2() { return 1; }
public static final int staticField = 1;
}
+12
View File
@@ -0,0 +1,12 @@
package test
object Utils {
public fun foo1(p: Int) {
}
public fun foo2(): Int {
return 1
}
public val staticField: Int = 1
}
@@ -0,0 +1,9 @@
package test;
class C {
void foo() {
Utils.foo1(Utils.staticField);
Utils.staticField += Utils.foo2();
PureUtils.foo1(PureUtils.foo2())
}
}
@@ -0,0 +1,9 @@
package test;
class C {
void foo() {
Utils.INSTANCE$.foo1(Utils.staticField);
Utils.staticField += Utils.INSTANCE$.foo2();
PureUtils.INSTANCE$.foo1(PureUtils.INSTANCE$.foo2())
}
}
@@ -0,0 +1,6 @@
package test
fun foo() {
Utils.foo1(Utils.staticField)
PureUtils.foo1(PureUtils.foo2())
}
@@ -0,0 +1,6 @@
package test
fun foo() {
Utils.foo1(Utils.staticField)
PureUtils.foo1(PureUtils.foo2())
}