@willbooster/tree-sitter-kotlin 1.5.8 → 1.6.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 +48 -15
- package/package.json +1 -1
- package/src/node-types.json +43 -0
- package/tree-sitter-kotlin.wasm +0 -0
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -68,6 +68,11 @@ module.exports = grammar({
|
|
|
68
68
|
[$.visibility_modifier, $._reserved_identifier],
|
|
69
69
|
[$.member_modifier, $._reserved_identifier],
|
|
70
70
|
|
|
71
|
+
[$.context_parameters, $._reserved_identifier],
|
|
72
|
+
[$.modifiers, $.function_type],
|
|
73
|
+
[$.secondary_constructor, $._reserved_identifier],
|
|
74
|
+
[$.enum_entry, $.modifiers],
|
|
75
|
+
[$.modifiers, $.anonymous_function],
|
|
71
76
|
[$.qualified_identifier],
|
|
72
77
|
[$.constructor_invocation, $._unescaped_annotation],
|
|
73
78
|
[$.nullable_type],
|
|
@@ -385,6 +390,8 @@ module.exports = grammar({
|
|
|
385
390
|
class_member_declaration: ($) =>
|
|
386
391
|
choice($.declaration, $.companion_object, $.anonymous_initializer, $.secondary_constructor),
|
|
387
392
|
|
|
393
|
+
_annotations: ($) => repeat1($.annotation),
|
|
394
|
+
|
|
388
395
|
enum_class_body: ($) =>
|
|
389
396
|
seq(
|
|
390
397
|
'{',
|
|
@@ -393,7 +400,15 @@ module.exports = grammar({
|
|
|
393
400
|
'}'
|
|
394
401
|
),
|
|
395
402
|
|
|
396
|
-
|
|
403
|
+
// Only annotations can modify an enum entry, and with the full modifier list a `context` after an annotation would
|
|
404
|
+
// start a context parameter list instead of naming the entry.
|
|
405
|
+
enum_entry: ($) =>
|
|
406
|
+
seq(
|
|
407
|
+
optional(alias($._annotations, $.modifiers)),
|
|
408
|
+
$._identifier,
|
|
409
|
+
optional($.value_arguments),
|
|
410
|
+
optional($.class_body)
|
|
411
|
+
),
|
|
397
412
|
|
|
398
413
|
value_arguments: ($) => seq('(', optionalCommaSep1($.value_argument), ')'),
|
|
399
414
|
|
|
@@ -421,7 +436,8 @@ module.exports = grammar({
|
|
|
421
436
|
$.visibility_modifier,
|
|
422
437
|
$.inheritance_modifier,
|
|
423
438
|
$.parameter_modifier,
|
|
424
|
-
$.platform_modifier
|
|
439
|
+
$.platform_modifier,
|
|
440
|
+
$.context_parameters
|
|
425
441
|
)
|
|
426
442
|
)
|
|
427
443
|
)
|
|
@@ -481,7 +497,24 @@ module.exports = grammar({
|
|
|
481
497
|
type_projection: ($) => choice(seq(repeat($.variance_modifier), $.type), '*'),
|
|
482
498
|
|
|
483
499
|
function_type: ($) =>
|
|
484
|
-
seq(
|
|
500
|
+
seq(
|
|
501
|
+
optional($.type_modifiers),
|
|
502
|
+
optional($.context_parameters),
|
|
503
|
+
optional(seq($._receiver_type, '.')),
|
|
504
|
+
$.function_type_parameters,
|
|
505
|
+
'->',
|
|
506
|
+
$.type
|
|
507
|
+
),
|
|
508
|
+
|
|
509
|
+
// Context parameters (`context(scope: Scope)`, Kotlin 2.2) and the older context receivers (`context(Scope)`).
|
|
510
|
+
context_parameters: ($) =>
|
|
511
|
+
seq(
|
|
512
|
+
'context',
|
|
513
|
+
'(',
|
|
514
|
+
commaSep1(choice(seq(optional($.parameter_modifiers), $.parameter), $.type)),
|
|
515
|
+
optional(','),
|
|
516
|
+
')'
|
|
517
|
+
),
|
|
485
518
|
|
|
486
519
|
function_type_parameters: ($) => seq('(', optionalCommaSep1(choice($.parameter, $.type)), ')'),
|
|
487
520
|
|
|
@@ -625,6 +658,7 @@ module.exports = grammar({
|
|
|
625
658
|
anonymous_function: ($) =>
|
|
626
659
|
prec.right(
|
|
627
660
|
seq(
|
|
661
|
+
optional($.context_parameters),
|
|
628
662
|
'fun',
|
|
629
663
|
optional(seq($.type, '.')),
|
|
630
664
|
$.function_value_parameters,
|
|
@@ -769,23 +803,21 @@ module.exports = grammar({
|
|
|
769
803
|
)
|
|
770
804
|
),
|
|
771
805
|
|
|
772
|
-
interpolation: ($) =>
|
|
806
|
+
interpolation: ($) => choice(seq('$', $._template_name), seq('${', $.expression, '}')),
|
|
807
|
+
|
|
808
|
+
// Immediate so that it outranks the string content that would otherwise absorb the name. As in Kotlin, `$this`
|
|
809
|
+
// refers to `this`: with the same token precedence as the name pattern, the string token wins a match of equal
|
|
810
|
+
// length (without its `prec(2)`, `$this` lexes as a name again), while a longer name such as `$thisX` still wins.
|
|
811
|
+
_template_name: ($) =>
|
|
773
812
|
choice(
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
seq('${', $.expression, '}')
|
|
813
|
+
alias(token.immediate(prec(2, /[\p{L}_][\p{L}_\p{Nd}]*/u)), $.identifier),
|
|
814
|
+
alias(token.immediate(prec(2, 'this')), $.this_expression)
|
|
777
815
|
),
|
|
778
816
|
|
|
779
817
|
// In a string prefixed with n dollars (Kotlin 2.1), exactly n dollars start an interpolation; the scanner
|
|
780
818
|
// returns them as one token only where they do.
|
|
781
819
|
_multi_dollar_interpolation: ($) =>
|
|
782
|
-
seq(
|
|
783
|
-
$._multi_dollar_interpolation_start,
|
|
784
|
-
choice(
|
|
785
|
-
alias(token.immediate(prec(2, /[\p{L}_][\p{L}_\p{Nd}]*/u)), $.identifier),
|
|
786
|
-
seq(token.immediate('{'), $.expression, '}')
|
|
787
|
-
)
|
|
788
|
-
),
|
|
820
|
+
seq($._multi_dollar_interpolation_start, choice($._template_name, seq(token.immediate('{'), $.expression, '}'))),
|
|
789
821
|
|
|
790
822
|
character_literal: ($) => seq("'", choice(token.immediate(prec(1, /[^'\\\r\n]/)), $.escape_sequence), "'"),
|
|
791
823
|
|
|
@@ -863,7 +895,8 @@ module.exports = grammar({
|
|
|
863
895
|
'set',
|
|
864
896
|
'suspend',
|
|
865
897
|
'tailrec',
|
|
866
|
-
'value'
|
|
898
|
+
'value',
|
|
899
|
+
'context'
|
|
867
900
|
),
|
|
868
901
|
$.identifier
|
|
869
902
|
),
|
package/package.json
CHANGED
package/src/node-types.json
CHANGED
|
@@ -332,6 +332,10 @@
|
|
|
332
332
|
"multiple": true,
|
|
333
333
|
"required": true,
|
|
334
334
|
"types": [
|
|
335
|
+
{
|
|
336
|
+
"type": "context_parameters",
|
|
337
|
+
"named": true
|
|
338
|
+
},
|
|
335
339
|
{
|
|
336
340
|
"type": "function_body",
|
|
337
341
|
"named": true
|
|
@@ -870,6 +874,29 @@
|
|
|
870
874
|
]
|
|
871
875
|
}
|
|
872
876
|
},
|
|
877
|
+
{
|
|
878
|
+
"type": "context_parameters",
|
|
879
|
+
"named": true,
|
|
880
|
+
"fields": {},
|
|
881
|
+
"children": {
|
|
882
|
+
"multiple": true,
|
|
883
|
+
"required": true,
|
|
884
|
+
"types": [
|
|
885
|
+
{
|
|
886
|
+
"type": "parameter",
|
|
887
|
+
"named": true
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
"type": "parameter_modifiers",
|
|
891
|
+
"named": true
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
"type": "type",
|
|
895
|
+
"named": true
|
|
896
|
+
}
|
|
897
|
+
]
|
|
898
|
+
}
|
|
899
|
+
},
|
|
873
900
|
{
|
|
874
901
|
"type": "continue_expression",
|
|
875
902
|
"named": true,
|
|
@@ -1231,6 +1258,10 @@
|
|
|
1231
1258
|
"multiple": true,
|
|
1232
1259
|
"required": true,
|
|
1233
1260
|
"types": [
|
|
1261
|
+
{
|
|
1262
|
+
"type": "context_parameters",
|
|
1263
|
+
"named": true
|
|
1264
|
+
},
|
|
1234
1265
|
{
|
|
1235
1266
|
"type": "function_type_parameters",
|
|
1236
1267
|
"named": true
|
|
@@ -1486,6 +1517,10 @@
|
|
|
1486
1517
|
{
|
|
1487
1518
|
"type": "identifier",
|
|
1488
1519
|
"named": true
|
|
1520
|
+
},
|
|
1521
|
+
{
|
|
1522
|
+
"type": "this_expression",
|
|
1523
|
+
"named": true
|
|
1489
1524
|
}
|
|
1490
1525
|
]
|
|
1491
1526
|
}
|
|
@@ -1594,6 +1629,10 @@
|
|
|
1594
1629
|
"type": "class_modifier",
|
|
1595
1630
|
"named": true
|
|
1596
1631
|
},
|
|
1632
|
+
{
|
|
1633
|
+
"type": "context_parameters",
|
|
1634
|
+
"named": true
|
|
1635
|
+
},
|
|
1597
1636
|
{
|
|
1598
1637
|
"type": "function_modifier",
|
|
1599
1638
|
"named": true
|
|
@@ -2962,6 +3001,10 @@
|
|
|
2962
3001
|
"type": "constructor",
|
|
2963
3002
|
"named": false
|
|
2964
3003
|
},
|
|
3004
|
+
{
|
|
3005
|
+
"type": "context",
|
|
3006
|
+
"named": false
|
|
3007
|
+
},
|
|
2965
3008
|
{
|
|
2966
3009
|
"type": "continue",
|
|
2967
3010
|
"named": false
|
package/tree-sitter-kotlin.wasm
CHANGED
|
Binary file
|