@willbooster/tree-sitter-kotlin 1.7.0 → 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 +27 -6
- package/package.json +1 -1
- package/tree-sitter-kotlin.wasm +0 -0
- package/tree-sitter.json +1 -1
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,
|
|
@@ -126,6 +128,9 @@ module.exports = grammar({
|
|
|
126
128
|
$._keyword_reference,
|
|
127
129
|
// never scanned: see `_template_name`
|
|
128
130
|
$._keyword_reference_end,
|
|
131
|
+
'where',
|
|
132
|
+
$._separated_member_start,
|
|
133
|
+
$._unseparated_member_start,
|
|
129
134
|
],
|
|
130
135
|
|
|
131
136
|
inline: ($) => [$._statements, $._identifier, $._control_structure_body],
|
|
@@ -205,7 +210,8 @@ module.exports = grammar({
|
|
|
205
210
|
prec.right(
|
|
206
211
|
seq(
|
|
207
212
|
optional($.modifiers),
|
|
208
|
-
choice('class', seq(optional('fun'), 'interface')),
|
|
213
|
+
choice('class', seq(optional(seq('fun', optional($._unseparated_member_start))), 'interface')),
|
|
214
|
+
optional($._unseparated_member_start),
|
|
209
215
|
field('name', $.identifier),
|
|
210
216
|
optional($.type_parameters),
|
|
211
217
|
optional(seq(optional($._primary_constructor_position), $.primary_constructor)),
|
|
@@ -220,6 +226,7 @@ module.exports = grammar({
|
|
|
220
226
|
seq(
|
|
221
227
|
optional($.modifiers),
|
|
222
228
|
'object',
|
|
229
|
+
optional($._unseparated_member_start),
|
|
223
230
|
field('name', $.identifier),
|
|
224
231
|
optional(seq(':', $.delegation_specifiers)),
|
|
225
232
|
optional($.class_body)
|
|
@@ -231,6 +238,7 @@ module.exports = grammar({
|
|
|
231
238
|
seq(
|
|
232
239
|
optional($.modifiers),
|
|
233
240
|
choice('val', 'var'),
|
|
241
|
+
optional($._separated_member_start),
|
|
234
242
|
optional($.type_parameters),
|
|
235
243
|
optional(seq($._receiver_type, optional('.'))),
|
|
236
244
|
choice($.variable_declaration, $.multi_variable_declaration),
|
|
@@ -243,7 +251,15 @@ module.exports = grammar({
|
|
|
243
251
|
|
|
244
252
|
type_alias: ($) =>
|
|
245
253
|
prec.right(
|
|
246
|
-
seq(
|
|
254
|
+
seq(
|
|
255
|
+
optional($.modifiers),
|
|
256
|
+
'typealias',
|
|
257
|
+
optional($._separated_member_start),
|
|
258
|
+
field('type', $.identifier),
|
|
259
|
+
optional($.type_parameters),
|
|
260
|
+
'=',
|
|
261
|
+
$.type
|
|
262
|
+
)
|
|
247
263
|
),
|
|
248
264
|
|
|
249
265
|
companion_object: ($) =>
|
|
@@ -251,17 +267,19 @@ module.exports = grammar({
|
|
|
251
267
|
optional($.modifiers),
|
|
252
268
|
'companion',
|
|
253
269
|
'object',
|
|
270
|
+
optional($._unseparated_member_start),
|
|
254
271
|
optional(field('name', $.identifier)),
|
|
255
272
|
optional(seq(':', $.delegation_specifiers)),
|
|
256
273
|
optional($.class_body)
|
|
257
274
|
),
|
|
258
275
|
|
|
259
|
-
anonymous_initializer: ($) => seq('init', $.block),
|
|
276
|
+
anonymous_initializer: ($) => seq('init', optional($._unseparated_member_start), $.block),
|
|
260
277
|
|
|
261
278
|
secondary_constructor: ($) =>
|
|
262
279
|
seq(
|
|
263
280
|
optional($.modifiers),
|
|
264
281
|
'constructor',
|
|
282
|
+
optional($._unseparated_member_start),
|
|
265
283
|
$.function_value_parameters,
|
|
266
284
|
optional(seq(':', $.constructor_delegation_call)),
|
|
267
285
|
optional($.block)
|
|
@@ -299,6 +317,7 @@ module.exports = grammar({
|
|
|
299
317
|
seq(
|
|
300
318
|
optional($.modifiers),
|
|
301
319
|
'fun',
|
|
320
|
+
optional($._unseparated_member_start),
|
|
302
321
|
optional($.type_parameters),
|
|
303
322
|
optional(seq($._receiver_type, optional('.'))),
|
|
304
323
|
field('name', $._identifier),
|
|
@@ -405,8 +424,10 @@ module.exports = grammar({
|
|
|
405
424
|
|
|
406
425
|
_loop_prefix: ($) => prec.dynamic(1, repeat1(choice($.annotation, $.label))),
|
|
407
426
|
|
|
408
|
-
class_body: ($) =>
|
|
409
|
-
|
|
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),
|
|
410
431
|
|
|
411
432
|
class_member_declaration: ($) =>
|
|
412
433
|
choice($.declaration, $.companion_object, $.anonymous_initializer, $.secondary_constructor),
|
|
@@ -418,7 +439,7 @@ module.exports = grammar({
|
|
|
418
439
|
'{',
|
|
419
440
|
$._open_members,
|
|
420
441
|
optionalCommaSep1($.enum_entry),
|
|
421
|
-
optional(seq(';', repeat(
|
|
442
|
+
optional(seq(';', repeat($._class_member_with_separator))),
|
|
422
443
|
'}',
|
|
423
444
|
$._close_braces
|
|
424
445
|
),
|
package/package.json
CHANGED
package/tree-sitter-kotlin.wasm
CHANGED
|
Binary file
|