Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3163315

Browse files
committed
Allow IfMod and UnlessMod to know about heredocs moving their bounds.
1 parent 59510a1 commit 3163315

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
4343
- Only unescape forward slashes in regular expressions if converting from slash bounds to `%r` bounds.
4444
- Allow `When` nodes to grab trailing comments away from their statements lists.
4545
- Allow flip-flop operators to be formatted correctly within `IfMod` and `UnlessMod` nodes.
46+
- Allow `IfMod` and `UnlessMod` to know about heredocs moving their bounds.
4647

4748
### Removed
4849

lib/syntax_tree.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6973,7 +6973,13 @@ def on_if_mod(predicate, statement)
69736973
IfMod.new(
69746974
statement: statement,
69756975
predicate: predicate,
6976-
location: statement.location.to(predicate.location)
6976+
location:
6977+
Location.new(
6978+
start_line: statement.location.start_line,
6979+
start_char: statement.location.start_char,
6980+
end_line: [statement.location.end_line, predicate.location.end_line].max,
6981+
end_char: predicate.location.end_char
6982+
)
69776983
)
69786984
end
69796985

@@ -12127,7 +12133,13 @@ def on_unless_mod(predicate, statement)
1212712133
UnlessMod.new(
1212812134
statement: statement,
1212912135
predicate: predicate,
12130-
location: statement.location.to(predicate.location)
12136+
location:
12137+
Location.new(
12138+
start_line: statement.location.start_line,
12139+
start_char: statement.location.start_char,
12140+
end_line: [statement.location.end_line, predicate.location.end_line].max,
12141+
end_char: predicate.location.end_char
12142+
)
1213112143
)
1213212144
end
1213312145

0 commit comments

Comments
 (0)