| 1 |
package example |
| 2 |
|
| 3 |
class Example(private val value: Int) { |
| 4 |
fun compute(a: Int, b: Int): Int { |
| 5 |
val numbers = listOf( |
| 6 |
1, |
| 7 |
2, |
| 8 |
3, |
| 9 |
) |
| 10 |
for (n in numbers) { |
| 11 |
println(n) |
| 12 |
} |
| 13 |
val result = when (b) { |
| 14 |
1 -> a |
| 15 |
2 -> b |
| 16 |
else -> 0 |
| 17 |
} |
| 18 |
// Known limitation (documented, not checked): else / catch / finally |
| 19 |
// bodies over-indent by one level because the block begins on a different |
| 20 |
// line than the enclosing if / try, so the two indents do not collapse. |
| 21 |
// The brace-less if-body additionally has no public grammar node to indent |
| 22 |
// against, so this needs a grammar change rather than a query fix. The |
| 23 |
// cases are left here, commented out, to document the edge. |
| 24 |
// if (a > b) { |
| 25 |
// println("gt") |
| 26 |
// } else { |
| 27 |
// println("le") |
| 28 |
// } |
| 29 |
// try { |
| 30 |
// return result |
| 31 |
// } catch (e: Exception) { |
| 32 |
// return 0 |
| 33 |
// } finally { |
| 34 |
// println("done") |
| 35 |
// } |
| 36 |
return result |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
val multi = """ |
| 41 |
unindented |
| 42 |
indented |
| 43 |
""" |