Skip to content

Commit

Permalink
Adds support for constructor property promotion with readonly modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
nsfisis authored and cfroystad committed Jun 6, 2022
1 parent b9b719d commit 866e4a1
Show file tree
Hide file tree
Showing 6 changed files with 60,869 additions and 60,322 deletions.
1 change: 1 addition & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ module.exports = grammar({

property_promotion_parameter: $ => seq(
field('visibility', $.visibility_modifier),
field('readonly', optional($.readonly_modifier)),
field('type', optional($._type)), // Note: callable is not a valid type here, but instead of complicating the parser, we defer this checking to any intelligence using the parser
field('name', $.variable_name),
optional(seq(
Expand Down
16 changes: 16 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -2276,6 +2276,22 @@
"name": "visibility_modifier"
}
},
{
"type": "FIELD",
"name": "readonly",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "readonly_modifier"
},
{
"type": "BLANK"
}
]
}
},
{
"type": "FIELD",
"name": "type",
Expand Down
10 changes: 10 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -3598,6 +3598,16 @@
}
]
},
"readonly": {
"multiple": false,
"required": false,
"types": [
{
"type": "readonly_modifier",
"named": true
}
]
},
"type": {
"multiple": false,
"required": false,
Expand Down
Loading

0 comments on commit 866e4a1

Please sign in to comment.