@willbooster/tree-sitter-kotlin 1.7.4 → 2.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/grammar.js CHANGED
@@ -134,6 +134,9 @@ module.exports = grammar({
134
134
  'where',
135
135
  $._separated_member_start,
136
136
  $._unseparated_member_start,
137
+ $._infix_position,
138
+ $._companion_name_position,
139
+ $._try_continuation_position,
137
140
  ],
138
141
 
139
142
  inline: ($) => [$._statements, $._identifier, $._control_structure_body],
@@ -271,7 +274,7 @@ module.exports = grammar({
271
274
  'companion',
272
275
  'object',
273
276
  optional($._unseparated_member_start),
274
- optional(field('name', $.identifier)),
277
+ optional(seq(optional($._companion_name_position), field('name', $.identifier))),
275
278
  optional(seq(':', $.delegation_specifiers)),
276
279
  optional($.class_body)
277
280
  ),
@@ -705,7 +708,8 @@ module.exports = grammar({
705
708
 
706
709
  range_expression: ($) => prec.left(PREC.RANGE, seq($.expression, choice('..', '..<'), $.expression)),
707
710
 
708
- infix_expression: ($) => prec.left(PREC.INFIX, seq($.expression, $.identifier, $.expression)),
711
+ infix_expression: ($) =>
712
+ prec.left(PREC.INFIX, seq($.expression, optional($._infix_position), $.identifier, $.expression)),
709
713
 
710
714
  // Right-associative so that a trailing lambda after arguments belongs to the same call (`f(x) { … }`), as in
711
715
  // Kotlin, instead of calling the result of `f(x)`.
@@ -817,11 +821,19 @@ module.exports = grammar({
817
821
  type_test: ($) => seq(choice('is', alias($._not_is, '!is')), $.type),
818
822
 
819
823
  try_expression: ($) =>
820
- seq('try', $.block, choice(seq(repeat1($.catch_block), optional($.finally_block)), $.finally_block)),
824
+ seq(
825
+ 'try',
826
+ $.block,
827
+ choice(
828
+ seq(repeat1(seq($.catch_block, optional($._try_continuation_position))), optional($.finally_block)),
829
+ $.finally_block
830
+ )
831
+ ),
821
832
 
822
833
  catch_block: ($) => seq('catch', '(', repeat($.annotation), $.identifier, ':', $.type, optional(','), ')', $.block),
823
834
 
824
- finally_block: ($) => seq('finally', $.block),
835
+ finally_block: ($) =>
836
+ choice(prec(1, seq($._try_continuation_position, 'finally', $.block)), seq('finally', $.block)),
825
837
 
826
838
  return_expression: ($) =>
827
839
  prec.right(seq(choice('return', seq('return@', field('label', $.identifier))), optional($.expression))),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-kotlin",
3
- "version": "1.7.4",
3
+ "version": "2.0.0",
4
4
  "description": "Kotlin grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
Binary file
package/tree-sitter.json CHANGED
@@ -13,7 +13,7 @@
13
13
  }
14
14
  ],
15
15
  "metadata": {
16
- "version": "1.7.4",
16
+ "version": "2.0.0",
17
17
  "license": "MIT",
18
18
  "description": "Kotlin grammar for tree-sitter",
19
19
  "authors": [