File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
12
12
- Comments can now be attached to the ` case ` keyword.
13
13
- Remove escaped forward slashes from regular expression literals when converting to ` %r ` .
14
14
- Allow arrays of ` CHAR ` nodes to be converted to ` QWords ` under certain conditions.
15
+ - Allow ` Hash ` opening braces to have trailing comments.
15
16
16
17
### Changed
17
18
Original file line number Diff line number Diff line change @@ -6096,6 +6096,9 @@ def on_gvar(value)
6096
6096
# { key => value }
6097
6097
#
6098
6098
class HashLiteral
6099
+ # [LBrace] the left brace that opens this hash
6100
+ attr_reader :lbrace
6101
+
6099
6102
# [Array[ AssocNew | AssocSplat ]] the optional contents of the hash
6100
6103
attr_reader :assocs
6101
6104
@@ -6105,19 +6108,20 @@ class HashLiteral
6105
6108
# [Array[ Comment | EmbDoc ]] the comments attached to this node
6106
6109
attr_reader :comments
6107
6110
6108
- def initialize ( assocs :, location :, comments : [ ] )
6111
+ def initialize ( lbrace :, assocs :, location :, comments : [ ] )
6112
+ @lbrace = lbrace
6109
6113
@assocs = assocs
6110
6114
@location = location
6111
6115
@comments = comments
6112
6116
end
6113
6117
6114
6118
def child_nodes
6115
- assocs
6119
+ [ lbrace ] + assocs
6116
6120
end
6117
6121
6118
6122
def format ( q )
6119
6123
contents = -> do
6120
- q . text ( "{" )
6124
+ q . format ( lbrace )
6121
6125
q . indent do
6122
6126
q . breakable
6123
6127
q . format ( HashFormatter . for ( self ) )
@@ -6156,6 +6160,7 @@ def on_hash(assocs)
6156
6160
rbrace = find_token ( RBrace )
6157
6161
6158
6162
HashLiteral . new (
6163
+ lbrace : lbrace ,
6159
6164
assocs : assocs || [ ] ,
6160
6165
location : lbrace . location . to ( rbrace . location )
6161
6166
)
You can’t perform that action at this time.
0 commit comments