@willbooster/tree-sitter-kotlin 10.0.1 → 12.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
@@ -106,9 +106,6 @@ module.exports = grammar({
106
106
  externals: () => [
107
107
  sym('_destructuring_type_start'),
108
108
  sym('_semi'),
109
- sym('_class_member_semi'),
110
- // Unlike properties, these declarations can end before another member on the same line.
111
- sym('_same_line_member_end'),
112
109
  sym('block_comment'),
113
110
  // also lexed by the scanner, since the generated lexer stops at a NUL character
114
111
  sym('line_comment'),
@@ -135,9 +132,10 @@ module.exports = grammar({
135
132
  sym('_delegation_end'),
136
133
  // the `)` that ends a call's arguments (see `value_arguments`)
137
134
  sym('_arguments_end'),
138
- // empty: they tell the scanner when a statement list or the member list of a class body opens in braces, and when
139
- // 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)
140
137
  sym('_open_statements'),
138
+ sym('_open_entries'),
141
139
  sym('_open_members'),
142
140
  sym('_close_braces'),
143
141
  sym('_top_level_statement_end'),
@@ -156,6 +154,8 @@ module.exports = grammar({
156
154
  sym('_infix_get_identifier'),
157
155
  sym('_import_end'),
158
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'),
159
159
  ],
160
160
 
161
161
  inline: ($) => [$._statements, $._identifier, $._control_structure_body, $._non_function_type],
@@ -508,8 +508,7 @@ module.exports = grammar({
508
508
  class_body: ($) =>
509
509
  seq('{', sym('_open_members'), repeat($._class_member_with_separator), '}', sym('_close_braces')),
510
510
 
511
- _class_member_with_separator: ($) =>
512
- seq($.class_member_declaration, optional(sym('_same_line_member_end')), sym('_class_member_semi')),
511
+ _class_member_with_separator: ($) => seq($.class_member_declaration, sym('_semi')),
513
512
 
514
513
  class_member_declaration: ($) =>
515
514
  choice($.declaration, $.companion_object, $.anonymous_initializer, $.secondary_constructor),
@@ -891,15 +890,7 @@ module.exports = grammar({
891
890
  collection_literal: ($) => seq('[', optionalCommaSep1($.expression), ']'),
892
891
 
893
892
  when_expression: ($) =>
894
- seq(
895
- 'when',
896
- optional($.when_subject),
897
- '{',
898
- sym('_open_statements'),
899
- repeat($.when_entry),
900
- '}',
901
- sym('_close_braces')
902
- ),
893
+ seq('when', optional($.when_subject), '{', sym('_open_entries'), repeat($.when_entry), '}', sym('_close_braces')),
903
894
 
904
895
  when_subject: ($) =>
905
896
  seq('(', optional(seq(repeat($.annotation), 'val', $.variable_declaration, '=')), $.expression, ')'),
@@ -909,8 +900,7 @@ module.exports = grammar({
909
900
  choice(seq(commaSep1(field('condition', $._when_condition)), optional(',')), 'else'),
910
901
  optional(seq('if', field('guard', $.expression))),
911
902
  '->',
912
- field('body', choice($.block, $.statement)),
913
- optional(sym('_semi'))
903
+ choice(seq(field('body', $.block), optional(sym('_semi'))), seq(field('body', $.statement), sym('_semi')))
914
904
  ),
915
905
 
916
906
  _when_condition: ($) => choice($.expression, $.range_test, $.type_test),
@@ -935,7 +925,13 @@ module.exports = grammar({
935
925
  choice(prec(1, seq(sym('_try_continuation_position'), 'finally', $.block)), seq('finally', $.block)),
936
926
 
937
927
  return_expression: ($) =>
938
- 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
+ ),
939
935
 
940
936
  throw_expression: ($) => seq('throw', $.expression),
941
937
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-kotlin",
3
- "version": "10.0.1",
3
+ "version": "12.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": "10.0.1",
16
+ "version": "12.0.0",
17
17
  "license": "MIT",
18
18
  "description": "Kotlin grammar for tree-sitter",
19
19
  "authors": [