@willbooster/tree-sitter-rust 3.1.9 → 3.2.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 +6 -0
- package/grammar.js +14 -4
- package/package.json +11 -11
- package/queries/injections.scm +9 -0
- package/src/node-types.json +4 -0
- package/tree-sitter-rust.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -60,6 +60,12 @@ parser.setLanguage(await Language.load(rust));
|
|
|
60
60
|
|
|
61
61
|
The package also ships the queries in `queries/` and the node types in `src/node-types.json`.
|
|
62
62
|
|
|
63
|
+
Documentation-comment injections require a host with Markdown parsing and fenced-language injections.
|
|
64
|
+
Line documentation is combined across the syntax tree; an unclosed fence can affect later comments.
|
|
65
|
+
Each block comment is a separate Markdown document. Its content is passed through unchanged, including
|
|
66
|
+
leading `*` gutters, which remain Markdown text and can prevent fence recognition. Use unguttered block
|
|
67
|
+
documentation or line documentation for fenced examples with these queries.
|
|
68
|
+
|
|
63
69
|
In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-rust) and on
|
|
64
70
|
[willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
|
|
65
71
|
fuzzed with. The parser loads only with that runtime, version 2.0.0 or later; upstream's `tree-sitter` crate rejects it:
|
package/grammar.js
CHANGED
|
@@ -160,6 +160,8 @@ module.exports = grammar({
|
|
|
160
160
|
],
|
|
161
161
|
|
|
162
162
|
conflicts: ($) => [
|
|
163
|
+
[$.type_parameters, $.for_lifetimes],
|
|
164
|
+
[$.lifetime_parameter, $.for_lifetimes],
|
|
163
165
|
[$._token_pattern, $.token_repetition_pattern],
|
|
164
166
|
[$.token_tree, $.token_repetition],
|
|
165
167
|
[$.field_initializer_list, $.block],
|
|
@@ -664,7 +666,8 @@ module.exports = grammar({
|
|
|
664
666
|
seq(':', optional(seq(sepBy1('+', choice($._type, $.lifetime, $.higher_ranked_trait_bound)), optional('+'))))
|
|
665
667
|
),
|
|
666
668
|
|
|
667
|
-
higher_ranked_trait_bound: ($) =>
|
|
669
|
+
higher_ranked_trait_bound: ($) =>
|
|
670
|
+
prec.dynamic(1, seq('for', field('type_parameters', $.type_parameters), field('type', $._type))),
|
|
668
671
|
|
|
669
672
|
removed_trait_bound: ($) => seq('?', $._type),
|
|
670
673
|
|
|
@@ -794,7 +797,7 @@ module.exports = grammar({
|
|
|
794
797
|
|
|
795
798
|
array_type: ($) => seq('[', field('element', $._type), optional(seq(';', field('length', $._expression))), ']'),
|
|
796
799
|
|
|
797
|
-
for_lifetimes: ($) => seq('for', '<', optional(seq(sepBy1(',', $.lifetime), optional(','))), '>'),
|
|
800
|
+
for_lifetimes: ($) => prec(1, seq('for', '<', optional(seq(sepBy1(',', prec(1, $.lifetime)), optional(','))), '>')),
|
|
798
801
|
|
|
799
802
|
function_type: ($) =>
|
|
800
803
|
seq(
|
|
@@ -874,7 +877,14 @@ module.exports = grammar({
|
|
|
874
877
|
),
|
|
875
878
|
|
|
876
879
|
bounded_type: ($) =>
|
|
877
|
-
prec.left(
|
|
880
|
+
prec.left(
|
|
881
|
+
-1,
|
|
882
|
+
seq(
|
|
883
|
+
choice($.lifetime, $._type, $.use_bounds),
|
|
884
|
+
'+',
|
|
885
|
+
choice($.lifetime, $._type, $.use_bounds, prec.dynamic(-2, $.higher_ranked_trait_bound))
|
|
886
|
+
)
|
|
887
|
+
),
|
|
878
888
|
|
|
879
889
|
use_bounds: ($) =>
|
|
880
890
|
seq('use', token(prec(1, '<')), sepBy(',', choice($.lifetime, $._type_identifier)), optional(','), '>'),
|
|
@@ -917,7 +927,7 @@ module.exports = grammar({
|
|
|
917
927
|
abstract_type: ($) =>
|
|
918
928
|
seq(
|
|
919
929
|
'impl',
|
|
920
|
-
optional(seq('for', $.type_parameters)),
|
|
930
|
+
optional(prec.dynamic(1, seq('for', $.type_parameters))),
|
|
921
931
|
field(
|
|
922
932
|
'trait',
|
|
923
933
|
prec(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-rust",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "Rust grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -46,20 +46,20 @@
|
|
|
46
46
|
"@vitest/browser-playwright": "5.0.3",
|
|
47
47
|
"@willbooster/oxfmt-config": "1.2.2",
|
|
48
48
|
"@willbooster/oxlint-config": "1.4.8",
|
|
49
|
-
"@willbooster/wb": "22.
|
|
50
|
-
"@willbooster/web-tree-sitter": "2.0.
|
|
51
|
-
"conventional-changelog-conventionalcommits": "10.4.
|
|
52
|
-
"lefthook": "2.1
|
|
53
|
-
"oxfmt": "0.
|
|
54
|
-
"oxlint": "1.
|
|
55
|
-
"oxlint-tsgolint": "7.0.
|
|
56
|
-
"playwright": "1.
|
|
49
|
+
"@willbooster/wb": "22.26.1",
|
|
50
|
+
"@willbooster/web-tree-sitter": "2.0.24",
|
|
51
|
+
"conventional-changelog-conventionalcommits": "10.4.1",
|
|
52
|
+
"lefthook": "2.2.1",
|
|
53
|
+
"oxfmt": "0.72.0",
|
|
54
|
+
"oxlint": "1.87.0",
|
|
55
|
+
"oxlint-tsgolint": "7.0.2004",
|
|
56
|
+
"playwright": "1.64.0",
|
|
57
57
|
"semantic-release": "25.0.9",
|
|
58
58
|
"sort-package-json": "4.0.0",
|
|
59
59
|
"typescript": "7.0.2",
|
|
60
|
-
"vite": "8.3.
|
|
60
|
+
"vite": "8.3.4",
|
|
61
61
|
"vitest": "5.0.3",
|
|
62
|
-
"wrangler": "4.
|
|
62
|
+
"wrangler": "4.149.0"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"@willbooster/web-tree-sitter": "^2.0.0"
|
package/queries/injections.scm
CHANGED
|
@@ -13,3 +13,12 @@
|
|
|
13
13
|
body: (token_tree) @injection.content)
|
|
14
14
|
(#set! injection.language "rust")
|
|
15
15
|
(#set! injection.include-children))
|
|
16
|
+
|
|
17
|
+
((line_comment
|
|
18
|
+
doc: (doc_comment) @injection.content)
|
|
19
|
+
(#set! injection.language "markdown")
|
|
20
|
+
(#set! injection.combined))
|
|
21
|
+
|
|
22
|
+
((block_comment
|
|
23
|
+
doc: (doc_comment) @injection.content)
|
|
24
|
+
(#set! injection.language "markdown"))
|
package/src/node-types.json
CHANGED
package/tree-sitter-rust.wasm
CHANGED
|
Binary file
|