@willbooster/tree-sitter-kotlin 1.4.2 → 1.5.1

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
@@ -86,6 +86,11 @@ module.exports = grammar({
86
86
  $._in,
87
87
  $._q_dot,
88
88
  $._multiline_string_content,
89
+ $._multi_dollar_string_start,
90
+ $._multi_dollar_multiline_string_start,
91
+ $._multi_dollar_string_content,
92
+ $._multi_dollar_interpolation_start,
93
+ $._multi_dollar_string_end,
89
94
  // used to check if a preceding annoation should not have an automatic _semi inserted
90
95
  'constructor',
91
96
  'get',
@@ -683,26 +688,51 @@ module.exports = grammar({
683
688
  object_literal: ($) => seq('object', optional(seq(':', $.delegation_specifiers)), $.class_body),
684
689
 
685
690
  string_literal: ($) =>
686
- seq(
687
- '"',
688
- repeat(
689
- choice(
690
- alias(
691
- choice(token.immediate(prec(2, seq('\\', /[^bnrt'"\\$]/))), token.immediate(prec(1, /[^"\\$]+/)), '$'),
692
- $.string_content
693
- ),
694
- $.escape_sequence,
695
- $.interpolation
696
- )
691
+ choice(
692
+ seq(
693
+ '"',
694
+ repeat(
695
+ choice(
696
+ alias(
697
+ choice(token.immediate(prec(2, seq('\\', /[^bnrt'"\\$]/))), token.immediate(prec(1, /[^"\\$]+/)), '$'),
698
+ $.string_content
699
+ ),
700
+ $.escape_sequence,
701
+ $.interpolation
702
+ )
703
+ ),
704
+ '"'
697
705
  ),
698
- '"'
706
+ seq(
707
+ $._multi_dollar_string_start,
708
+ repeat(
709
+ choice(
710
+ alias($._multi_dollar_string_content, $.string_content),
711
+ $.escape_sequence,
712
+ alias($._multi_dollar_interpolation, $.interpolation)
713
+ )
714
+ ),
715
+ $._multi_dollar_string_end
716
+ )
699
717
  ),
700
718
 
701
719
  multiline_string_literal: ($) =>
702
- seq(
703
- '"""',
704
- repeat(choice(alias($._multiline_string_content, $.string_content), $.interpolation)),
705
- choice('"""', '""""')
720
+ choice(
721
+ seq(
722
+ '"""',
723
+ repeat(choice(alias($._multiline_string_content, $.string_content), $.interpolation)),
724
+ choice('"""', '""""')
725
+ ),
726
+ seq(
727
+ $._multi_dollar_multiline_string_start,
728
+ repeat(
729
+ choice(
730
+ alias($._multi_dollar_string_content, $.string_content),
731
+ alias($._multi_dollar_interpolation, $.interpolation)
732
+ )
733
+ ),
734
+ $._multi_dollar_string_end
735
+ )
706
736
  ),
707
737
 
708
738
  interpolation: ($) =>
@@ -712,6 +742,17 @@ module.exports = grammar({
712
742
  seq('${', $.expression, '}')
713
743
  ),
714
744
 
745
+ // In a string prefixed with n dollars (Kotlin 2.1), exactly n dollars start an interpolation; the scanner
746
+ // returns them as one token only where they do.
747
+ _multi_dollar_interpolation: ($) =>
748
+ seq(
749
+ $._multi_dollar_interpolation_start,
750
+ choice(
751
+ alias(token.immediate(prec(2, /[\p{L}_][\p{L}_\p{Nd}]*/u)), $.identifier),
752
+ seq(token.immediate('{'), $.expression, '}')
753
+ )
754
+ ),
755
+
715
756
  character_literal: ($) => seq("'", choice(token.immediate(prec(1, /[^'\\\r\n]/)), $.escape_sequence), "'"),
716
757
 
717
758
  escape_sequence: () => token.immediate(prec(1, seq('\\', choice(/[^xu0-7]/, /u[0-9a-fA-F]{4}/)))),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-kotlin",
3
- "version": "1.4.2",
3
+ "version": "1.5.1",
4
4
  "description": "Kotlin grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -22,13 +22,13 @@
22
22
  ],
23
23
  "scripts": {
24
24
  "build-wasm": "tree-sitter build --wasm",
25
- "build/ci": "tree-sitter generate && tree-sitter build --wasm",
25
+ "build/ci": "tree-sitter generate && script/generate-letter-ranges && tree-sitter build --wasm",
26
26
  "cleanup": "bun wb lint --fix --format",
27
27
  "format": "bun wb lint --format",
28
28
  "lint": "bun wb lint",
29
29
  "lint-fix": "bun wb lint --fix",
30
30
  "prepare": "(bun lefthook install || true) && (test ! -f .lefthook/normalize-bun-lockfile.sh || bash .lefthook/normalize-bun-lockfile.sh)",
31
- "release": "wb release",
31
+ "release": "node script/release.mjs",
32
32
  "prestart": "bun run build-wasm",
33
33
  "start": "tree-sitter playground",
34
34
  "test": "bun wb test",
@@ -46,7 +46,7 @@
46
46
  "@willbooster/oxfmt-config": "1.2.2",
47
47
  "@willbooster/oxlint-config": "1.4.8",
48
48
  "@willbooster/wb": "22.11.5",
49
- "@willbooster/web-tree-sitter": "1.0.0",
49
+ "@willbooster/web-tree-sitter": "1.0.7",
50
50
  "conventional-changelog-conventionalcommits": "10.4.0",
51
51
  "lefthook": "2.1.14",
52
52
  "oxfmt": "0.70.0",
Binary file
package/tree-sitter.json CHANGED
@@ -13,7 +13,7 @@
13
13
  }
14
14
  ],
15
15
  "metadata": {
16
- "version": "1.4.2",
16
+ "version": "1.5.1",
17
17
  "license": "MIT",
18
18
  "description": "Kotlin grammar for tree-sitter",
19
19
  "authors": [