Other code review changes
This commit is contained in:
+102
-54
@@ -1,59 +1,107 @@
|
||||
class ControlStructures {
|
||||
val prop = 3
|
||||
|
||||
fun nullFun(): String? = null
|
||||
|
||||
fun test(): Boolean {
|
||||
if (5 > 3) {
|
||||
println("5 > 3")
|
||||
}
|
||||
""
|
||||
// " "
|
||||
// "Z Z"
|
||||
//
|
||||
// val qwe = 2
|
||||
// " $qwe "
|
||||
// "5\n 2"
|
||||
// "\t\t\t"
|
||||
|
||||
for (c in "ABC") {
|
||||
println(c)
|
||||
}
|
||||
|
||||
for (c: Char in "DEF") {
|
||||
println(c.toByte())
|
||||
}
|
||||
|
||||
var i = 5
|
||||
while (i > 0) {
|
||||
i--
|
||||
if (i == 3) break
|
||||
if (i == 2) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
i = 5
|
||||
do {
|
||||
i -= 1
|
||||
} while (i > 0)
|
||||
|
||||
"ABC".forEach { println(it.toString()[0]) }
|
||||
|
||||
"ABC".zip("DEF").forEach { println(it.first + " " + it.second) }
|
||||
|
||||
val (a, b) = "ABC".zip("DEF")
|
||||
|
||||
val value = if (5 > 3) "a" else "b"
|
||||
val list = listOf("A")
|
||||
val list2 = listOf("A")
|
||||
|
||||
val type = when (value) {
|
||||
in list -> "inlist"
|
||||
!in list2 -> "notinlist2"
|
||||
is String -> "string"
|
||||
is CharSequence -> "cs"
|
||||
else -> "unknown"
|
||||
}
|
||||
|
||||
val x = when {
|
||||
value == "b" -> "B"
|
||||
5 % 2 == 0 -> {
|
||||
println("A")
|
||||
"Q"
|
||||
}
|
||||
false -> "!"
|
||||
else -> "A"
|
||||
}
|
||||
|
||||
return false
|
||||
// if (5 > 3) {
|
||||
// println("5 > 3")
|
||||
// }
|
||||
//
|
||||
// for (c in "ABC") {
|
||||
// println(c)
|
||||
// }
|
||||
//
|
||||
// for (c: Char in "DEF") {
|
||||
// println(c.toByte())
|
||||
// }
|
||||
//
|
||||
// var i = 5
|
||||
// while (i > 0) {
|
||||
// i--
|
||||
// if (i == 3) break
|
||||
// if (i == 2) {
|
||||
// continue
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// "" is String
|
||||
// ("" as Any) as String?
|
||||
//
|
||||
// super.equals(this)
|
||||
// this.equals(this)
|
||||
//
|
||||
// this@ControlStructures.equals(this)
|
||||
//
|
||||
// ControlStructures::test
|
||||
// ControlStructures::prop
|
||||
// ControlStructures::class.java
|
||||
//
|
||||
// outer@ for (outerVal in 1..2) {
|
||||
// inner@ for (innerVal in 3..4) {
|
||||
// continue@outer
|
||||
// }
|
||||
// break@outer
|
||||
// }
|
||||
//
|
||||
// nullFun()?.let { println(it) }
|
||||
//
|
||||
// i = 5
|
||||
// do {
|
||||
// i -= 1
|
||||
// } while (i > 0)
|
||||
//
|
||||
// "ABC".forEach { println(it.toString()[0]) }
|
||||
//
|
||||
// "ABC".zip("DEF").forEach { println(it.first + " " + it.second) }
|
||||
//
|
||||
// val arr = arrayOf("A", "B", "C")
|
||||
// println(arr[2])
|
||||
//
|
||||
// val (a, b) = "ABC".zip("DEF")
|
||||
//
|
||||
// val value = if (5 > 3) "a" else "b"
|
||||
// val list = listOf("A")
|
||||
// val list2 = listOf("A")
|
||||
//
|
||||
// val type = when (value) {
|
||||
// in list -> "inlist"
|
||||
// !in list2 -> "notinlist2"
|
||||
// is String -> "string"
|
||||
// is CharSequence -> "cs"
|
||||
// else -> "unknown"
|
||||
// }
|
||||
//
|
||||
// val x = when {
|
||||
// value == "b" -> "B"
|
||||
// 5 % 2 == 0 -> {
|
||||
// println("A")
|
||||
// "Q"
|
||||
// }
|
||||
// false -> "!"
|
||||
// else -> "A"
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// 5 + 1
|
||||
// throw Exception()
|
||||
// } catch (e: Exception) {
|
||||
// e.printStackTrace()
|
||||
// } catch (thr: Throwable) {
|
||||
// System.out.println("error!")
|
||||
// } finally {
|
||||
// System.out.println("finally")
|
||||
// }
|
||||
//
|
||||
// return false
|
||||
}
|
||||
}
|
||||
+13
@@ -1,5 +1,10 @@
|
||||
class Declarations {
|
||||
val a: String = "a"
|
||||
var b: String
|
||||
get() = "A"
|
||||
set(v) { println(v) }
|
||||
val c: String
|
||||
|
||||
class NestedClass {
|
||||
val b: String = "b"
|
||||
}
|
||||
@@ -7,6 +12,14 @@ class Declarations {
|
||||
val c: CharSequence = a
|
||||
}
|
||||
|
||||
companion object {
|
||||
val CONST_VAL = 1
|
||||
}
|
||||
|
||||
companion object A {
|
||||
fun b(): Boolean = true
|
||||
}
|
||||
|
||||
fun func(a: Int, b: String): Int {
|
||||
return (a + 1) * b.length
|
||||
}
|
||||
|
||||
+19
-5
@@ -1,22 +1,36 @@
|
||||
UFile (package = null)
|
||||
UFile (package = )
|
||||
UClass (Declarations, kind = class)
|
||||
UFunction (<init>, kind = CONSTRUCTOR, paramCount = 0)
|
||||
UFunction (<init>, kind = constructor, paramCount = 0)
|
||||
EmptyExpression
|
||||
UVariable (a, kind = member)
|
||||
ULiteralExpression ("a")
|
||||
UVariable (b, kind = member)
|
||||
EmptyExpression
|
||||
UVariable (c, kind = member)
|
||||
EmptyExpression
|
||||
UClass (NestedClass, kind = class)
|
||||
UFunction (<init>, kind = CONSTRUCTOR, paramCount = 0)
|
||||
UFunction (<init>, kind = constructor, paramCount = 0)
|
||||
EmptyExpression
|
||||
UVariable (b, kind = member)
|
||||
ULiteralExpression ("b")
|
||||
UClass (InnerClass, kind = class)
|
||||
UFunction (<init>, kind = CONSTRUCTOR, paramCount = 0)
|
||||
UFunction (<init>, kind = constructor, paramCount = 0)
|
||||
EmptyExpression
|
||||
UVariable (c, kind = member)
|
||||
USimpleReferenceExpression (a)
|
||||
UClass (Companion, kind = companion object)
|
||||
UFunction (<init>, kind = constructor, paramCount = 0)
|
||||
EmptyExpression
|
||||
UVariable (CONST_VAL, kind = member)
|
||||
ULiteralExpression (1)
|
||||
UClass (A, kind = companion object)
|
||||
UFunction (<init>, kind = constructor, paramCount = 0)
|
||||
EmptyExpression
|
||||
UFunction (b, kind = function, paramCount = 0)
|
||||
ULiteralExpression (true)
|
||||
UFunction (func, kind = function, paramCount = 2)
|
||||
UBlockExpression
|
||||
USpecialExpressionList (return)
|
||||
UReturnExpression
|
||||
UBinaryExpression (*)
|
||||
UParenthesizedExpression
|
||||
UBinaryExpression (+)
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
UFile (package = null)
|
||||
UFile (package = )
|
||||
UClass (Simple, kind = class)
|
||||
UFunction (<init>, kind = CONSTRUCTOR, paramCount = 0)
|
||||
UFunction (<init>, kind = constructor, paramCount = 0)
|
||||
EmptyExpression
|
||||
UVariable (a, kind = member)
|
||||
UBinaryExpression (+)
|
||||
|
||||
+27
-4
@@ -1,19 +1,42 @@
|
||||
public static class Declarations {
|
||||
public fun <init>() = EmptyExpression
|
||||
var a: String = "a"
|
||||
|
||||
public immutable var a: String = "a"
|
||||
|
||||
public var b: String
|
||||
public fun <get>(): String = "A"
|
||||
public fun <set>(v: String) {
|
||||
println(v)
|
||||
}
|
||||
|
||||
|
||||
public immutable var c: String
|
||||
|
||||
public static class NestedClass {
|
||||
public fun <init>() = EmptyExpression
|
||||
var b: String = "b"
|
||||
|
||||
public immutable var b: String = "b"
|
||||
}
|
||||
|
||||
public class InnerClass {
|
||||
public fun <init>() = EmptyExpression
|
||||
var c: CharSequence = a
|
||||
|
||||
public immutable var c: CharSequence = a
|
||||
}
|
||||
|
||||
public static companion object Companion {
|
||||
public fun <init>() = EmptyExpression
|
||||
|
||||
public immutable var CONST_VAL: Int = 1
|
||||
}
|
||||
|
||||
public static companion object A {
|
||||
public fun <init>() = EmptyExpression
|
||||
|
||||
public fun b(): Boolean = true
|
||||
}
|
||||
|
||||
public fun func(a: Int, b: String): Int {
|
||||
return (a + 1) * b.length
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
public static class Simple {
|
||||
public fun <init>() = EmptyExpression
|
||||
var a: String = "text" + "other" + "text"
|
||||
public immutable var a: String = "text" + "other" + "text"
|
||||
|
||||
var b: List<String> = listOf("A")
|
||||
public immutable var b: List<String> = listOf("A")
|
||||
|
||||
public fun test(): Unit {
|
||||
System.out.println(5.0f / 2)
|
||||
|
||||
Reference in New Issue
Block a user