@willbooster/tree-sitter-kotlin 11.0.0 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -25,7 +25,7 @@ the trees that error recovery produces may change; such changes are released as
25
25
 
26
26
  The npm package ships `tree-sitter-kotlin.wasm` for
27
27
  [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter), which runs in Node.js, Bun,
28
- browsers, and Cloudflare Workers. The parser loads only with this runtime, version 15.0.0 or later in the 15.x or 16.x series: the upstream
28
+ browsers, and Cloudflare Workers. The parser loads only with this runtime, version 17.0.1 or later in the 17.x series: the upstream
29
29
  Tree-sitter runtime rejects it.
30
30
 
31
31
  In Node.js and Bun:
@@ -71,10 +71,10 @@ The package also ships the node types in `src/node-types.json`.
71
71
 
72
72
  In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-kotlin) and on
73
73
  [willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
74
- fuzzed with. The parser loads only with this runtime, version 15.0.0 or later in the 15.x or 16.x series:
74
+ fuzzed with. The parser loads only with this runtime, version 17.0.1 or later in the 17.x series:
75
75
 
76
76
  ```sh
77
- cargo add willbooster-tree-sitter@16.0.0 --rename tree-sitter
77
+ cargo add willbooster-tree-sitter@17.0.1 --rename tree-sitter
78
78
  cargo add willbooster-tree-sitter-kotlin --rename tree-sitter-kotlin
79
79
  ```
80
80
 
package/grammar.js CHANGED
@@ -132,9 +132,10 @@ module.exports = grammar({
132
132
  sym('_delegation_end'),
133
133
  // the `)` that ends a call's arguments (see `value_arguments`)
134
134
  sym('_arguments_end'),
135
- // empty: they tell the scanner when a statement list or the member list of a class body opens in braces, and when
136
- // either closes (see `frames` in the scanner)
135
+ // empty: they tell the scanner when a statement list, the entries of a `when`, or the member list of a class body
136
+ // opens in braces, and when any closes (see `frames` in the scanner)
137
137
  sym('_open_statements'),
138
+ sym('_open_entries'),
138
139
  sym('_open_members'),
139
140
  sym('_close_braces'),
140
141
  sym('_top_level_statement_end'),
@@ -153,6 +154,8 @@ module.exports = grammar({
153
154
  sym('_infix_get_identifier'),
154
155
  sym('_import_end'),
155
156
  sym('_import_continue'),
157
+ // never scanned: it tells the scanner that a value may follow `return` (see `return_expression`)
158
+ sym('_return_value_position'),
156
159
  ],
157
160
 
158
161
  inline: ($) => [$._statements, $._identifier, $._control_structure_body, $._non_function_type],
@@ -887,15 +890,7 @@ module.exports = grammar({
887
890
  collection_literal: ($) => seq('[', optionalCommaSep1($.expression), ']'),
888
891
 
889
892
  when_expression: ($) =>
890
- seq(
891
- 'when',
892
- optional($.when_subject),
893
- '{',
894
- sym('_open_statements'),
895
- repeat($.when_entry),
896
- '}',
897
- sym('_close_braces')
898
- ),
893
+ seq('when', optional($.when_subject), '{', sym('_open_entries'), repeat($.when_entry), '}', sym('_close_braces')),
899
894
 
900
895
  when_subject: ($) =>
901
896
  seq('(', optional(seq(repeat($.annotation), 'val', $.variable_declaration, '=')), $.expression, ')'),
@@ -905,8 +900,7 @@ module.exports = grammar({
905
900
  choice(seq(commaSep1(field('condition', $._when_condition)), optional(',')), 'else'),
906
901
  optional(seq('if', field('guard', $.expression))),
907
902
  '->',
908
- field('body', choice($.block, $.statement)),
909
- optional(sym('_semi'))
903
+ choice(seq(field('body', $.block), optional(sym('_semi'))), seq(field('body', $.statement), sym('_semi')))
910
904
  ),
911
905
 
912
906
  _when_condition: ($) => choice($.expression, $.range_test, $.type_test),
@@ -931,7 +925,13 @@ module.exports = grammar({
931
925
  choice(prec(1, seq(sym('_try_continuation_position'), 'finally', $.block)), seq('finally', $.block)),
932
926
 
933
927
  return_expression: ($) =>
934
- prec.right(seq(choice('return', seq('return@', field('label', $.identifier))), optional($.expression))),
928
+ prec.right(
929
+ seq(
930
+ choice('return', seq('return@', field('label', $.identifier))),
931
+ optional(sym('_return_value_position')),
932
+ optional($.expression)
933
+ )
934
+ ),
935
935
 
936
936
  throw_expression: ($) => seq('throw', $.expression),
937
937
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-kotlin",
3
- "version": "11.0.0",
3
+ "version": "13.0.0",
4
4
  "description": "Kotlin grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -49,7 +49,7 @@
49
49
  "@vitest/browser-playwright": "5.0.5",
50
50
  "@willbooster/oxlint-config": "1.4.9",
51
51
  "@willbooster/wb": "23.0.2",
52
- "@willbooster/web-tree-sitter": "16.0.2",
52
+ "@willbooster/web-tree-sitter": "17.0.1",
53
53
  "conventional-changelog-conventionalcommits": "10.4.1",
54
54
  "lefthook": "2.2.2",
55
55
  "oxlint": "1.89.0",
@@ -61,7 +61,7 @@
61
61
  "wrangler": "4.152.0"
62
62
  },
63
63
  "peerDependencies": {
64
- "@willbooster/web-tree-sitter": "^15.0.0 || ^16.0.0"
64
+ "@willbooster/web-tree-sitter": "^17.0.1"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "@willbooster/web-tree-sitter": {
Binary file
package/tree-sitter.json CHANGED
@@ -13,7 +13,7 @@
13
13
  }
14
14
  ],
15
15
  "metadata": {
16
- "version": "11.0.0",
16
+ "version": "13.0.0",
17
17
  "license": "MIT",
18
18
  "description": "Kotlin grammar for tree-sitter",
19
19
  "authors": [