KT-7151 Convert 'System.out.println()' to just 'println()'
#KT-7151 Fixed
This commit is contained in:
@@ -274,7 +274,7 @@ class DefaultExpressionConverter : JavaElementVisitor(), ExpressionConverter {
|
||||
|
||||
if (target is PsiMethod) {
|
||||
val specialMethod = SpecialMethod.values().firstOrNull { it.matches(target) }
|
||||
if (specialMethod != null && arguments.size() == specialMethod.parameterCount) {
|
||||
if (specialMethod != null && (specialMethod.parameterCount == null || specialMethod.parameterCount == arguments.size())) {
|
||||
val converted = specialMethod.convertCall(methodExpr.getQualifierExpression(), arguments, typeArguments, codeConverter)
|
||||
if (converted != null) {
|
||||
result = converted
|
||||
|
||||
@@ -16,19 +16,14 @@
|
||||
|
||||
package org.jetbrains.kotlin.j2k
|
||||
|
||||
import com.intellij.psi.PsiMethod
|
||||
import com.intellij.psi.PsiExpression
|
||||
import org.jetbrains.kotlin.j2k.ast.BinaryExpression
|
||||
import org.jetbrains.kotlin.j2k.ast.Expression
|
||||
import org.jetbrains.kotlin.j2k.ast.MethodCallExpression
|
||||
import com.intellij.psi.CommonClassNames.JAVA_LANG_OBJECT
|
||||
import com.intellij.psi.PsiExpression
|
||||
import com.intellij.psi.PsiMethod
|
||||
import com.intellij.psi.PsiReferenceExpression
|
||||
import com.intellij.psi.PsiSuperExpression
|
||||
import org.jetbrains.kotlin.j2k.ast.QualifiedExpression
|
||||
import org.jetbrains.kotlin.j2k.ast.Identifier
|
||||
import org.jetbrains.kotlin.j2k.ast.assignNoPrototype
|
||||
import org.jetbrains.kotlin.j2k.ast.Type
|
||||
import org.jetbrains.kotlin.j2k.ast.*
|
||||
|
||||
enum class SpecialMethod(val qualifiedClassName: String?, val methodName: String, val parameterCount: Int) {
|
||||
enum class SpecialMethod(val qualifiedClassName: String?, val methodName: String, val parameterCount: Int?) {
|
||||
OBJECT_EQUALS: SpecialMethod(null, "equals", 1) {
|
||||
override fun matches(method: PsiMethod)
|
||||
= super.matches(method) && method.getParameterList().getParameters().single().getType().getCanonicalText() == JAVA_LANG_OBJECT
|
||||
@@ -76,11 +71,36 @@ enum class SpecialMethod(val qualifiedClassName: String?, val methodName: String
|
||||
= MethodCallExpression.build(null, "setOf", listOf(codeConverter.convertExpression(arguments.single())), typeArgumentsConverted, false)
|
||||
}
|
||||
|
||||
SYSTEM_OUT_PRINTLN: SpecialMethod("java.io.PrintStream", "println", null) {
|
||||
override fun convertCall(qualifier: PsiExpression?, arguments: Array<PsiExpression>, typeArgumentsConverted: List<Type>, codeConverter: CodeConverter)
|
||||
= convertSystemOutMethodCall(methodName, qualifier, arguments, typeArgumentsConverted, codeConverter)
|
||||
}
|
||||
|
||||
SYSTEM_OUT_PRINT: SpecialMethod("java.io.PrintStream", "print", null) {
|
||||
override fun convertCall(qualifier: PsiExpression?, arguments: Array<PsiExpression>, typeArgumentsConverted: List<Type>, codeConverter: CodeConverter)
|
||||
= convertSystemOutMethodCall(methodName, qualifier, arguments, typeArgumentsConverted, codeConverter)
|
||||
}
|
||||
|
||||
open fun matches(method: PsiMethod): Boolean {
|
||||
if (method.getName() != methodName) return false
|
||||
if (qualifiedClassName != null && method.getContainingClass()?.getQualifiedName() != qualifiedClassName) return false
|
||||
return method.getParameterList().getParametersCount() == parameterCount
|
||||
return parameterCount == null || parameterCount == method.getParameterList().getParametersCount()
|
||||
}
|
||||
|
||||
abstract fun convertCall(qualifier: PsiExpression?, arguments: Array<PsiExpression>, typeArgumentsConverted: List<Type>, codeConverter: CodeConverter): Expression?
|
||||
}
|
||||
|
||||
private fun convertSystemOutMethodCall(
|
||||
methodName: String,
|
||||
qualifier: PsiExpression?,
|
||||
arguments: Array<PsiExpression>,
|
||||
typeArgumentsConverted: List<Type>,
|
||||
codeConverter: CodeConverter
|
||||
): Expression? {
|
||||
if (qualifier !is PsiReferenceExpression) return null
|
||||
val qqualifier = qualifier.getQualifierExpression() as? PsiReferenceExpression ?: return null
|
||||
if (qqualifier.getCanonicalText() != "java.lang.System") return null
|
||||
if (qualifier.getReferenceName() != "out") return null
|
||||
if (typeArgumentsConverted.isNotEmpty()) return null
|
||||
return MethodCallExpression.build(null, methodName, arguments.map { codeConverter.convertExpression(it) }, emptyList(), false)
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public class Test(str: String) {
|
||||
|
||||
public fun sout(str: String) {
|
||||
// UNNECESSARY_NOT_NULL_ASSERTION heuristic does not work any more, instead we can skip generating !! altogether
|
||||
System.out!!.println(str)
|
||||
println(str)
|
||||
}
|
||||
|
||||
public fun dummy(str: String): String {
|
||||
|
||||
@@ -9,7 +9,7 @@ public class Test(str: String?) {
|
||||
}
|
||||
|
||||
public fun sout(str: String?) {
|
||||
System.out.println(str)
|
||||
println(str)
|
||||
}
|
||||
|
||||
public fun dummy(str: String?): String? {
|
||||
|
||||
@@ -1 +1 @@
|
||||
System.out.println("Hello, world")
|
||||
println("Hello, world")
|
||||
@@ -1,11 +1,11 @@
|
||||
public object A {
|
||||
public fun main(args: Array<String>) {
|
||||
System.out.println(Void.TYPE)
|
||||
System.out.println(Integer.TYPE)
|
||||
System.out.println(java.lang.Double.TYPE)
|
||||
System.out.println(javaClass<IntArray>())
|
||||
System.out.println(javaClass<Array<Any>>())
|
||||
System.out.println(javaClass<Array<Array<Any>>>())
|
||||
println(Void.TYPE)
|
||||
println(Integer.TYPE)
|
||||
println(java.lang.Double.TYPE)
|
||||
println(javaClass<IntArray>())
|
||||
println(javaClass<Array<Any>>())
|
||||
println(javaClass<Array<Array<Any>>>())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class C {
|
||||
fun foo(o: Any) {
|
||||
if (o !is String) return
|
||||
System.out.println("String")
|
||||
println("String")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,17 +10,17 @@ import java.util.ArrayList // we need ArrayList
|
||||
class A /* just a sample name*/ : Runnable /* let's implement Runnable */ {
|
||||
fun foo/* again a sample name */(p: Int /* parameter p */, c: Char /* parameter c */) {
|
||||
// let's print something:
|
||||
System.out.println("1") // print 1
|
||||
System.out.println("2") // print 2
|
||||
println("1") // print 1
|
||||
println("2") // print 2
|
||||
|
||||
System.out.println("3") // print 3
|
||||
println("3") // print 3
|
||||
|
||||
// end of printing
|
||||
|
||||
if (p > 0) {
|
||||
// do this only when p > 0
|
||||
// we print 4 and return
|
||||
System.out.println("3")
|
||||
println("3")
|
||||
return // do not continue
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
fun foo(b: Boolean) {
|
||||
if (b)
|
||||
System.out.println("true")
|
||||
println("true")
|
||||
else
|
||||
System.out.println("false")
|
||||
println("false")
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
class C(arg1: Int, arg2: Int, arg3: Int) {
|
||||
|
||||
constructor(arg1: Int, arg2: Int) : this(arg1, arg2, 0) {
|
||||
System.out.println()
|
||||
println()
|
||||
}
|
||||
|
||||
constructor(arg1: Int) : this(arg1, 0) {
|
||||
System.out.println()
|
||||
println()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class CustomerBuilder {
|
||||
public object User {
|
||||
public fun main() {
|
||||
val customer = CustomerBuilder().WithFirstName("Homer").WithLastName("Simpson").Build()
|
||||
System.out.println(customer.firstName)
|
||||
System.out.println(customer.lastName)
|
||||
println(customer.firstName)
|
||||
println(customer.lastName)
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
class C(private val field: Int) {
|
||||
|
||||
init {
|
||||
System.out.println(field)
|
||||
println(field)
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ class C(p: Int) {
|
||||
init {
|
||||
var p = p
|
||||
this.p = p
|
||||
System.out.println(p++)
|
||||
System.out.println(p)
|
||||
println(p++)
|
||||
println(p)
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ class C(private val arg1: Int, private val arg2: Int, private val arg3: Int) {
|
||||
}
|
||||
|
||||
constructor(arg1: Int, arg2: Int, other: C) : this(arg1, arg2, 0) {
|
||||
System.out.println(foo(1) + this.foo(2) + other.foo(3) + staticFoo(4) + C.staticFoo(5))
|
||||
println(foo(1) + this.foo(2) + other.foo(3) + staticFoo(4) + C.staticFoo(5))
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -3,11 +3,11 @@ class C {
|
||||
}
|
||||
|
||||
constructor(arg1: Int, arg2: Int) : this(arg1, arg2, 0) {
|
||||
System.out.println()
|
||||
println()
|
||||
}
|
||||
|
||||
constructor(arg: Int) {
|
||||
System.out.println(arg)
|
||||
println(arg)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ class C(arg1: Int, arg2: Int = 0, arg3: Int = 0) {
|
||||
var arg1 = arg1
|
||||
var arg3 = arg3
|
||||
arg1++
|
||||
System.out.print(arg1 + arg2)
|
||||
print(arg1 + arg2)
|
||||
field = arg3
|
||||
arg3++
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class C(private val arg1: Int, private val arg2: Int, private val arg3: Int) {
|
||||
|
||||
constructor(arg1: Int, arg2: Int, other: C) : this(arg1, arg2, 0) {
|
||||
System.out.println(this.arg1 + other.arg2)
|
||||
println(this.arg1 + other.arg2)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class C() {
|
||||
|
||||
constructor(p: Int) : this() {
|
||||
System.out.println(staticField1 + C.staticField2)
|
||||
println(staticField1 + C.staticField2)
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -4,7 +4,7 @@ public class X {
|
||||
var value = 10
|
||||
|
||||
override fun run() {
|
||||
System.out.println(value)
|
||||
println(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
public class Test(public var id: String?, public val name: String, public val age: Int) {
|
||||
|
||||
init {
|
||||
System.out.println(age)
|
||||
println(age)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ public class AAA {
|
||||
private set
|
||||
|
||||
public fun foo(other: AAA) {
|
||||
System.out.println(x)
|
||||
System.out.println(other.x)
|
||||
println(x)
|
||||
println(other.x)
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,15 +3,15 @@ public open class AAA {
|
||||
protected set
|
||||
|
||||
public fun foo(other: AAA) {
|
||||
System.out.println(x)
|
||||
System.out.println(other.x)
|
||||
println(x)
|
||||
println(other.x)
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
|
||||
class BBB : AAA() {
|
||||
fun bar() {
|
||||
System.out.println(x)
|
||||
println(x)
|
||||
x = 10
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,6 @@ class C {
|
||||
public val default: Int = 0
|
||||
|
||||
fun foo() {
|
||||
System.out.println(default)
|
||||
println(default)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ class C {
|
||||
public val `this`: Int = 0
|
||||
|
||||
fun foo() {
|
||||
System.out.println(`this`)
|
||||
println(`this`)
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,6 @@ enum class Color : Runnable {
|
||||
BLUE
|
||||
|
||||
override fun run() {
|
||||
System.out.println("name()=" + name() + ", toString()=" + toString())
|
||||
println("name()=" + name() + ", toString()=" + toString())
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
public class A {
|
||||
fun foo(array: Array<String>) {
|
||||
for (i in array.indices.reversed()) {
|
||||
System.out.println(i)
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
public class A {
|
||||
fun foo() {
|
||||
for (i in 10 downTo 0) {
|
||||
System.out.println(i)
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
public class A {
|
||||
fun foo() {
|
||||
for (i in 10 downTo 1) {
|
||||
System.out.println(i)
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
public class A {
|
||||
fun foo(min: Int) {
|
||||
for (i in 10 downTo min + 1) {
|
||||
System.out.println(i)
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
public class A {
|
||||
fun foo(array: Array<String>) {
|
||||
for (i in array.size() downTo 0) {
|
||||
System.out.println(i)
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
public class A {
|
||||
fun foo(array: Array<String>) {
|
||||
for (i in array.size() - 2 downTo 0) {
|
||||
System.out.println(i)
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
public class A {
|
||||
fun foo(collection: Collection<String>) {
|
||||
for (i in collection.size() downTo 0) {
|
||||
System.out.println(i)
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
for (i in 0..N - 1) {
|
||||
System.out.println(i)
|
||||
println(i)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import java.lang.System
|
||||
class C {
|
||||
fun foo1(collection: Collection<String>) {
|
||||
for (i in collection.indices) {
|
||||
System.out.print(i)
|
||||
print(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ class X {
|
||||
class C {
|
||||
fun foo(x: X) {
|
||||
for (i in 0..x.length - 1) {
|
||||
System.out.print(i)
|
||||
print(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ class X {
|
||||
class C {
|
||||
fun foo(x: X) {
|
||||
for (i in 0..x.size() - 1) {
|
||||
System.out.print(i)
|
||||
print(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
//statement
|
||||
int j = 1;
|
||||
for (int i = 0; i < 10; j++, i++) {
|
||||
System.out.println(i);
|
||||
System.out.println(j);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
var j = 1
|
||||
var i = 0
|
||||
while (i < 10) {
|
||||
System.out.println(i)
|
||||
System.out.println(j)
|
||||
println(i)
|
||||
println(j)
|
||||
j++
|
||||
i++
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
public class A {
|
||||
fun foo(collection: Collection<String>) {
|
||||
for (i in collection.indices.reversed()) {
|
||||
System.out.println(i)
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@ class A {
|
||||
run {
|
||||
var i = 1
|
||||
while (i < 1000) {
|
||||
System.out.println(i)
|
||||
println(i)
|
||||
i *= 2
|
||||
}
|
||||
}
|
||||
|
||||
var i = 1
|
||||
while (i < 2000) {
|
||||
System.out.println(i)
|
||||
println(i)
|
||||
i *= 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ class A {
|
||||
var i = 1
|
||||
var j = 0
|
||||
while (i < 1000) {
|
||||
System.out.println(i)
|
||||
println(i)
|
||||
i *= 2
|
||||
j++
|
||||
}
|
||||
@@ -12,7 +12,7 @@ class A {
|
||||
|
||||
var j = 1
|
||||
while (j < 2000) {
|
||||
System.out.println(j)
|
||||
println(j)
|
||||
j *= 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ class A {
|
||||
run {
|
||||
var i = 1
|
||||
while (i < 1000) {
|
||||
System.out.println(i)
|
||||
println(i)
|
||||
i *= 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ class A {
|
||||
run {
|
||||
var i = 1
|
||||
while (i < 1000) {
|
||||
System.out.println(i)
|
||||
println(i)
|
||||
i *= 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ class A {
|
||||
|
||||
var i = 1
|
||||
while (i < 1000) {
|
||||
System.out.println(i)
|
||||
println(i)
|
||||
i *= 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ class A {
|
||||
if (p) {
|
||||
var i = 1
|
||||
while (i < 1000) {
|
||||
System.out.println(i)
|
||||
println(i)
|
||||
i *= 2
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ class A {
|
||||
|
||||
fun foo() {
|
||||
for (e in list!!) {
|
||||
System.out.println(e)
|
||||
println(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
fun foo() {
|
||||
if (a)
|
||||
System.out.println("a")
|
||||
println("a")
|
||||
else if (b)
|
||||
System.out.println("b")
|
||||
println("b")
|
||||
else
|
||||
System.out.println("else")
|
||||
println("else")
|
||||
|
||||
if (c) {
|
||||
System.out.println("c")
|
||||
println("c")
|
||||
} else if (d) {
|
||||
System.out.println("d")
|
||||
println("d")
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ object FileRead {
|
||||
val br = BufferedReader(InputStreamReader(`in`))
|
||||
val strLine: String
|
||||
while ((strLine = br.readLine()) != null) {
|
||||
System.out.println(strLine)
|
||||
println(strLine)
|
||||
}
|
||||
`in`.close()
|
||||
} catch (e: Exception) {
|
||||
|
||||
@@ -11,15 +11,15 @@ object One {
|
||||
class Test {
|
||||
fun test() {
|
||||
if (One.myContainer.myBoolean)
|
||||
System.out.println("Ok")
|
||||
println("Ok")
|
||||
|
||||
val s = if (One.myContainer.myBoolean) "YES" else "NO"
|
||||
|
||||
while (One.myContainer.myBoolean)
|
||||
System.out.println("Ok")
|
||||
println("Ok")
|
||||
|
||||
do {
|
||||
System.out.println("Ok")
|
||||
println("Ok")
|
||||
} while (One.myContainer.myBoolean)
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,12 @@ class Test {
|
||||
res = res and false
|
||||
res = res or false
|
||||
res = res xor false
|
||||
System.out.println(true and false)
|
||||
System.out.println(true or false)
|
||||
System.out.println(true xor false)
|
||||
System.out.println(!true)
|
||||
println(true and false)
|
||||
println(true or false)
|
||||
println(true xor false)
|
||||
println(!true)
|
||||
|
||||
System.out.println(true && false)
|
||||
System.out.println(true || false)
|
||||
println(true && false)
|
||||
println(true || false)
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package demo
|
||||
|
||||
object Program {
|
||||
public fun main(args: Array<String>) {
|
||||
System.out.println("Halo!")
|
||||
println("Halo!")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package demo
|
||||
class Test {
|
||||
fun test() {
|
||||
for (i in 0..9) {
|
||||
System.out.println(i)
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
class Test {
|
||||
public fun printNumbers(number: Int) {
|
||||
for (i in 2..Math.sqrt(number.toDouble()) + 1 - 1)
|
||||
System.out.println(i)
|
||||
println(i)
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,7 @@ import kotlinApi.*
|
||||
|
||||
class C : KotlinClass() {
|
||||
fun foo() {
|
||||
System.out.println(property)
|
||||
println(property)
|
||||
property = "a"
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import kotlinApi.*
|
||||
|
||||
class C {
|
||||
fun foo(k: KotlinClass) {
|
||||
System.out.println(k.property)
|
||||
println(k.property)
|
||||
k.property = "a"
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import kotlinApi.*
|
||||
|
||||
class C {
|
||||
fun foo(k: KotlinClass) {
|
||||
System.out.println(k.field)
|
||||
println(k.field)
|
||||
k.field = 1
|
||||
}
|
||||
}
|
||||
@@ -10,4 +10,4 @@
|
||||
foundIt = true
|
||||
break@test
|
||||
}
|
||||
System.out.println(if (foundIt) "Found it" else "Didn't find it")
|
||||
println(if (foundIt) "Found it" else "Didn't find it")
|
||||
@@ -6,9 +6,9 @@ class Test {
|
||||
name = name.replaceAll("\\$[0-9]+", "\\$")
|
||||
|
||||
val c = '$'
|
||||
System.out.println(c)
|
||||
println(c)
|
||||
|
||||
val C = '$'
|
||||
System.out.println(C)
|
||||
println(C)
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
class A {
|
||||
fun foo(o: Any) {
|
||||
System.out.println(o.javaClass)
|
||||
System.out.println(javaClass)
|
||||
println(o.javaClass)
|
||||
println(javaClass)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class A {
|
||||
void foo() {
|
||||
System.out.println();
|
||||
System.out.println(1);
|
||||
System.out.println("1");
|
||||
System.out.print("1");
|
||||
System.out.print(1);
|
||||
|
||||
System.err.println();
|
||||
System.err.println(1);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
class A {
|
||||
fun foo() {
|
||||
println()
|
||||
println(1)
|
||||
println("1")
|
||||
print("1")
|
||||
print(1)
|
||||
|
||||
System.err.println()
|
||||
System.err.println(1)
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
object : Runnable {
|
||||
override fun run() {
|
||||
System.out.println("Run")
|
||||
println("Run")
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ class C {
|
||||
|
||||
fun foo() {
|
||||
if (s == null) {
|
||||
System.out.print("null")
|
||||
print("null")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ class C(private val s: String?) {
|
||||
|
||||
fun foo() {
|
||||
if (s != null) {
|
||||
System.out.print("not null")
|
||||
print("not null")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ class C {
|
||||
class D {
|
||||
fun foo(c: C) {
|
||||
if (null == c.s) {
|
||||
System.out.println("null")
|
||||
println("null")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ class C(private val s: String?) {
|
||||
|
||||
init {
|
||||
if (s == null) {
|
||||
System.out.print("null")
|
||||
print("null")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fun foo(s: String?, b: Boolean): Int {
|
||||
if (s == null) System.out.println("null")
|
||||
if (s == null) println("null")
|
||||
if (b) return s!!.length()
|
||||
return 10
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package demo
|
||||
|
||||
class Collection<E>(e: E) {
|
||||
init {
|
||||
System.out.println(e)
|
||||
println(e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,5 +5,5 @@ public fun foo(list: List<String>) {
|
||||
array[i] = i
|
||||
}
|
||||
|
||||
for (s: String in list) System.out.print(s)
|
||||
for (s: String in list) print(s)
|
||||
}
|
||||
@@ -2,16 +2,16 @@ fun foo() {
|
||||
when (a) {
|
||||
1 -> {
|
||||
val x = 1
|
||||
System.out.println(x)
|
||||
println(x)
|
||||
}
|
||||
|
||||
2 -> {
|
||||
val x = 2
|
||||
System.out.println(x)
|
||||
println(x)
|
||||
}
|
||||
|
||||
3 -> {
|
||||
System.out.println(3)
|
||||
println(3)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package demo
|
||||
|
||||
public object SwitchDemo {
|
||||
public fun print(o: Any) {
|
||||
System.out.println(o)
|
||||
println(o)
|
||||
}
|
||||
|
||||
public fun test(i: Int) {
|
||||
@@ -73,7 +73,7 @@ public object SwitchDemo {
|
||||
12 -> monthString = "December"
|
||||
else -> monthString = "Invalid month"
|
||||
}
|
||||
System.out.println(monthString)
|
||||
println(monthString)
|
||||
}
|
||||
|
||||
public fun main(args: Array<String>) {
|
||||
|
||||
@@ -3,11 +3,11 @@ fun foo() {
|
||||
when (take()) {
|
||||
1 -> continue
|
||||
2 -> {
|
||||
System.out.println("2")
|
||||
println("2")
|
||||
return
|
||||
}
|
||||
3 -> break@Loop
|
||||
}
|
||||
System.out.println()
|
||||
println()
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ public object NonDefault {
|
||||
when (value) {
|
||||
|
||||
}
|
||||
System.out.println(valueString)
|
||||
println(valueString)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ public object SwitchDemo {
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 -> monthString = "December"
|
||||
else -> monthString = "Invalid month"
|
||||
}
|
||||
System.out.println(monthString)
|
||||
println(monthString)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,17 +4,17 @@ public object C {
|
||||
1 -> {
|
||||
run {
|
||||
val a = 1
|
||||
System.out.print("1")
|
||||
print("1")
|
||||
}
|
||||
run {
|
||||
val a = 2
|
||||
System.out.print("2")
|
||||
print("2")
|
||||
}
|
||||
}
|
||||
|
||||
2 -> {
|
||||
val a = 2
|
||||
System.out.print("2")
|
||||
print("2")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
fun foo() {
|
||||
when (a) {
|
||||
-> {
|
||||
System.out.println("1")
|
||||
System.out.println("2")
|
||||
println("1")
|
||||
println("2")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public object SwitchDemo {
|
||||
12 -> monthString = "December"
|
||||
else -> monthString = "Invalid month"
|
||||
}
|
||||
System.out.println(monthString)
|
||||
println(monthString)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ public object NonDefault {
|
||||
2 -> valueString = "TWO"
|
||||
3 -> valueString = "THREE"
|
||||
}
|
||||
System.out.println(valueString)
|
||||
println(valueString)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
fun foo(a: Int): Int {
|
||||
when (a) {
|
||||
1 -> {
|
||||
System.out.println("1")
|
||||
println("1")
|
||||
return 1
|
||||
}
|
||||
2 -> {
|
||||
System.out.println("2")
|
||||
println("2")
|
||||
return 2
|
||||
}
|
||||
3 -> {
|
||||
System.out.println("3")
|
||||
println("3")
|
||||
throw RuntimeException()
|
||||
}
|
||||
else -> {
|
||||
System.out.println("default")
|
||||
println("default")
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ public class C {
|
||||
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
||||
// reading something
|
||||
val c = stream.read()
|
||||
System.out.println(c)
|
||||
println(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,6 @@ import java.io.*
|
||||
public class C {
|
||||
throws(javaClass<IOException>())
|
||||
fun foo() {
|
||||
ByteArrayInputStream(ByteArray(10)).use { stream -> System.out.println(stream.read()) }
|
||||
ByteArrayInputStream(ByteArray(10)).use { stream -> println(stream.read()) }
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,10 @@ public class C {
|
||||
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
||||
// reading something
|
||||
val c = stream.read()
|
||||
System.out.println(c)
|
||||
println(c)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
System.out.println(e)
|
||||
println(e)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ public class C {
|
||||
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
||||
// reading something
|
||||
val c = stream.read()
|
||||
System.out.println(c)
|
||||
println(c)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
System.out.println(e)
|
||||
println(e)
|
||||
} finally {
|
||||
System.out.println("Finally!")
|
||||
println("Finally!")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,10 @@ public class C {
|
||||
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
||||
// reading something
|
||||
val c = stream.read()
|
||||
System.out.println(c)
|
||||
println(c)
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
System.out.println(e)
|
||||
println(e)
|
||||
} catch (e: Exception) {
|
||||
System.err.println(e)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ public class C {
|
||||
ByteArrayInputStream(ByteArray(10)).use { stream ->
|
||||
// reading something
|
||||
val c = stream.read()
|
||||
System.out.println(c)
|
||||
println(c)
|
||||
}
|
||||
} finally {
|
||||
// dispose something else
|
||||
|
||||
@@ -9,7 +9,7 @@ public class C {
|
||||
return c
|
||||
}
|
||||
} catch (e: IOException) {
|
||||
System.out.println(e)
|
||||
println(e)
|
||||
return -1
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,6 @@ public class AAA {
|
||||
}
|
||||
|
||||
public fun bar(b: B) {
|
||||
System.out.println(b.YY)
|
||||
println(b.YY)
|
||||
}
|
||||
}
|
||||
@@ -3064,6 +3064,12 @@ public class JavaToKotlinConverterForWebDemoTestGenerated extends AbstractJavaTo
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("systemOut.java")
|
||||
public void testSystemOut() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/methodCallExpression/systemOut.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("vararg1.java")
|
||||
public void testVararg1() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/methodCallExpression/vararg1.java");
|
||||
|
||||
@@ -3064,6 +3064,12 @@ public class JavaToKotlinConverterSingleFileTestGenerated extends AbstractJavaTo
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("systemOut.java")
|
||||
public void testSystemOut() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/methodCallExpression/systemOut.java");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("vararg1.java")
|
||||
public void testVararg1() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("j2k/testData/fileOrElement/methodCallExpression/vararg1.java");
|
||||
|
||||
Reference in New Issue
Block a user