@willbooster/tree-sitter-java 2.0.3 → 3.0.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/README.md +7 -7
- package/grammar.js +12 -12
- package/package.json +6 -7
- package/queries/highlights.scm +1 -17
- package/src/node-types.json +8 -0
- package/tree-sitter-java.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
[](https://github.com/WillBooster/tree-sitter-java/actions/workflows/test.yml)
|
|
6
6
|
[](https://github.com/WillBooster/tree-sitter-java/actions/workflows/test-rust.yml)
|
|
7
7
|
[](https://github.com/semantic-release/semantic-release)
|
|
8
|
-
[](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
|
|
9
9
|
[](https://crates.io/crates/willbooster-tree-sitter-java)
|
|
10
10
|
|
|
11
11
|
Java grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), forked from
|
|
@@ -13,10 +13,11 @@ Java grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter), fork
|
|
|
13
13
|
to its authors and contributors. This is not an official release of that project.
|
|
14
14
|
|
|
15
15
|
This fork is based on tree-sitter-java 0.23.5 and accepts `final` modifiers on switch type patterns
|
|
16
|
-
and typed record-pattern components, plus qualified names in record patterns.
|
|
17
|
-
|
|
18
|
-
[WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter) generator
|
|
19
|
-
(`0x57420001`), so the parser loads only with that runtime, version 2.0.0 or
|
|
16
|
+
and typed record-pattern components, plus qualified names in record patterns. Unnamed variables in switch and
|
|
17
|
+
`instanceof` type patterns, including typed record-pattern components, use `underscore_pattern` nodes. It ships the
|
|
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 (`0x57420001`), so the parser loads only with that runtime, version 2.0.0 or
|
|
20
|
+
later, and not with upstream's tree-sitter.
|
|
20
21
|
|
|
21
22
|
## Usage
|
|
22
23
|
|
|
@@ -110,8 +111,7 @@ and the release build regenerate the parsers before compiling them.
|
|
|
110
111
|
- the corpus in `test/corpus`, with the native build and with the Wasm build (the first run downloads the WASI SDK);
|
|
111
112
|
- an incremental-parsing check (`test/unit/incremental.test.ts`): `script/fuzz-corpus` runs `tree-sitter fuzz`, which
|
|
112
113
|
edits each corpus case at random, reparses it, undoes the edits, and reparses again. `TREE_SITTER_SEED`,
|
|
113
|
-
`TREE_SITTER_ITERATIONS`, and `TREE_SITTER_EDITS` run other or more edits
|
|
114
|
-
parser also reparses differently from a fresh parse (see `script/fuzz-corpus`);
|
|
114
|
+
`TREE_SITTER_ITERATIONS`, and `TREE_SITTER_EDITS` run other or more edits;
|
|
115
115
|
- a check that the real-world Java files of the repositories cloned into `examples/` fail to parse exactly as listed in
|
|
116
116
|
`script/known-failures.txt`. The first run clones the repositories. The example
|
|
117
117
|
repositories are pinned to commits in `script/parse-examples`. After a grammar change or a moved pin alters that
|
package/grammar.js
CHANGED
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
/// <reference types="tree-sitter-cli/dsl" />
|
|
10
10
|
// @ts-check
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const HEX_DIGITS = token(sep1(/[A-Fa-f0-9]+/,
|
|
12
|
+
const DECIMAL_DIGITS = token(sep1(/[0-9]+/, /_+/));
|
|
13
|
+
const DIGITS = token(choice('0', seq(/[1-9]/, optional(seq(optional(/_+/), DECIMAL_DIGITS)))));
|
|
14
|
+
const HEX_DIGITS = token(sep1(/[A-Fa-f0-9]+/, /_+/));
|
|
15
15
|
|
|
16
16
|
/* eslint-disable no-multi-spaces */
|
|
17
17
|
|
|
@@ -126,22 +126,22 @@ module.exports = grammar({
|
|
|
126
126
|
)),
|
|
127
127
|
|
|
128
128
|
octal_integer_literal: _ => token(seq(
|
|
129
|
-
choice('0o', '0O', '0'),
|
|
130
|
-
sep1(/[0-7]+/,
|
|
129
|
+
choice('0o', '0O', seq('0', optional(/_+/))),
|
|
130
|
+
sep1(/[0-7]+/, /_+/),
|
|
131
131
|
optional(choice('l', 'L')),
|
|
132
132
|
)),
|
|
133
133
|
|
|
134
134
|
binary_integer_literal: _ => token(seq(
|
|
135
135
|
choice('0b', '0B'),
|
|
136
|
-
sep1(/[01]+/,
|
|
136
|
+
sep1(/[01]+/, /_+/),
|
|
137
137
|
optional(choice('l', 'L')),
|
|
138
138
|
)),
|
|
139
139
|
|
|
140
140
|
decimal_floating_point_literal: _ => token(choice(
|
|
141
141
|
seq(DECIMAL_DIGITS, '.', optional(DECIMAL_DIGITS), optional(seq((/[eE]/), optional(choice('-', '+')), DECIMAL_DIGITS)), optional(/[fFdD]/)),
|
|
142
142
|
seq('.', DECIMAL_DIGITS, optional(seq((/[eE]/), optional(choice('-', '+')), DECIMAL_DIGITS)), optional(/[fFdD]/)),
|
|
143
|
-
seq(
|
|
144
|
-
seq(
|
|
143
|
+
seq(DECIMAL_DIGITS, /[eE]/, optional(choice('-', '+')), DECIMAL_DIGITS, optional(/[fFdD]/)),
|
|
144
|
+
seq(DECIMAL_DIGITS, optional(seq((/[eE]/), optional(choice('-', '+')), DECIMAL_DIGITS)), (/[fFdD]/)),
|
|
145
145
|
)),
|
|
146
146
|
|
|
147
147
|
hex_floating_point_literal: _ => token(seq(
|
|
@@ -153,7 +153,7 @@ module.exports = grammar({
|
|
|
153
153
|
optional(seq(
|
|
154
154
|
/[pP]/,
|
|
155
155
|
optional(choice('-', '+')),
|
|
156
|
-
|
|
156
|
+
DECIMAL_DIGITS,
|
|
157
157
|
optional(/[fFdD]/),
|
|
158
158
|
)),
|
|
159
159
|
)),
|
|
@@ -301,7 +301,7 @@ module.exports = grammar({
|
|
|
301
301
|
choice(
|
|
302
302
|
seq(
|
|
303
303
|
field('right', $._type),
|
|
304
|
-
optional(field('name', choice($.identifier, $._reserved_identifier))),
|
|
304
|
+
optional(field('name', choice($.identifier, $._reserved_identifier, $.underscore_pattern))),
|
|
305
305
|
),
|
|
306
306
|
field('pattern', $.record_pattern),
|
|
307
307
|
),
|
|
@@ -519,7 +519,7 @@ module.exports = grammar({
|
|
|
519
519
|
$.type_pattern,
|
|
520
520
|
$.record_pattern,
|
|
521
521
|
),
|
|
522
|
-
type_pattern: $ => seq(optional('final'), $._unannotated_type, choice($.identifier, $._reserved_identifier)),
|
|
522
|
+
type_pattern: $ => seq(optional('final'), $._unannotated_type, choice($.identifier, $._reserved_identifier, $.underscore_pattern)),
|
|
523
523
|
record_pattern: $ => seq(choice($.identifier, $._reserved_identifier, $.generic_type, $.scoped_type_identifier), $.record_pattern_body),
|
|
524
524
|
record_pattern_body: $ => seq('(', commaSep(choice($.record_pattern_component, $.record_pattern)), ')'),
|
|
525
525
|
record_pattern_component: $ => choice(
|
|
@@ -527,7 +527,7 @@ module.exports = grammar({
|
|
|
527
527
|
seq(
|
|
528
528
|
optional('final'),
|
|
529
529
|
$._unannotated_type,
|
|
530
|
-
choice($.identifier, $._reserved_identifier),
|
|
530
|
+
choice($.identifier, $._reserved_identifier, $.underscore_pattern),
|
|
531
531
|
),
|
|
532
532
|
),
|
|
533
533
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-java",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Java grammar for tree-sitter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"incremental",
|
|
@@ -46,17 +46,16 @@
|
|
|
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.
|
|
49
|
+
"@willbooster/wb": "22.26.1",
|
|
50
50
|
"@willbooster/web-tree-sitter": "2.0.1",
|
|
51
51
|
"conventional-changelog-conventionalcommits": "10.4.0",
|
|
52
|
-
"lefthook": "2.1
|
|
53
|
-
"oxfmt": "0.
|
|
54
|
-
"oxlint": "1.
|
|
55
|
-
"oxlint-tsgolint": "7.0.
|
|
52
|
+
"lefthook": "2.2.1",
|
|
53
|
+
"oxfmt": "0.72.0",
|
|
54
|
+
"oxlint": "1.87.0",
|
|
55
|
+
"oxlint-tsgolint": "7.0.2004",
|
|
56
56
|
"playwright": "1.63.0",
|
|
57
57
|
"semantic-release": "25.0.9",
|
|
58
58
|
"sort-package-json": "4.0.0",
|
|
59
|
-
"typescript": "7.0.2",
|
|
60
59
|
"vitest": "5.0.3",
|
|
61
60
|
"wrangler": "4.147.0"
|
|
62
61
|
},
|
package/queries/highlights.scm
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
(identifier) @variable
|
|
4
|
-
|
|
5
|
-
; Methods
|
|
1
|
+
[(identifier) (underscore_pattern)] @variable
|
|
6
2
|
|
|
7
3
|
(method_declaration
|
|
8
4
|
name: (identifier) @function.method)
|
|
@@ -10,8 +6,6 @@
|
|
|
10
6
|
name: (identifier) @function.method)
|
|
11
7
|
(super) @function.builtin
|
|
12
8
|
|
|
13
|
-
; Annotations
|
|
14
|
-
|
|
15
9
|
(annotation
|
|
16
10
|
name: (identifier) @attribute)
|
|
17
11
|
(marker_annotation
|
|
@@ -19,8 +13,6 @@
|
|
|
19
13
|
|
|
20
14
|
"@" @operator
|
|
21
15
|
|
|
22
|
-
; Types
|
|
23
|
-
|
|
24
16
|
(type_identifier) @type
|
|
25
17
|
|
|
26
18
|
(interface_declaration
|
|
@@ -54,17 +46,11 @@
|
|
|
54
46
|
(void_type)
|
|
55
47
|
] @type.builtin
|
|
56
48
|
|
|
57
|
-
; Constants
|
|
58
|
-
|
|
59
49
|
((identifier) @constant
|
|
60
50
|
(#match? @constant "^_*[A-Z][A-Z\\d_]+$"))
|
|
61
51
|
|
|
62
|
-
; Builtins
|
|
63
|
-
|
|
64
52
|
(this) @variable.builtin
|
|
65
53
|
|
|
66
|
-
; Literals
|
|
67
|
-
|
|
68
54
|
[
|
|
69
55
|
(hex_integer_literal)
|
|
70
56
|
(decimal_integer_literal)
|
|
@@ -90,8 +76,6 @@
|
|
|
90
76
|
(block_comment)
|
|
91
77
|
] @comment
|
|
92
78
|
|
|
93
|
-
; Keywords
|
|
94
|
-
|
|
95
79
|
[
|
|
96
80
|
"abstract"
|
|
97
81
|
"assert"
|
package/src/node-types.json
CHANGED
|
@@ -2250,6 +2250,10 @@
|
|
|
2250
2250
|
{
|
|
2251
2251
|
"type": "identifier",
|
|
2252
2252
|
"named": true
|
|
2253
|
+
},
|
|
2254
|
+
{
|
|
2255
|
+
"type": "underscore_pattern",
|
|
2256
|
+
"named": true
|
|
2253
2257
|
}
|
|
2254
2258
|
]
|
|
2255
2259
|
},
|
|
@@ -3896,6 +3900,10 @@
|
|
|
3896
3900
|
{
|
|
3897
3901
|
"type": "identifier",
|
|
3898
3902
|
"named": true
|
|
3903
|
+
},
|
|
3904
|
+
{
|
|
3905
|
+
"type": "underscore_pattern",
|
|
3906
|
+
"named": true
|
|
3899
3907
|
}
|
|
3900
3908
|
]
|
|
3901
3909
|
}
|
package/tree-sitter-java.wasm
CHANGED
|
Binary file
|