@willbooster/tree-sitter-kotlin 1.6.4 → 1.6.6

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/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Test](https://github.com/WillBooster/tree-sitter-kotlin/actions/workflows/test.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-kotlin/actions/workflows/test.yml)
6
6
  [![Test rust](https://github.com/WillBooster/tree-sitter-kotlin/actions/workflows/test-rust.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-kotlin/actions/workflows/test-rust.yml)
7
7
  [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
8
- [![wbfy](https://img.shields.io/badge/wbfy-20.26.0-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
8
+ [![wbfy](https://img.shields.io/badge/wbfy-20.28.7-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
9
9
  [![crates.io](https://img.shields.io/crates/v/willbooster-tree-sitter-kotlin.svg)](https://crates.io/crates/willbooster-tree-sitter-kotlin)
10
10
 
11
11
  Kotlin grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
@@ -88,28 +88,35 @@ script/parse-examples
88
88
  cargo test
89
89
  ```
90
90
 
91
+ Every `tree-sitter` command, from `generate` to the tests, runs the CLI of the WillBooster/tree-sitter runtime version
92
+ locked in `Cargo.lock` (`script/tree-sitter`), whose generator and runtime have fixes that the upstream CLI lacks.
93
+ `script/fork-cli` downloads that CLI into `.tmp/` from its GitHub Release on first use, or builds it with `cargo` when
94
+ the download fails or the release has no binary that runs here.
95
+
91
96
  `bun run test` runs:
92
97
 
93
98
  - the corpus in `test/corpus`, with the native build and with the Wasm build (the first run downloads the WASI SDK);
94
- - an incremental-parsing check (`test/unit/incremental.test.ts`): `tree-sitter fuzz` edits each corpus case at random,
95
- reparses it, undoes the edits, and reparses again. `TREE_SITTER_SEED`, `TREE_SITTER_ITERATIONS`, and
96
- `TREE_SITTER_EDITS` run other or more edits;
99
+ - an incremental-parsing check (`test/unit/incremental.test.ts`): `script/fuzz-corpus` runs `tree-sitter fuzz`, which
100
+ edits each corpus case at random, reparses it, undoes the edits, and reparses again. `TREE_SITTER_SEED`,
101
+ `TREE_SITTER_ITERATIONS`, and `TREE_SITTER_EDITS` run other or more edits;
97
102
  - a check that real-world Kotlin files cloned into `examples/` fail to parse exactly as listed in
98
103
  `script/known-failures.txt`. The first run clones them. The example repositories are pinned to commits in
99
104
  `script/parse-examples`. After a grammar change or a moved pin alters that list, `script/parse-examples` rewrites
100
105
  it; review its diff before committing;
101
106
  - a performance check (`test/unit/performance.test.ts`) that recovering from an error on each line takes linear time
102
- (ten times the lines take about ten times the CPU time, under a ceiling), since consumers parse files while they are being edited.
103
- It loads the Wasm build through @willbooster/web-tree-sitter, which `bun run build/ci` rebuilds after regenerating
104
- the parser;
105
- - a check that comments containing NUL characters parse (`test/unit/nulCharacters.test.ts`);
107
+ (ten times the lines take about ten times the CPU time, under a ceiling), since consumers parse files while they are
108
+ being edited. It loads the Wasm build through @willbooster/web-tree-sitter, which `bun run build/ci` rebuilds after
109
+ regenerating the parser;
110
+ - a check that comments, strings, escapes, string templates, character literals, and shebang lines containing NUL
111
+ characters parse (`test/unit/nulCharacters.test.ts`);
106
112
  - a check that `package.json` and `Cargo.lock` test the same runtime version (`test/unit/runtimeVersion.test.ts`);
107
113
  - checks that the Wasm build parses Kotlin through @willbooster/web-tree-sitter in Chromium
108
114
  (`test/unit/browser.test.ts`) and in Cloudflare Workers with and without Node.js compatibility
109
115
  (`test/unit/workers.test.ts`).
110
116
 
111
117
  The tests and `script/parse-examples` compile the parser into `.tmp/tree-sitter-lib` rather than the CLI's cache shared
112
- by every checkout.
118
+ by every checkout, and `mise.toml` sets `TREE_SITTER_LIBDIR` to it for any other command run in the checkout;
119
+ `script/fuzz-corpus` builds a parser of its own in `.tmp/fuzz` for each run and deletes it afterwards.
113
120
 
114
121
  CI also runs these tests on Linux arm64 and macOS, where the Rust binding compiles the parser natively, and fuzzes the
115
122
  parser with libFuzzer and sanitizers (`.github/workflows/robustness.yml`).
package/grammar.js CHANGED
@@ -121,6 +121,10 @@ module.exports = grammar({
121
121
  $._top_level_statement_end,
122
122
  // empty: it ends a context list of types among modifiers, except directly in a statement list (see `modifiers`)
123
123
  $._context_end,
124
+ // a hard keyword other than `this` right after the `$` of a string template (see `_template_name`)
125
+ $._keyword_reference,
126
+ // never scanned: see `_template_name`
127
+ $._keyword_reference_end,
124
128
  ],
125
129
 
126
130
  inline: ($) => [$._statements, $._identifier, $._control_structure_body],
@@ -861,7 +865,11 @@ module.exports = grammar({
861
865
  _template_name: ($) =>
862
866
  choice(
863
867
  alias(token.immediate(prec(2, /[\p{L}_][\p{L}_\p{Nd}]*/u)), $.identifier),
864
- alias(token.immediate(prec(2, 'this')), $.this_expression)
868
+ alias(token.immediate(prec(2, 'this')), $.this_expression),
869
+ // As in Kotlin, another hard keyword after `$` is an error: the scanner lexes it, and the grammar then expects
870
+ // `_keyword_reference_end`, which is never scanned. The first alias keeps a name required in `interpolation`; the
871
+ // second makes the end visible when error recovery inserts it as missing, which a hidden token would not be.
872
+ seq(alias($._keyword_reference, $.identifier), alias($._keyword_reference_end, 'keyword_reference_end'))
865
873
  ),
866
874
 
867
875
  // In a string prefixed with n dollars (Kotlin 2.1), exactly n dollars start an interpolation; the scanner
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-kotlin",
3
- "version": "1.6.4",
3
+ "version": "1.6.6",
4
4
  "description": "Kotlin grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -21,8 +21,8 @@
21
21
  "*.wasm"
22
22
  ],
23
23
  "scripts": {
24
- "build-wasm": "tree-sitter build --wasm",
25
- "build/ci": "tree-sitter generate && script/generate-letter-ranges && tree-sitter build --wasm",
24
+ "build-wasm": "script/tree-sitter build --wasm",
25
+ "build/ci": "script/tree-sitter generate && script/generate-letter-ranges && script/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",
@@ -30,7 +30,7 @@
30
30
  "prepare": "(bun lefthook install || true) && (test ! -f .lefthook/normalize-bun-lockfile.sh || bash .lefthook/normalize-bun-lockfile.sh)",
31
31
  "release": "wb release",
32
32
  "prestart": "bun run build-wasm",
33
- "start": "tree-sitter playground",
33
+ "start": "script/tree-sitter playground",
34
34
  "test": "bun wb test",
35
35
  "test/ci": "bun wb test-on-ci",
36
36
  "test/ci-setup": "playwright install --with-deps chromium",
@@ -45,12 +45,12 @@
45
45
  "@willbooster/oxfmt-config": "1.2.2",
46
46
  "@willbooster/oxlint-config": "1.4.8",
47
47
  "@willbooster/wb": "22.13.1",
48
- "@willbooster/web-tree-sitter": "1.0.8",
48
+ "@willbooster/web-tree-sitter": "1.0.16",
49
49
  "conventional-changelog-conventionalcommits": "10.4.0",
50
50
  "lefthook": "2.1.14",
51
51
  "oxfmt": "0.70.0",
52
52
  "oxlint": "1.85.0",
53
- "oxlint-tsgolint": "7.0.2002",
53
+ "oxlint-tsgolint": "7.0.2003",
54
54
  "playwright": "1.63.0",
55
55
  "semantic-release": "25.0.9",
56
56
  "sort-package-json": "4.0.0",
@@ -3129,6 +3129,10 @@
3129
3129
  "type": "is",
3130
3130
  "named": false
3131
3131
  },
3132
+ {
3133
+ "type": "keyword_reference_end",
3134
+ "named": false
3135
+ },
3132
3136
  {
3133
3137
  "type": "label",
3134
3138
  "named": true
Binary file
package/tree-sitter.json CHANGED
@@ -13,7 +13,7 @@
13
13
  }
14
14
  ],
15
15
  "metadata": {
16
- "version": "1.6.4",
16
+ "version": "1.6.6",
17
17
  "license": "MIT",
18
18
  "description": "Kotlin grammar for tree-sitter",
19
19
  "authors": [