Skip to content

Commit 788c6f1

Browse files
fix: move method decorators into method_decorator field
1 parent 198d035 commit 788c6f1

File tree

8 files changed

+418867
-341727
lines changed

8 files changed

+418867
-341727
lines changed

common/define-grammar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,6 @@ module.exports = function defineGrammar(dialect) {
420420
'{',
421421
repeat(choice(
422422
seq(
423-
repeat(field('decorator', $.decorator)),
424423
$.method_definition,
425424
optional($._semicolon),
426425
),
@@ -449,6 +448,7 @@ module.exports = function defineGrammar(dialect) {
449448
),
450449

451450
method_definition: $ => prec.left(seq(
451+
repeat(field('decorator', $.decorator)),
452452
optional($.accessibility_modifier),
453453
optional('static'),
454454
optional($.override_modifier),

test/corpus/declarations.txt

+13-13
Original file line numberDiff line numberDiff line change
@@ -938,13 +938,13 @@ class Foo {
938938
(class_declaration
939939
(type_identifier)
940940
(class_body
941-
(decorator
942-
(call_expression
943-
(identifier)
944-
(type_arguments
945-
(type_identifier))
946-
(arguments)))
947941
(method_definition
942+
(decorator
943+
(call_expression
944+
(identifier)
945+
(type_arguments
946+
(type_identifier))
947+
(arguments)))
948948
(property_identifier)
949949
(formal_parameters)
950950
(statement_block)))))
@@ -1000,9 +1000,9 @@ Classes with decorators
10001000
(type_identifier))
10011001
(string
10021002
(string_fragment)))
1003-
(decorator
1004-
(identifier))
10051003
(method_definition
1004+
(decorator
1005+
(identifier))
10061006
(property_identifier)
10071007
(formal_parameters
10081008
(required_parameter
@@ -1204,12 +1204,12 @@ class C {
12041204
(class_declaration
12051205
(type_identifier)
12061206
(class_body
1207-
(decorator
1208-
(parenthesized_expression
1209-
(member_expression
1210-
(identifier)
1211-
(property_identifier))))
12121207
(method_definition
1208+
(decorator
1209+
(parenthesized_expression
1210+
(member_expression
1211+
(identifier)
1212+
(property_identifier))))
12131213
(property_identifier)
12141214
(formal_parameters)
12151215
(statement_block)))))

tsx/src/grammar.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -6586,17 +6586,6 @@
65866586
{
65876587
"type": "SEQ",
65886588
"members": [
6589-
{
6590-
"type": "REPEAT",
6591-
"content": {
6592-
"type": "FIELD",
6593-
"name": "decorator",
6594-
"content": {
6595-
"type": "SYMBOL",
6596-
"name": "decorator"
6597-
}
6598-
}
6599-
},
66006589
{
66016590
"type": "SYMBOL",
66026591
"name": "method_definition"
@@ -6873,6 +6862,17 @@
68736862
"content": {
68746863
"type": "SEQ",
68756864
"members": [
6865+
{
6866+
"type": "REPEAT",
6867+
"content": {
6868+
"type": "FIELD",
6869+
"name": "decorator",
6870+
"content": {
6871+
"type": "SYMBOL",
6872+
"name": "decorator"
6873+
}
6874+
}
6875+
},
68766876
{
68776877
"type": "CHOICE",
68786878
"members": [

tsx/src/node-types.json

+13-14
Original file line numberDiff line numberDiff line change
@@ -1407,18 +1407,7 @@
14071407
{
14081408
"type": "class_body",
14091409
"named": true,
1410-
"fields": {
1411-
"decorator": {
1412-
"multiple": true,
1413-
"required": false,
1414-
"types": [
1415-
{
1416-
"type": "decorator",
1417-
"named": true
1418-
}
1419-
]
1420-
}
1421-
},
1410+
"fields": {},
14221411
"children": {
14231412
"multiple": true,
14241413
"required": false,
@@ -3686,6 +3675,16 @@
36863675
}
36873676
]
36883677
},
3678+
"decorator": {
3679+
"multiple": true,
3680+
"required": false,
3681+
"types": [
3682+
{
3683+
"type": "decorator",
3684+
"named": true
3685+
}
3686+
]
3687+
},
36893688
"name": {
36903689
"multiple": false,
36913690
"required": true,
@@ -6097,11 +6096,11 @@
60976096
},
60986097
{
60996098
"type": "number",
6100-
"named": true
6099+
"named": false
61016100
},
61026101
{
61036102
"type": "number",
6104-
"named": false
6103+
"named": true
61056104
},
61066105
{
61076106
"type": "object",

0 commit comments

Comments
 (0)