Skip to content

Commit b55b90f

Browse files
committed
fix issues with annotations
1 parent e398400 commit b55b90f

File tree

11 files changed

+91562
-92357
lines changed

11 files changed

+91562
-92357
lines changed

grammar.js

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ module.exports = grammar({
107107
[$._normal_formal_parameters],
108108
[$._declared_identifier],
109109
[$.equality_expression],
110-
[$.annotation, $.marker_annotation],
111110
[$._primary, $._type_name, $._simple_formal_parameter],
112111
[$.record_type_field, $._function_formal_parameter, $._var_or_type],
113112
[$.typed_identifier, $._var_or_type, $._function_formal_parameter],
@@ -1557,22 +1556,14 @@ module.exports = grammar({
15571556
),
15581557

15591558
// Annotations
1560-
1561-
_annotation: $ => choice(
1562-
$.marker_annotation,
1563-
$.annotation
1564-
),
1565-
1566-
marker_annotation: $ => seq(
1567-
'@',
1568-
field('name', choice($.identifier, $.scoped_identifier))
1569-
),
1570-
1571-
annotation: $ => seq(
1559+
annotation: $ => prec.right(seq(
15721560
'@',
15731561
field('name', choice($.identifier, $.scoped_identifier)),
1574-
field('arguments', $.arguments)
1575-
),
1562+
choice(
1563+
optional(seq($.type_arguments, $.arguments)),
1564+
optional($.arguments)
1565+
)
1566+
)),
15761567

15771568
// Declarations
15781569

@@ -1758,7 +1749,7 @@ module.exports = grammar({
17581749
),
17591750
),
17601751

1761-
_metadata: $ => prec.right(repeat1($._annotation)),
1752+
_metadata: $ => prec.right(repeat1($.annotation)),
17621753

17631754

17641755
type_parameters: $ => seq(

queries/highlights.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
; --------------------
1212
(annotation
1313
name: (identifier) @attribute)
14-
(marker_annotation
14+
(annotation
1515
name: (identifier) @attribute)
1616

1717
; Operators and Tokens

src/grammar.json

Lines changed: 59 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -6320,78 +6320,73 @@
63206320
}
63216321
]
63226322
},
6323-
"_annotation": {
6324-
"type": "CHOICE",
6325-
"members": [
6326-
{
6327-
"type": "SYMBOL",
6328-
"name": "marker_annotation"
6329-
},
6330-
{
6331-
"type": "SYMBOL",
6332-
"name": "annotation"
6333-
}
6334-
]
6335-
},
6336-
"marker_annotation": {
6337-
"type": "SEQ",
6338-
"members": [
6339-
{
6340-
"type": "STRING",
6341-
"value": "@"
6342-
},
6343-
{
6344-
"type": "FIELD",
6345-
"name": "name",
6346-
"content": {
6347-
"type": "CHOICE",
6348-
"members": [
6349-
{
6350-
"type": "SYMBOL",
6351-
"name": "identifier"
6352-
},
6353-
{
6354-
"type": "SYMBOL",
6355-
"name": "scoped_identifier"
6356-
}
6357-
]
6358-
}
6359-
}
6360-
]
6361-
},
63626323
"annotation": {
6363-
"type": "SEQ",
6364-
"members": [
6365-
{
6366-
"type": "STRING",
6367-
"value": "@"
6368-
},
6369-
{
6370-
"type": "FIELD",
6371-
"name": "name",
6372-
"content": {
6324+
"type": "PREC_RIGHT",
6325+
"value": 0,
6326+
"content": {
6327+
"type": "SEQ",
6328+
"members": [
6329+
{
6330+
"type": "STRING",
6331+
"value": "@"
6332+
},
6333+
{
6334+
"type": "FIELD",
6335+
"name": "name",
6336+
"content": {
6337+
"type": "CHOICE",
6338+
"members": [
6339+
{
6340+
"type": "SYMBOL",
6341+
"name": "identifier"
6342+
},
6343+
{
6344+
"type": "SYMBOL",
6345+
"name": "scoped_identifier"
6346+
}
6347+
]
6348+
}
6349+
},
6350+
{
63736351
"type": "CHOICE",
63746352
"members": [
63756353
{
6376-
"type": "SYMBOL",
6377-
"name": "identifier"
6354+
"type": "CHOICE",
6355+
"members": [
6356+
{
6357+
"type": "SEQ",
6358+
"members": [
6359+
{
6360+
"type": "SYMBOL",
6361+
"name": "type_arguments"
6362+
},
6363+
{
6364+
"type": "SYMBOL",
6365+
"name": "arguments"
6366+
}
6367+
]
6368+
},
6369+
{
6370+
"type": "BLANK"
6371+
}
6372+
]
63786373
},
63796374
{
6380-
"type": "SYMBOL",
6381-
"name": "scoped_identifier"
6375+
"type": "CHOICE",
6376+
"members": [
6377+
{
6378+
"type": "SYMBOL",
6379+
"name": "arguments"
6380+
},
6381+
{
6382+
"type": "BLANK"
6383+
}
6384+
]
63826385
}
63836386
]
63846387
}
6385-
},
6386-
{
6387-
"type": "FIELD",
6388-
"name": "arguments",
6389-
"content": {
6390-
"type": "SYMBOL",
6391-
"name": "arguments"
6392-
}
6393-
}
6394-
]
6388+
]
6389+
}
63956390
},
63966391
"_declaration": {
63976392
"type": "PREC",
@@ -7462,7 +7457,7 @@
74627457
"type": "REPEAT1",
74637458
"content": {
74647459
"type": "SYMBOL",
7465-
"name": "_annotation"
7460+
"name": "annotation"
74667461
}
74677462
}
74687463
},
@@ -12165,10 +12160,6 @@
1216512160
[
1216612161
"equality_expression"
1216712162
],
12168-
[
12169-
"annotation",
12170-
"marker_annotation"
12171-
],
1217212163
[
1217312164
"_primary",
1217412165
"_type_name",

0 commit comments

Comments
 (0)