@willbooster/tree-sitter-go 1.0.0 → 2.1.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/README.md CHANGED
@@ -1,23 +1,26 @@
1
1
  # @willbooster/tree-sitter-go
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@willbooster/tree-sitter-go.svg)](https://www.npmjs.com/package/@willbooster/tree-sitter-go)
4
+ [![license](https://img.shields.io/npm/l/@willbooster/tree-sitter-go.svg)](https://www.npmjs.com/package/@willbooster/tree-sitter-go)
3
5
  [![Test](https://github.com/WillBooster/tree-sitter-go/actions/workflows/test.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-go/actions/workflows/test.yml)
4
6
  [![Test rust](https://github.com/WillBooster/tree-sitter-go/actions/workflows/test-rust.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-go/actions/workflows/test-rust.yml)
5
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)
6
- [![wbfy](https://img.shields.io/badge/wbfy-20.36.6-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
8
+ [![wbfy](https://img.shields.io/badge/wbfy-20.36.11-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
7
9
  [![crates.io](https://img.shields.io/crates/v/willbooster-tree-sitter-go.svg)](https://crates.io/crates/willbooster-tree-sitter-go)
8
10
 
9
11
  Go grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
10
12
  [tree-sitter/tree-sitter-go](https://github.com/tree-sitter/tree-sitter-go). We are grateful
11
13
  to its authors and contributors. This is not an official release of that project.
12
14
 
13
- This fork keeps the grammar of upstream's version 0.25.0 and generates the parser with the
14
- [WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter) generator at ABI 16, whose compact parse tables
15
- need that fork's runtime.
15
+ This fork extends upstream's version 0.25.0 grammar with method type parameters and generates the parser with the
16
+ [WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter) generator. The parser carries that fork's own ABI
17
+ number (`0x57420001`), so it loads only with the WillBooster runtime, version 2.0.0 or later
18
+ (`willbooster-tree-sitter`, `@willbooster/web-tree-sitter`), and not with upstream's tree-sitter.
16
19
 
17
20
  ## Usage
18
21
 
19
22
  The npm package ships `tree-sitter-go.wasm` for
20
- [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version 1.4.3 or later, which runs in Node.js, Bun, browsers, and Cloudflare Workers. In Node.js and Bun, load the grammar from its path:
23
+ [@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version 2.0.0 or later, which runs in Node.js, Bun, browsers, and Cloudflare Workers. In Node.js and Bun, load the grammar from its path:
21
24
 
22
25
  ```js
23
26
  import { fileURLToPath } from 'node:url';
@@ -63,8 +66,8 @@ fuzzed with:
63
66
 
64
67
  ```toml
65
68
  [dependencies]
66
- tree-sitter = { package = "willbooster-tree-sitter", version = "1.4.3" }
67
- tree-sitter-go = { package = "willbooster-tree-sitter-go", version = "1" }
69
+ tree-sitter = { package = "willbooster-tree-sitter", version = "2" }
70
+ tree-sitter-go = { package = "willbooster-tree-sitter-go", version = "2" }
68
71
  ```
69
72
 
70
73
  ```rust
@@ -90,7 +93,7 @@ not the ones this package ships with. Its first run downloads that CLI from the
90
93
  with `cargo` (whose build runs the CMake that `mise.toml` pins) when the download fails or the release has no binary that runs here. Run other CLI commands through it as
91
94
  well (e.g. `script/tree-sitter parse file.go`).
92
95
 
93
- `bun run generate` records a fresh ABI 16 generation profile from the applicable `test/corpus` cases and Git-tracked
96
+ `bun run generate` records a fresh generation profile from the applicable `test/corpus` cases and Git-tracked
94
97
  files in `examples/`, then generates compact parser tables. The parser also embeds metadata from `tree-sitter.json`. After changing a grammar,
95
98
  `tree-sitter.json`, a corpus case, or a tracked example,
96
99
  regenerate and commit `src/`. Stage added or removed examples with `git add -A examples` before generation so the profile uses the intended file list.
package/grammar.js CHANGED
@@ -90,6 +90,7 @@ module.exports = grammar({
90
90
  [$.qualified_type, $._expression],
91
91
  [$.generic_type, $._simple_type],
92
92
  [$.parameter_declaration, $._simple_type],
93
+ [$.type_parameter_declaration, $._simple_type],
93
94
  [$.type_parameter_declaration, $._simple_type, $._expression],
94
95
  [$.type_parameter_declaration, $._expression],
95
96
  [$.type_parameter_declaration, $._simple_type, $.generic_type, $._expression],
@@ -231,6 +232,7 @@ module.exports = grammar({
231
232
  'func',
232
233
  field('receiver', $.parameter_list),
233
234
  field('name', $._field_identifier),
235
+ field('type_parameters', optional($.type_parameter_list)),
234
236
  field('parameters', $.parameter_list),
235
237
  field('result', optional(choice($.parameter_list, $._simple_type))),
236
238
  field('body', optional($.block)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@willbooster/tree-sitter-go",
3
- "version": "1.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Go grammar for tree-sitter",
5
5
  "keywords": [
6
6
  "incremental",
@@ -47,7 +47,7 @@
47
47
  "@willbooster/oxfmt-config": "1.2.2",
48
48
  "@willbooster/oxlint-config": "1.4.8",
49
49
  "@willbooster/wb": "22.24.0",
50
- "@willbooster/web-tree-sitter": "1.5.1",
50
+ "@willbooster/web-tree-sitter": "2.0.1",
51
51
  "conventional-changelog-conventionalcommits": "10.4.0",
52
52
  "lefthook": "2.1.16",
53
53
  "oxfmt": "0.71.0",
@@ -61,7 +61,7 @@
61
61
  "wrangler": "4.147.0"
62
62
  },
63
63
  "peerDependencies": {
64
- "@willbooster/web-tree-sitter": "^1.4.3"
64
+ "@willbooster/web-tree-sitter": "^2.0.0"
65
65
  },
66
66
  "peerDependenciesMeta": {
67
67
  "@willbooster/web-tree-sitter": {
@@ -1633,6 +1633,16 @@
1633
1633
  "named": true
1634
1634
  }
1635
1635
  ]
1636
+ },
1637
+ "type_parameters": {
1638
+ "multiple": false,
1639
+ "required": false,
1640
+ "types": [
1641
+ {
1642
+ "type": "type_parameter_list",
1643
+ "named": true
1644
+ }
1645
+ ]
1636
1646
  }
1637
1647
  }
1638
1648
  },
Binary file
package/tree-sitter.json CHANGED
@@ -14,7 +14,7 @@
14
14
  }
15
15
  ],
16
16
  "metadata": {
17
- "version": "1.0.0",
17
+ "version": "2.1.0",
18
18
  "license": "MIT",
19
19
  "description": "Go grammar for tree-sitter",
20
20
  "authors": [