@willbooster/tree-sitter-kotlin 1.5.7 → 1.5.9

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
@@ -82,6 +82,8 @@ module.exports = grammar({
82
82
  $._semi,
83
83
  $._class_member_semi,
84
84
  $.block_comment,
85
+ // also lexed by the scanner, since the generated lexer stops at a NUL character
86
+ $.line_comment,
85
87
  $._not_is,
86
88
  $._in,
87
89
  $._q_dot,
@@ -767,23 +769,21 @@ module.exports = grammar({
767
769
  )
768
770
  ),
769
771
 
770
- interpolation: ($) =>
772
+ interpolation: ($) => choice(seq('$', $._template_name), seq('${', $.expression, '}')),
773
+
774
+ // Immediate so that it outranks the string content that would otherwise absorb the name. As in Kotlin, `$this`
775
+ // refers to `this`: with the same token precedence as the name pattern, the string token wins a match of equal
776
+ // length (without its `prec(2)`, `$this` lexes as a name again), while a longer name such as `$thisX` still wins.
777
+ _template_name: ($) =>
771
778
  choice(
772
- // Immediate so that it outranks the string content that would otherwise absorb the name.
773
- seq('$', alias(token.immediate(prec(2, /[\p{L}_][\p{L}_\p{Nd}]*/u)), $.identifier)),
774
- seq('${', $.expression, '}')
779
+ alias(token.immediate(prec(2, /[\p{L}_][\p{L}_\p{Nd}]*/u)), $.identifier),
780
+ alias(token.immediate(prec(2, 'this')), $.this_expression)
775
781
  ),
776
782
 
777
783
  // In a string prefixed with n dollars (Kotlin 2.1), exactly n dollars start an interpolation; the scanner
778
784
  // returns them as one token only where they do.
779
785
  _multi_dollar_interpolation: ($) =>
780
- seq(
781
- $._multi_dollar_interpolation_start,
782
- choice(
783
- alias(token.immediate(prec(2, /[\p{L}_][\p{L}_\p{Nd}]*/u)), $.identifier),
784
- seq(token.immediate('{'), $.expression, '}')
785
- )
786
- ),
786
+ seq($._multi_dollar_interpolation_start, choice($._template_name, seq(token.immediate('{'), $.expression, '}'))),
787
787
 
788
788
  character_literal: ($) => seq("'", choice(token.immediate(prec(1, /[^'\\\r\n]/)), $.escape_sequence), "'"),
789
789
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-kotlin",
3
- "version": "1.5.7",
3
+ "version": "1.5.9",
4
4
  "description": "Kotlin grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -1486,6 +1486,10 @@
1486
1486
  {
1487
1487
  "type": "identifier",
1488
1488
  "named": true
1489
+ },
1490
+ {
1491
+ "type": "this_expression",
1492
+ "named": true
1489
1493
  }
1490
1494
  ]
1491
1495
  }
Binary file
package/tree-sitter.json CHANGED
@@ -13,7 +13,7 @@
13
13
  }
14
14
  ],
15
15
  "metadata": {
16
- "version": "1.5.7",
16
+ "version": "1.5.9",
17
17
  "license": "MIT",
18
18
  "description": "Kotlin grammar for tree-sitter",
19
19
  "authors": [