@willbooster/tree-sitter-kotlin 22.0.1 → 22.0.3

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
@@ -5,7 +5,7 @@
5
5
  [![Test](https://github.com/WillBooster/tree-sitter-kotlin/actions/workflows/test.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-kotlin/actions/workflows/test.yml)
6
6
  [![Test rust](https://github.com/WillBooster/tree-sitter-kotlin/actions/workflows/test-rust.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-kotlin/actions/workflows/test-rust.yml)
7
7
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
8
- [![wbfy](https://img.shields.io/badge/wbfy-21.3.0-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
8
+ [![wbfy](https://img.shields.io/badge/wbfy-21.13.1-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
9
9
  [![crates.io](https://img.shields.io/crates/v/willbooster-tree-sitter-kotlin.svg)](https://crates.io/crates/willbooster-tree-sitter-kotlin)
10
10
 
11
11
  Kotlin grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
package/grammar.js CHANGED
@@ -155,6 +155,9 @@ 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('_getter_separator'),
159
+ sym('_setter_separator'),
160
+ sym('_accessor_parameters_position'),
158
161
  ],
159
162
 
160
163
  inline: ($) => [$._statements, $._identifier, $._control_structure_body, $._non_function_type],
@@ -281,7 +284,14 @@ module.exports = grammar({
281
284
  optional($.type_constraints),
282
285
  optional(choice(seq('=', $.expression), $.property_delegate)),
283
286
  optional(';'),
284
- optional(choice(seq($.getter, optional($.setter)), seq($.setter, optional($.getter))))
287
+ optional(
288
+ choice(
289
+ seq($.getter, optional($.setter)),
290
+ seq($.setter, optional($.getter)),
291
+ seq(alias($._expression_getter, $.getter), sym('_setter_separator'), $.setter),
292
+ seq(alias($._expression_setter, $.setter), sym('_getter_separator'), $.getter)
293
+ )
294
+ )
285
295
  )
286
296
  ),
287
297
 
@@ -428,33 +438,36 @@ module.exports = grammar({
428
438
  // last operand of an operator (`B by a ?: b { … }`): the scanner ends the expression before it.
429
439
  explicit_delegation: ($) => seq($.type, 'by', $.expression, optional(sym('_delegation_end'))),
430
440
 
431
- getter: ($) =>
432
- prec.right(
433
- seq(optional($.modifiers), 'get', optional(seq('(', ')', optional(seq(':', $.type)), $.function_body)))
434
- ),
441
+ getter: ($) => prec.right(seq(optional($.modifiers), 'get', optional(seq($._getter_parameters, $.function_body)))),
435
442
 
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
- )
443
+ setter: ($) => prec.right(seq(optional($.modifiers), 'set', optional(seq($._setter_parameters, $.function_body)))),
444
+
445
+ _getter_parameters: ($) =>
446
+ seq(optional(sym('_accessor_parameters_position')), '(', ')', optional(seq(':', $.type))),
447
+
448
+ _setter_parameters: ($) =>
449
+ seq(
450
+ optional(sym('_accessor_parameters_position')),
451
+ '(',
452
+ optional($.parameter_modifiers),
453
+ $.identifier,
454
+ optional(seq(':', $.type)),
455
+ optional(seq('=', $.expression)),
456
+ optional(','),
457
+ ')',
458
+ optional(seq(':', $.type))
455
459
  ),
456
460
 
457
- function_body: ($) => choice($.block, seq('=', $.expression)),
461
+ // Kotlin's parseFunctionBody consumes a semicolon after an expression body, but leaves it after a block body.
462
+ _expression_getter: ($) =>
463
+ seq(optional($.modifiers), 'get', $._getter_parameters, alias($._expression_body, $.function_body)),
464
+
465
+ _expression_setter: ($) =>
466
+ seq(optional($.modifiers), 'set', $._setter_parameters, alias($._expression_body, $.function_body)),
467
+
468
+ function_body: ($) => choice($.block, $._expression_body),
469
+
470
+ _expression_body: ($) => seq('=', $.expression),
458
471
 
459
472
  block: ($) => seq('{', sym('_open_statements'), optional($._statements), '}', sym('_close_braces')),
460
473
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-kotlin",
3
- "version": "22.0.1",
3
+ "version": "22.0.3",
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.3.4",
50
+ "@willbooster/wb": "23.4.1",
51
51
  "@willbooster/web-tree-sitter": "23.0.0",
52
52
  "conventional-changelog-conventionalcommits": "10.4.1",
53
53
  "lefthook": "2.2.2",
54
- "oxlint": "1.92.0",
55
- "oxlint-tsgolint": "7.0.2006",
56
- "playwright": "1.65.0",
54
+ "oxlint": "1.93.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.1",
16
+ "version": "22.0.3",
17
17
  "license": "MIT",
18
18
  "description": "Kotlin grammar for tree-sitter",
19
19
  "authors": [