@willbooster/tree-sitter-java 3.1.2 → 5.0.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 +17 -5
- package/grammar.js +8 -4
- package/package.json +3 -3
- package/src/node-types.json +19 -1
- package/tree-sitter-java.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -16,13 +16,13 @@ This fork is based on tree-sitter-java 0.23.5 and accepts `final` modifiers on s
|
|
|
16
16
|
and typed record-pattern components, plus qualified names in record patterns. Unnamed variables in switch and
|
|
17
17
|
`instanceof` type patterns, including typed record-pattern components, use `underscore_pattern` nodes. It ships the
|
|
18
18
|
parser as the compact tables that the [WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter) generator
|
|
19
|
-
emits under that fork's own ABI number (`
|
|
20
|
-
later, and not with upstream's tree-sitter.
|
|
19
|
+
emits under that fork's own ABI number (`0x57420006`), so the parser loads only with that runtime, version 7.0.5 or
|
|
20
|
+
later within major version 7, and not with upstream's tree-sitter.
|
|
21
21
|
|
|
22
22
|
## Usage
|
|
23
23
|
|
|
24
24
|
The npm package ships `tree-sitter-java.wasm` for
|
|
25
|
-
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version
|
|
25
|
+
[@willbooster/web-tree-sitter](https://www.npmjs.com/package/@willbooster/web-tree-sitter) version 7.0.5 or later within major version 7, which runs in Node.js, Bun, browsers, and Cloudflare Workers. In Node.js and Bun, load the grammar from its path:
|
|
26
26
|
|
|
27
27
|
```js
|
|
28
28
|
import { fileURLToPath } from 'node:url';
|
|
@@ -62,14 +62,26 @@ parser.setLanguage(await Language.load(java));
|
|
|
62
62
|
|
|
63
63
|
The package also ships `grammar.js`, the queries in `queries/`, and the node types in `src/node-types.json`.
|
|
64
64
|
|
|
65
|
+
Within a declaration's `modifiers`, access keywords are named `visibility` nodes and other modifier keywords are
|
|
66
|
+
named `modifier` nodes. Annotations retain their own nodes, and the keyword tokens remain available for highlighting.
|
|
67
|
+
For example, this query captures explicitly public static methods without matching annotation text:
|
|
68
|
+
|
|
69
|
+
```scheme
|
|
70
|
+
(method_declaration
|
|
71
|
+
(modifiers (visibility) @visibility (modifier) @modifier)
|
|
72
|
+
name: (identifier) @method
|
|
73
|
+
(#eq? @visibility "public")
|
|
74
|
+
(#eq? @modifier "static"))
|
|
75
|
+
```
|
|
76
|
+
|
|
65
77
|
In Rust, depend on the [crate](https://crates.io/crates/willbooster-tree-sitter-java) and on
|
|
66
78
|
[willbooster-tree-sitter](https://crates.io/crates/willbooster-tree-sitter), the runtime this package is tested and
|
|
67
79
|
fuzzed with:
|
|
68
80
|
|
|
69
81
|
```toml
|
|
70
82
|
[dependencies]
|
|
71
|
-
tree-sitter = { package = "willbooster-tree-sitter", version = "
|
|
72
|
-
tree-sitter-java = { package = "willbooster-tree-sitter-java", version = "
|
|
83
|
+
tree-sitter = { package = "willbooster-tree-sitter", version = "7.0.5" }
|
|
84
|
+
tree-sitter-java = { package = "willbooster-tree-sitter-java", version = "5" }
|
|
73
85
|
```
|
|
74
86
|
|
|
75
87
|
```rust
|
package/grammar.js
CHANGED
|
@@ -991,9 +991,13 @@ module.exports = grammar({
|
|
|
991
991
|
|
|
992
992
|
modifiers: $ => repeat1(choice(
|
|
993
993
|
$._annotation,
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
994
|
+
$.visibility,
|
|
995
|
+
$.modifier,
|
|
996
|
+
)),
|
|
997
|
+
|
|
998
|
+
visibility: _ => choice('public', 'protected', 'private'),
|
|
999
|
+
|
|
1000
|
+
modifier: _ => choice(
|
|
997
1001
|
'abstract',
|
|
998
1002
|
'static',
|
|
999
1003
|
'final',
|
|
@@ -1005,7 +1009,7 @@ module.exports = grammar({
|
|
|
1005
1009
|
'volatile',
|
|
1006
1010
|
'sealed',
|
|
1007
1011
|
'non-sealed',
|
|
1008
|
-
)
|
|
1012
|
+
),
|
|
1009
1013
|
|
|
1010
1014
|
type_parameters: $ => seq(
|
|
1011
1015
|
'<', commaSep1($.type_parameter), '>',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-java",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Java 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.26.1",
|
|
50
|
-
"@willbooster/web-tree-sitter": "
|
|
50
|
+
"@willbooster/web-tree-sitter": "7.0.5",
|
|
51
51
|
"conventional-changelog-conventionalcommits": "10.4.0",
|
|
52
52
|
"lefthook": "2.2.1",
|
|
53
53
|
"oxfmt": "0.72.0",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"wrangler": "4.147.0"
|
|
61
61
|
},
|
|
62
62
|
"peerDependencies": {
|
|
63
|
-
"@willbooster/web-tree-sitter": "^
|
|
63
|
+
"@willbooster/web-tree-sitter": "^7.0.5"
|
|
64
64
|
},
|
|
65
65
|
"peerDependenciesMeta": {
|
|
66
66
|
"@willbooster/web-tree-sitter": {
|
package/src/node-types.json
CHANGED
|
@@ -2707,13 +2707,18 @@
|
|
|
2707
2707
|
]
|
|
2708
2708
|
}
|
|
2709
2709
|
},
|
|
2710
|
+
{
|
|
2711
|
+
"type": "modifier",
|
|
2712
|
+
"named": true,
|
|
2713
|
+
"fields": {}
|
|
2714
|
+
},
|
|
2710
2715
|
{
|
|
2711
2716
|
"type": "modifiers",
|
|
2712
2717
|
"named": true,
|
|
2713
2718
|
"fields": {},
|
|
2714
2719
|
"children": {
|
|
2715
2720
|
"multiple": true,
|
|
2716
|
-
"required":
|
|
2721
|
+
"required": true,
|
|
2717
2722
|
"types": [
|
|
2718
2723
|
{
|
|
2719
2724
|
"type": "annotation",
|
|
@@ -2722,6 +2727,14 @@
|
|
|
2722
2727
|
{
|
|
2723
2728
|
"type": "marker_annotation",
|
|
2724
2729
|
"named": true
|
|
2730
|
+
},
|
|
2731
|
+
{
|
|
2732
|
+
"type": "modifier",
|
|
2733
|
+
"named": true
|
|
2734
|
+
},
|
|
2735
|
+
{
|
|
2736
|
+
"type": "visibility",
|
|
2737
|
+
"named": true
|
|
2725
2738
|
}
|
|
2726
2739
|
]
|
|
2727
2740
|
}
|
|
@@ -4065,6 +4078,11 @@
|
|
|
4065
4078
|
}
|
|
4066
4079
|
}
|
|
4067
4080
|
},
|
|
4081
|
+
{
|
|
4082
|
+
"type": "visibility",
|
|
4083
|
+
"named": true,
|
|
4084
|
+
"fields": {}
|
|
4085
|
+
},
|
|
4068
4086
|
{
|
|
4069
4087
|
"type": "while_statement",
|
|
4070
4088
|
"named": true,
|
package/tree-sitter-java.wasm
CHANGED
|
Binary file
|