@willbooster/tree-sitter-kotlin 1.5.8 → 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
@@ -769,23 +769,21 @@ module.exports = grammar({
769
769
  )
770
770
  ),
771
771
 
772
- 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: ($) =>
773
778
  choice(
774
- // Immediate so that it outranks the string content that would otherwise absorb the name.
775
- seq('$', alias(token.immediate(prec(2, /[\p{L}_][\p{L}_\p{Nd}]*/u)), $.identifier)),
776
- 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)
777
781
  ),
778
782
 
779
783
  // In a string prefixed with n dollars (Kotlin 2.1), exactly n dollars start an interpolation; the scanner
780
784
  // returns them as one token only where they do.
781
785
  _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
- ),
786
+ seq($._multi_dollar_interpolation_start, choice($._template_name, seq(token.immediate('{'), $.expression, '}'))),
789
787
 
790
788
  character_literal: ($) => seq("'", choice(token.immediate(prec(1, /[^'\\\r\n]/)), $.escape_sequence), "'"),
791
789
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-kotlin",
3
- "version": "1.5.8",
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.8",
16
+ "version": "1.5.9",
17
17
  "license": "MIT",
18
18
  "description": "Kotlin grammar for tree-sitter",
19
19
  "authors": [