@willbooster/tree-sitter-kotlin 22.0.2 → 22.0.4

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/grammar.js CHANGED
@@ -155,6 +155,10 @@ module.exports = grammar({
155
155
  sym('_return_value_position'),
156
156
  // valid nowhere, so that an unterminated block comment, which runs to the end of the input, is an error
157
157
  sym('_unterminated_block_comment'),
158
+ sym('_initial_accessor_separator'),
159
+ sym('_getter_separator'),
160
+ sym('_setter_separator'),
161
+ sym('_accessor_parameters_position'),
158
162
  ],
159
163
 
160
164
  inline: ($) => [$._statements, $._identifier, $._control_structure_body, $._non_function_type],
@@ -280,8 +284,17 @@ module.exports = grammar({
280
284
  choice($.variable_declaration, $.multi_variable_declaration),
281
285
  optional($.type_constraints),
282
286
  optional(choice(seq('=', $.expression), $.property_delegate)),
283
- optional(';'),
284
- optional(choice(seq($.getter, optional($.setter)), seq($.setter, optional($.getter))))
287
+ optional(
288
+ seq(
289
+ optional(sym('_initial_accessor_separator')),
290
+ choice(
291
+ seq($.getter, optional($.setter)),
292
+ seq($.setter, optional($.getter)),
293
+ seq(alias($._expression_getter, $.getter), sym('_setter_separator'), $.setter),
294
+ seq(alias($._expression_setter, $.setter), sym('_getter_separator'), $.getter)
295
+ )
296
+ )
297
+ )
285
298
  )
286
299
  ),
287
300
 
@@ -428,33 +441,36 @@ module.exports = grammar({
428
441
  // last operand of an operator (`B by a ?: b { … }`): the scanner ends the expression before it.
429
442
  explicit_delegation: ($) => seq($.type, 'by', $.expression, optional(sym('_delegation_end'))),
430
443
 
431
- getter: ($) =>
432
- prec.right(
433
- seq(optional($.modifiers), 'get', optional(seq('(', ')', optional(seq(':', $.type)), $.function_body)))
434
- ),
444
+ getter: ($) => prec.right(seq(optional($.modifiers), 'get', optional(seq($._getter_parameters, $.function_body)))),
435
445
 
436
- setter: ($) =>
437
- prec.right(
438
- seq(
439
- optional($.modifiers),
440
- 'set',
441
- optional(
442
- seq(
443
- '(',
444
- optional($.parameter_modifiers),
445
- $.identifier,
446
- optional(seq(':', $.type)),
447
- optional(seq('=', $.expression)),
448
- optional(','),
449
- ')',
450
- optional(seq(':', $.type)),
451
- $.function_body
452
- )
453
- )
454
- )
446
+ setter: ($) => prec.right(seq(optional($.modifiers), 'set', optional(seq($._setter_parameters, $.function_body)))),
447
+
448
+ _getter_parameters: ($) =>
449
+ seq(optional(sym('_accessor_parameters_position')), '(', ')', optional(seq(':', $.type))),
450
+
451
+ _setter_parameters: ($) =>
452
+ seq(
453
+ optional(sym('_accessor_parameters_position')),
454
+ '(',
455
+ optional($.parameter_modifiers),
456
+ $.identifier,
457
+ optional(seq(':', $.type)),
458
+ optional(seq('=', $.expression)),
459
+ optional(','),
460
+ ')',
461
+ optional(seq(':', $.type))
455
462
  ),
456
463
 
457
- function_body: ($) => choice($.block, seq('=', $.expression)),
464
+ // Kotlin's parseFunctionBody consumes a semicolon after an expression body, but leaves it after a block body.
465
+ _expression_getter: ($) =>
466
+ seq(optional($.modifiers), 'get', $._getter_parameters, alias($._expression_body, $.function_body)),
467
+
468
+ _expression_setter: ($) =>
469
+ seq(optional($.modifiers), 'set', $._setter_parameters, alias($._expression_body, $.function_body)),
470
+
471
+ function_body: ($) => choice($.block, $._expression_body),
472
+
473
+ _expression_body: ($) => seq('=', $.expression),
458
474
 
459
475
  block: ($) => seq('{', sym('_open_statements'), optional($._statements), '}', sym('_close_braces')),
460
476
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-kotlin",
3
- "version": "22.0.2",
3
+ "version": "22.0.4",
4
4
  "description": "Kotlin grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "kotlin",
@@ -43,19 +43,19 @@
43
43
  "verify-full": "bun wb verify --full"
44
44
  },
45
45
  "devDependencies": {
46
- "@tsconfig/bun": "1.0.11",
46
+ "@tsconfig/bun": "1.0.12",
47
47
  "@types/bun": "1.4.4",
48
48
  "@vitest/browser-playwright": "5.1.0",
49
49
  "@willbooster/oxlint-config": "1.4.9",
50
- "@willbooster/wb": "23.4.0",
51
- "@willbooster/web-tree-sitter": "23.0.0",
50
+ "@willbooster/wb": "23.4.3",
51
+ "@willbooster/web-tree-sitter": "23.0.1",
52
52
  "conventional-changelog-conventionalcommits": "10.4.1",
53
53
  "lefthook": "2.2.2",
54
54
  "oxlint": "1.93.0",
55
- "oxlint-tsgolint": "7.0.2006",
56
- "playwright": "1.65.0",
55
+ "oxlint-tsgolint": "7.0.2007",
56
+ "playwright": "1.65.1",
57
57
  "semantic-release": "25.0.9",
58
- "vite": "8.3.7",
58
+ "vite": "8.3.8",
59
59
  "vitest": "5.1.0",
60
60
  "wrangler": "4.156.0"
61
61
  },
Binary file
package/tree-sitter.json CHANGED
@@ -13,7 +13,7 @@
13
13
  }
14
14
  ],
15
15
  "metadata": {
16
- "version": "22.0.2",
16
+ "version": "22.0.4",
17
17
  "license": "MIT",
18
18
  "description": "Kotlin grammar for tree-sitter",
19
19
  "authors": [