PluginProbe
Code Block Pro – Beautiful Syntax Highlighting / 1.27.2
Code Block Pro – Beautiful Syntax Highlighting v1.27.2
1.27.1 1.27.2 1.27.3 1.27.4 1.27.5 1.27.6 1.27.7 1.28.0 1.3.0 1.4.0 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.8.0 1.9.0 1.9.1 1.9.2 1.9.3 trunk 1.1.0 1.10.0 1.11.0 1.11.1 All 63 releases
code-block-pro / build / shiki / samples / kotlin.sample

kotlin.sample in Code Block Pro – Beautiful Syntax Highlighting 1.27.2, at build/shiki/samples/kotlin.sample

149 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 package com.example.kotlin
2
3 import java.util.Random as Rand
4 import android.support.v7.app.AppCompatActivity
5 import org.amshove.kluent.`should equal` as Type
6
7 fun main(@NonNull args: Array<String>) {
8 println("Hello Kotlin! ${/*test*/}")
9
10 val map = mutableMapOf("A" to "B")
11
12 thing.apply("random string here \n\t\r")
13 thing.let { test: -> }
14
15 val string = "${getThing()}"
16 }
17
18 val items = listOf("apple", "banana", "kiwifruit")
19 var x = 9
20 const val CONSTANT = 99
21
22 @get:Rule
23 val activityRule = ActivityTestRule(SplashActivity::class.java)
24
25 val oneMillion = 1_000_000
26 val creditCardNumber = 1234_5678_9012_3456L
27 val socialSecurityNumber = 999_99_9999L
28 val hexBytes = 0xFF_EC_DE_5E
29 val float = 0.043_331F
30 val bytes = 0b11010010_01101001_10010100_10010010
31
32 if(test == "") {
33 1 and 2 not 3
34 } else {
35
36 }
37
38 fun <T> foo() {
39 val x = Bar::class
40 val y = hello?.test
41 }
42
43 suspend fun <T, U> SequenceBuilder<Int>.yieldIfOdd(x: Int) {
44 if (x % 2 != 0) yield(x)
45 }
46
47 val function = fun(@Inject x: Int, y: Int, lamda: (A, B) -> Unit): Int {
48 test.test()
49 return x + y;
50 }
51
52 abstract fun onCreate(savedInstanceState: Bundle?)
53
54 fun isOdd(x: Int) = x % 2 != 0
55 fun isOdd(s: String) = s == "brillig" || s == "slithy" || s == "tove"
56
57 val numbers = listOf(1, 2, 3)
58 println(numbers.filter(::isOdd))
59
60 fun foo(node: Node?): String? {
61 val parent = node.getParent() ?: return null
62 }
63
64 interface Greetable {
65 fun greet()
66 }
67
68 open class Greeter: Greetable {
69 companion object {
70 private const val GREETING = "Hello, World!"
71 }
72
73 override fun greet() {
74 println(GREETING)
75 }
76 }
77
78 expect class Foo(bar: String) {
79 fun frob()
80 }
81
82 actual class Foo actual constructor(val bar: String) {
83 actual fun frob() {
84 println("Frobbing the $bar")
85 }
86 }
87
88 expect fun formatString(source: String, vararg args: Any): String
89 expect annotation class Test
90
91 actual fun formatString(source: String, vararg args: Any) = String.format(source, args)
92 actual typealias Test = org.junit.Test
93
94 sealed class Expr
95 data class Const(val number: Double) : Expr()
96 data class Sum(val e1: Expr, val e2: Expr) : Expr()
97 object NotANumber : Expr()
98
99 @file:JvmName("Foo")
100 private sealed class InjectedClass<T, U> @Inject constructor(
101 val test: Int = 50,
102 var anotherVar: String = "hello world"
103 ) : SomeSuperClass(test, anotherVar) {
104
105 init {
106 //
107 }
108
109 constructor(param1: String, param2: Int): this(param1, param2) {
110 //
111 }
112
113 companion object {
114 //
115 }
116 }
117 annotation class Suspendable
118 val f = @Suspendable { Fiber.sleep(10) }
119
120
121 private data class Foo(
122 /**
123 * ```
124 * ($)
125 * ```
126 */
127 val variables: Map<String, String>
128 )
129
130 data class Response(@SerializedName("param1") val param1: String,
131 @SerializedName("param2") val param2: String,
132 @SerializedName("param3") val param3: String) {
133 }
134
135 object DefaultListener : MouseAdapter() {
136 override fun mouseClicked(e: MouseEvent) { }
137
138 override fun mouseEntered(e: MouseEvent) { }
139 }
140
141 class Feature : Node("Title", "Content", "Description") {
142
143 }
144
145 class Outer {
146 inner class Inner {}
147 }
148
149 // From: https://github.com/nishtahir/language-kotlin/blob/master/snapshots/corpus.kt