@willbooster/tree-sitter-java 6.0.0 → 6.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 +2 -2
- package/grammar.js +24 -33
- package/package.json +1 -1
- package/src/node-types.json +8 -0
- package/tree-sitter-java.wasm +0 -0
- package/tree-sitter.json +1 -1
package/README.md
CHANGED
|
@@ -107,8 +107,8 @@ not the ones this package ships with. Its first run downloads that CLI from the
|
|
|
107
107
|
with `cargo` (whose build runs the CMake that `mise.toml` pins) when the download fails or the release has no binary that runs here. Run other CLI commands through it as
|
|
108
108
|
well (e.g. `script/tree-sitter parse File.java`).
|
|
109
109
|
|
|
110
|
-
`grammar.js`
|
|
111
|
-
|
|
110
|
+
`grammar.js` keeps upstream's code layout so changes can be compared with upstream's grammar; the linter and formatter
|
|
111
|
+
skip it.
|
|
112
112
|
|
|
113
113
|
`bun run generate` records a fresh generation profile from the applicable `test/corpus` cases and any Git-tracked
|
|
114
114
|
files in `examples/`, then generates compact parser tables. The parser also embeds metadata from `tree-sitter.json`. After changing a grammar,
|
package/grammar.js
CHANGED
|
@@ -13,37 +13,33 @@ const DECIMAL_DIGITS = token(sep1(/[0-9]+/, /_+/));
|
|
|
13
13
|
const DIGITS = token(choice('0', seq(/[1-9]/, optional(seq(optional(/_+/), DECIMAL_DIGITS)))));
|
|
14
14
|
const HEX_DIGITS = token(sep1(/[A-Fa-f0-9]+/, /_+/));
|
|
15
15
|
|
|
16
|
-
/* eslint-disable no-multi-spaces */
|
|
17
|
-
|
|
18
16
|
const PREC = {
|
|
19
17
|
// https://introcs.cs.princeton.edu/java/11precedence/
|
|
20
|
-
COMMENT: 0,
|
|
21
|
-
ASSIGN: 1,
|
|
18
|
+
COMMENT: 0,
|
|
19
|
+
ASSIGN: 1,
|
|
22
20
|
DECL: 2,
|
|
23
21
|
ELEMENT_VAL: 2,
|
|
24
|
-
TERNARY: 3,
|
|
25
|
-
OR: 4,
|
|
26
|
-
AND: 5,
|
|
27
|
-
BIT_OR: 6,
|
|
28
|
-
BIT_XOR: 7,
|
|
29
|
-
BIT_AND: 8,
|
|
30
|
-
EQUALITY: 9,
|
|
22
|
+
TERNARY: 3,
|
|
23
|
+
OR: 4,
|
|
24
|
+
AND: 5,
|
|
25
|
+
BIT_OR: 6,
|
|
26
|
+
BIT_XOR: 7,
|
|
27
|
+
BIT_AND: 8,
|
|
28
|
+
EQUALITY: 9,
|
|
31
29
|
GENERIC: 10,
|
|
32
|
-
REL: 10,
|
|
33
|
-
SHIFT: 11,
|
|
34
|
-
ADD: 12,
|
|
35
|
-
MULT: 13,
|
|
36
|
-
CAST: 14,
|
|
37
|
-
OBJ_INST: 14,
|
|
38
|
-
UNARY: 15,
|
|
39
|
-
ARRAY: 16,
|
|
40
|
-
OBJ_ACCESS: 16,
|
|
41
|
-
PARENS: 16,
|
|
42
|
-
CLASS_LITERAL: 17,
|
|
30
|
+
REL: 10,
|
|
31
|
+
SHIFT: 11,
|
|
32
|
+
ADD: 12,
|
|
33
|
+
MULT: 13,
|
|
34
|
+
CAST: 14,
|
|
35
|
+
OBJ_INST: 14,
|
|
36
|
+
UNARY: 15,
|
|
37
|
+
ARRAY: 16,
|
|
38
|
+
OBJ_ACCESS: 16,
|
|
39
|
+
PARENS: 16,
|
|
40
|
+
CLASS_LITERAL: 17,
|
|
43
41
|
};
|
|
44
42
|
|
|
45
|
-
/* eslint-enable no-multi-spaces */
|
|
46
|
-
|
|
47
43
|
module.exports = grammar({
|
|
48
44
|
name: 'java',
|
|
49
45
|
|
|
@@ -77,6 +73,7 @@ module.exports = grammar({
|
|
|
77
73
|
[$.array_type, $._unannotated_type],
|
|
78
74
|
[$.array_type, $.primary_expression],
|
|
79
75
|
[$.modifiers, $.annotated_type, $.receiver_parameter],
|
|
76
|
+
[$.type_pattern, $.annotated_type],
|
|
80
77
|
[$.modifiers, $.annotated_type, $.module_declaration, $.package_declaration],
|
|
81
78
|
[$._unannotated_type, $.primary_expression, $.inferred_parameters],
|
|
82
79
|
[$._unannotated_type, $.primary_expression],
|
|
@@ -84,7 +81,6 @@ module.exports = grammar({
|
|
|
84
81
|
[$._unannotated_type, $.generic_type],
|
|
85
82
|
[$.generic_type, $.primary_expression],
|
|
86
83
|
[$.expression, $.statement],
|
|
87
|
-
// Only conflicts in switch expressions
|
|
88
84
|
[$.lambda_expression, $.primary_expression],
|
|
89
85
|
[$.inferred_parameters, $.primary_expression],
|
|
90
86
|
[$.argument_list, $.record_pattern_body],
|
|
@@ -280,10 +276,6 @@ module.exports = grammar({
|
|
|
280
276
|
)),
|
|
281
277
|
'"""',
|
|
282
278
|
),
|
|
283
|
-
// Workaround to https://github.com/tree-sitter/tree-sitter/issues/1156
|
|
284
|
-
// We give names to the token() constructs containing a regexp
|
|
285
|
-
// so as to obtain a node in the CST.
|
|
286
|
-
|
|
287
279
|
string_fragment: _ => token.immediate(prec(1, /[^"\\]+/)),
|
|
288
280
|
_multiline_string_fragment: _ => choice(
|
|
289
281
|
/[^"\\]+/,
|
|
@@ -438,7 +430,6 @@ module.exports = grammar({
|
|
|
438
430
|
)),
|
|
439
431
|
|
|
440
432
|
update_expression: $ => prec.left(PREC.UNARY, choice(
|
|
441
|
-
// Post (in|de)crement is evaluated before pre (in|de)crement
|
|
442
433
|
seq($.expression, '++'),
|
|
443
434
|
seq($.expression, '--'),
|
|
444
435
|
seq('++', $.expression),
|
|
@@ -623,7 +614,7 @@ module.exports = grammar({
|
|
|
623
614
|
$.type_pattern,
|
|
624
615
|
$.record_pattern,
|
|
625
616
|
),
|
|
626
|
-
type_pattern: $ => seq(
|
|
617
|
+
type_pattern: $ => seq(repeat(choice($._annotation, 'final')), $._unannotated_type, choice($.identifier, $._reserved_identifier, $.underscore_pattern)),
|
|
627
618
|
record_pattern: $ => seq(choice($.identifier, $._reserved_identifier, $.generic_type, $.scoped_type_identifier), $.record_pattern_body),
|
|
628
619
|
record_pattern_body: $ => seq('(', commaSep(choice($.record_pattern_component, $.record_pattern)), ')'),
|
|
629
620
|
record_pattern_component: $ => choice(
|
|
@@ -655,7 +646,7 @@ module.exports = grammar({
|
|
|
655
646
|
$.continue_statement,
|
|
656
647
|
$.return_statement,
|
|
657
648
|
$.yield_statement,
|
|
658
|
-
$.switch_expression,
|
|
649
|
+
$.switch_expression,
|
|
659
650
|
$.synchronized_statement,
|
|
660
651
|
$.local_variable_declaration,
|
|
661
652
|
$.throw_statement,
|
|
@@ -1053,7 +1044,7 @@ module.exports = grammar({
|
|
|
1053
1044
|
$.field_declaration,
|
|
1054
1045
|
$.record_declaration,
|
|
1055
1046
|
$.method_declaration,
|
|
1056
|
-
$.compact_constructor_declaration,
|
|
1047
|
+
$.compact_constructor_declaration,
|
|
1057
1048
|
$.class_declaration,
|
|
1058
1049
|
$.interface_declaration,
|
|
1059
1050
|
$.annotation_type_declaration,
|
package/package.json
CHANGED
package/src/node-types.json
CHANGED
|
@@ -3950,10 +3950,18 @@
|
|
|
3950
3950
|
"type": "_unannotated_type",
|
|
3951
3951
|
"named": true
|
|
3952
3952
|
},
|
|
3953
|
+
{
|
|
3954
|
+
"type": "annotation",
|
|
3955
|
+
"named": true
|
|
3956
|
+
},
|
|
3953
3957
|
{
|
|
3954
3958
|
"type": "identifier",
|
|
3955
3959
|
"named": true
|
|
3956
3960
|
},
|
|
3961
|
+
{
|
|
3962
|
+
"type": "marker_annotation",
|
|
3963
|
+
"named": true
|
|
3964
|
+
},
|
|
3957
3965
|
{
|
|
3958
3966
|
"type": "underscore_pattern",
|
|
3959
3967
|
"named": true
|
package/tree-sitter-java.wasm
CHANGED
|
Binary file
|