Skip to content

Commit 1a1a7c5

Browse files
reberflalewis6991
authored andcommitted
feat(kotlin): added kotlin support
fix failing tests delete trailing blank lines
1 parent b5ef8e3 commit 1a1a7c5

File tree

3 files changed

+113
-1
lines changed

3 files changed

+113
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Note: support for specific languages is strictly community maintained and can br
6060
- [x] `jsonnet`
6161
- [x] `julia`
6262
- [x] `kdl`
63+
- [x] `kotlin`
6364
- [x] `latex`
6465
- [x] `liquidsoap`
6566
- [x] `lua`
@@ -222,7 +223,6 @@ Note: support for specific languages is strictly community maintained and can br
222223
- [ ] `just`
223224
- [ ] `kcl`
224225
- [ ] `kconfig`
225-
- [ ] `kotlin`
226226
- [ ] `koto`
227227
- [ ] `kusto`
228228
- [ ] `lalrpop`

queries/kotlin/context.scm

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
(class_declaration
2+
(class_body (_)) @context.end
3+
) @context
4+
5+
(function_declaration
6+
(function_body (_) @context.end )
7+
) @context
8+
9+
(if_expression
10+
condition: (_)
11+
consequence: (_) @context.end
12+
) @context
13+
14+
(if_expression
15+
alternative: (_) @context.end
16+
) @context
17+
18+
(when_expression) @context
19+
20+
(when_entry) @context
21+
22+
(while_statement
23+
(control_structure_body (_)) @context.end
24+
) @context
25+
26+
(for_statement
27+
(control_structure_body (_)) @context.end
28+
) @context
29+
30+
(try_expression
31+
(statements (_))
32+
) @context

test/lang/test.kt

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// {{TEST}}
2+
3+
4+
class Main(){ // {{CONTEXT}}
5+
6+
7+
8+
9+
// {{CURSOR}}
10+
11+
}
12+
13+
// {{TEST}}
14+
15+
@Test // {{CONTEXT}}
16+
fun main(a: Int){ // {{CONTEXT}}
17+
18+
19+
20+
21+
// {{CURSOR}}
22+
23+
if (a == 1) { // {{CONTEXT}}
24+
25+
26+
27+
28+
// {{CURSOR}}
29+
30+
} else if (a == 2){ // {{CONTEXT}}
31+
32+
33+
34+
35+
// {{CURSOR}}
36+
37+
for (i in 0..a){ // {{CONTEXT}}
38+
39+
40+
41+
42+
// {{CURSOR}}
43+
44+
while( true ){ // {{CONTEXT}}
45+
46+
47+
48+
49+
// {{CURSOR}}
50+
51+
}
52+
}
53+
}
54+
}
55+
56+
// {{TEST}}
57+
fun main(a: Int){ // {{CONTEXT}}
58+
try{ // {{CONTEXT}}
59+
60+
61+
62+
63+
64+
// {{CURSOR}}
65+
66+
when (a){ // {{CONTEXT}}
67+
1 -> { // {{CONTEXT}}
68+
69+
70+
71+
72+
73+
// {{CURSOR}}
74+
}
75+
76+
}
77+
} catch (e: Exception) {
78+
79+
}
80+
}

0 commit comments

Comments
 (0)