Skip to content

Commit 21a6d62

Browse files
committed
Add support for annotations in array creation
After upgrading guava, parsing started to fail on the following pattern: ```java String[] allMyStrings = new @nullable String[5]; ``` This changes addresses that problem
1 parent f5b54e5 commit 21a6d62

File tree

6 files changed

+21653
-20934
lines changed

6 files changed

+21653
-20934
lines changed

grammar.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ module.exports = grammar({
289289

290290
array_creation_expression: $ => prec.right(seq(
291291
'new',
292+
repeat($._annotation),
292293
field('type', $._simple_type),
293294
choice(
294295
seq(

src/grammar.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2376,6 +2376,13 @@
23762376
"type": "STRING",
23772377
"value": "new"
23782378
},
2379+
{
2380+
"type": "REPEAT",
2381+
"content": {
2382+
"type": "SYMBOL",
2383+
"name": "_annotation"
2384+
}
2385+
},
23792386
{
23802387
"type": "FIELD",
23812388
"name": "type",

src/node-types.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,20 @@
673673
}
674674
]
675675
}
676+
},
677+
"children": {
678+
"multiple": true,
679+
"required": false,
680+
"types": [
681+
{
682+
"type": "annotation",
683+
"named": true
684+
},
685+
{
686+
"type": "marker_annotation",
687+
"named": true
688+
}
689+
]
676690
}
677691
},
678692
{

0 commit comments

Comments
 (0)