@willbooster/tree-sitter-java 3.1.1 → 4.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 +5 -5
- package/grammar.js +52 -18
- package/package.json +3 -3
- 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';
|
|
@@ -68,8 +68,8 @@ fuzzed with:
|
|
|
68
68
|
|
|
69
69
|
```toml
|
|
70
70
|
[dependencies]
|
|
71
|
-
tree-sitter = { package = "willbooster-tree-sitter", version = "
|
|
72
|
-
tree-sitter-java = { package = "willbooster-tree-sitter-java", version = "
|
|
71
|
+
tree-sitter = { package = "willbooster-tree-sitter", version = "7.0.5" }
|
|
72
|
+
tree-sitter-java = { package = "willbooster-tree-sitter-java", version = "4" }
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
```rust
|
package/grammar.js
CHANGED
|
@@ -225,15 +225,41 @@ module.exports = grammar({
|
|
|
225
225
|
|
|
226
226
|
false: _ => 'false',
|
|
227
227
|
|
|
228
|
-
character_literal: _ =>
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
228
|
+
character_literal: _ => {
|
|
229
|
+
const incompleteUnicode = /\\u+[0-9a-fA-F]{0,3}/;
|
|
230
|
+
const malformedUnicode = /\\u+([0-9a-fA-F]{1,3}[^0-9a-fA-F\\'\n]|[^0-9a-fA-Fu\\'\n])/;
|
|
231
|
+
const encodedBackslash = /\\u+005[cC]/;
|
|
232
|
+
const unicodeCharacter = /\\u+([1-9a-fA-F][0-9a-fA-F]{3}|0[1-9a-fA-F][0-9a-fA-F]{2}|00[0-46-9a-fA-F][0-9a-fA-F]|005[0-9abd-fABD-F])/;
|
|
233
|
+
const plainCharacter = /[^\\'\n]/;
|
|
234
|
+
const rawEscape = /\\[^u]/;
|
|
235
|
+
const boundedEscape = choice(
|
|
236
|
+
malformedUnicode,
|
|
237
|
+
rawEscape,
|
|
238
|
+
unicodeCharacter,
|
|
239
|
+
seq(encodedBackslash, choice(encodedBackslash, /[^'\n]/, /\n/)),
|
|
240
|
+
);
|
|
241
|
+
const boundedTail = seq(
|
|
242
|
+
repeat(choice(
|
|
243
|
+
plainCharacter,
|
|
244
|
+
seq(repeat(incompleteUnicode), boundedEscape),
|
|
245
|
+
)),
|
|
246
|
+
repeat(incompleteUnicode),
|
|
247
|
+
optional(encodedBackslash),
|
|
248
|
+
);
|
|
249
|
+
const character = choice(
|
|
250
|
+
plainCharacter,
|
|
251
|
+
rawEscape,
|
|
252
|
+
unicodeCharacter,
|
|
253
|
+
seq(encodedBackslash, choice(encodedBackslash, /./, /\n/)),
|
|
254
|
+
);
|
|
255
|
+
return token(seq('\'', choice(
|
|
256
|
+
repeat1(character),
|
|
257
|
+
seq(repeat(character), repeat1(incompleteUnicode)),
|
|
258
|
+
seq(repeat(character), malformedUnicode, boundedTail),
|
|
259
|
+
seq(repeat(character), repeat1(incompleteUnicode), boundedEscape, boundedTail),
|
|
260
|
+
seq(repeat(character), repeat1(incompleteUnicode), encodedBackslash),
|
|
261
|
+
), '\''));
|
|
262
|
+
},
|
|
237
263
|
|
|
238
264
|
string_literal: $ => choice($._string_literal, $._multiline_string_literal),
|
|
239
265
|
_string_literal: $ => seq(
|
|
@@ -274,15 +300,23 @@ module.exports = grammar({
|
|
|
274
300
|
prec(2, token.immediate(seq('\\', /[^bfnrts'\"\\]/))),
|
|
275
301
|
prec(1, $.escape_sequence),
|
|
276
302
|
),
|
|
277
|
-
escape_sequence: _ => token.immediate(
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
/[
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
303
|
+
escape_sequence: _ => token.immediate(choice(
|
|
304
|
+
seq(/\\u+005[cC]/, choice(
|
|
305
|
+
/(?:[0-3]|\\u+003[0-3])(?:[0-7]|\\u+003[0-7]){0,2}/,
|
|
306
|
+
/(?:[4-7]|\\u+003[4-7])(?:[0-7]|\\u+003[0-7])?/,
|
|
307
|
+
/\\u+[0-9a-fA-F]{4}/,
|
|
308
|
+
)),
|
|
309
|
+
seq(
|
|
310
|
+
choice('\\', /\\u+005[cC]/),
|
|
311
|
+
choice(
|
|
312
|
+
/[^xu0-7]/,
|
|
313
|
+
/(?:[0-3][0-7]{0,2}|[4-7][0-7]?)/,
|
|
314
|
+
/x[0-9a-fA-F]{2}/,
|
|
315
|
+
/u+[0-9a-fA-F]{4}/,
|
|
316
|
+
/u\{[0-9a-fA-F]+\}/,
|
|
317
|
+
),
|
|
318
|
+
),
|
|
319
|
+
)),
|
|
286
320
|
|
|
287
321
|
null_literal: _ => 'null',
|
|
288
322
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@willbooster/tree-sitter-java",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.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/tree-sitter-java.wasm
CHANGED
|
Binary file
|