@willbooster/tree-sitter-kotlin 1.7.1 → 1.7.2

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
@@ -88,6 +88,8 @@ module.exports = grammar({
88
88
  externals: ($) => [
89
89
  $._semi,
90
90
  $._class_member_semi,
91
+ // Unlike properties, these declarations can end before another member on the same line.
92
+ $._same_line_member_end,
91
93
  $.block_comment,
92
94
  // also lexed by the scanner, since the generated lexer stops at a NUL character
93
95
  $.line_comment,
@@ -127,6 +129,8 @@ module.exports = grammar({
127
129
  // never scanned: see `_template_name`
128
130
  $._keyword_reference_end,
129
131
  'where',
132
+ $._separated_member_start,
133
+ $._unseparated_member_start,
130
134
  ],
131
135
 
132
136
  inline: ($) => [$._statements, $._identifier, $._control_structure_body],
@@ -206,7 +210,8 @@ module.exports = grammar({
206
210
  prec.right(
207
211
  seq(
208
212
  optional($.modifiers),
209
- choice('class', seq(optional('fun'), 'interface')),
213
+ choice('class', seq(optional(seq('fun', optional($._unseparated_member_start))), 'interface')),
214
+ optional($._unseparated_member_start),
210
215
  field('name', $.identifier),
211
216
  optional($.type_parameters),
212
217
  optional(seq(optional($._primary_constructor_position), $.primary_constructor)),
@@ -221,6 +226,7 @@ module.exports = grammar({
221
226
  seq(
222
227
  optional($.modifiers),
223
228
  'object',
229
+ optional($._unseparated_member_start),
224
230
  field('name', $.identifier),
225
231
  optional(seq(':', $.delegation_specifiers)),
226
232
  optional($.class_body)
@@ -232,6 +238,7 @@ module.exports = grammar({
232
238
  seq(
233
239
  optional($.modifiers),
234
240
  choice('val', 'var'),
241
+ optional($._separated_member_start),
235
242
  optional($.type_parameters),
236
243
  optional(seq($._receiver_type, optional('.'))),
237
244
  choice($.variable_declaration, $.multi_variable_declaration),
@@ -244,7 +251,15 @@ module.exports = grammar({
244
251
 
245
252
  type_alias: ($) =>
246
253
  prec.right(
247
- seq(optional($.modifiers), 'typealias', field('type', $.identifier), optional($.type_parameters), '=', $.type)
254
+ seq(
255
+ optional($.modifiers),
256
+ 'typealias',
257
+ optional($._separated_member_start),
258
+ field('type', $.identifier),
259
+ optional($.type_parameters),
260
+ '=',
261
+ $.type
262
+ )
248
263
  ),
249
264
 
250
265
  companion_object: ($) =>
@@ -252,17 +267,19 @@ module.exports = grammar({
252
267
  optional($.modifiers),
253
268
  'companion',
254
269
  'object',
270
+ optional($._unseparated_member_start),
255
271
  optional(field('name', $.identifier)),
256
272
  optional(seq(':', $.delegation_specifiers)),
257
273
  optional($.class_body)
258
274
  ),
259
275
 
260
- anonymous_initializer: ($) => seq('init', $.block),
276
+ anonymous_initializer: ($) => seq('init', optional($._unseparated_member_start), $.block),
261
277
 
262
278
  secondary_constructor: ($) =>
263
279
  seq(
264
280
  optional($.modifiers),
265
281
  'constructor',
282
+ optional($._unseparated_member_start),
266
283
  $.function_value_parameters,
267
284
  optional(seq(':', $.constructor_delegation_call)),
268
285
  optional($.block)
@@ -300,6 +317,7 @@ module.exports = grammar({
300
317
  seq(
301
318
  optional($.modifiers),
302
319
  'fun',
320
+ optional($._unseparated_member_start),
303
321
  optional($.type_parameters),
304
322
  optional(seq($._receiver_type, optional('.'))),
305
323
  field('name', $._identifier),
@@ -406,8 +424,10 @@ module.exports = grammar({
406
424
 
407
425
  _loop_prefix: ($) => prec.dynamic(1, repeat1(choice($.annotation, $.label))),
408
426
 
409
- class_body: ($) =>
410
- seq('{', $._open_members, repeat(seq($.class_member_declaration, $._class_member_semi)), '}', $._close_braces),
427
+ class_body: ($) => seq('{', $._open_members, repeat($._class_member_with_separator), '}', $._close_braces),
428
+
429
+ _class_member_with_separator: ($) =>
430
+ seq($.class_member_declaration, optional($._same_line_member_end), $._class_member_semi),
411
431
 
412
432
  class_member_declaration: ($) =>
413
433
  choice($.declaration, $.companion_object, $.anonymous_initializer, $.secondary_constructor),
@@ -419,7 +439,7 @@ module.exports = grammar({
419
439
  '{',
420
440
  $._open_members,
421
441
  optionalCommaSep1($.enum_entry),
422
- optional(seq(';', repeat(seq($.class_member_declaration, $._class_member_semi)))),
442
+ optional(seq(';', repeat($._class_member_with_separator))),
423
443
  '}',
424
444
  $._close_braces
425
445
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-kotlin",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
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.1",
16
+ "version": "1.7.2",
17
17
  "license": "MIT",
18
18
  "description": "Kotlin grammar for tree-sitter",
19
19
  "authors": [