@willbooster/tree-sitter-java 2.0.3 → 3.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 CHANGED
@@ -5,7 +5,7 @@
5
5
  [![Test](https://github.com/WillBooster/tree-sitter-java/actions/workflows/test.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-java/actions/workflows/test.yml)
6
6
  [![Test rust](https://github.com/WillBooster/tree-sitter-java/actions/workflows/test-rust.yml/badge.svg)](https://github.com/WillBooster/tree-sitter-java/actions/workflows/test-rust.yml)
7
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)
8
- [![wbfy](https://img.shields.io/badge/wbfy-20.36.11-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
8
+ [![wbfy](https://img.shields.io/badge/wbfy-20.41.8-1e90ff.svg)](https://github.com/WillBooster/shared/tree/main/packages/wbfy)
9
9
  [![crates.io](https://img.shields.io/crates/v/willbooster-tree-sitter-java.svg)](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. These extensions preserve the existing
17
- node types. It ships the parser as the compact tables that the
18
- [WillBooster/tree-sitter](https://github.com/WillBooster/tree-sitter) generator emits under that fork's own ABI number
19
- (`0x57420001`), so the parser loads only with that runtime, version 2.0.0 or later, and not with upstream's tree-sitter.
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. It skips the one case that upstream's own
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
@@ -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": "2.0.3",
3
+ "version": "3.0.0",
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.24.0",
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.16",
53
- "oxfmt": "0.71.0",
54
- "oxlint": "1.86.0",
55
- "oxlint-tsgolint": "7.0.2003",
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
  },
@@ -1,8 +1,4 @@
1
- ; Variables
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"
@@ -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
  }
Binary file
package/tree-sitter.json CHANGED
@@ -14,7 +14,7 @@
14
14
  }
15
15
  ],
16
16
  "metadata": {
17
- "version": "2.0.3",
17
+ "version": "3.0.0",
18
18
  "license": "MIT",
19
19
  "description": "Java grammar for tree-sitter",
20
20
  "authors": [