ruby/lib/prism/translation
Stan Lo 0924ff2d39 [ruby/prism] Fix parser translation's heredoc whitespace calculation
Given this example:

```rb
<<~HEREDOC
  #{x}
HEREDOC
```

Both the parser gem and Prism's translation layer would generate the following AST:

```
s(:dstr,
  s(:begin,
    s(:int, 1)),
  s(:str, " a\n"))
```

However, the parser gem inserts a empty string node into this node's location, like:

```
<Parser::Source::Map::Heredoc:0x0000000104ce73b8
 @expression=#<Parser::Source::Range (string) 0...10>,
 @heredoc_body=#<Parser::Source::Range (string) 11...20>,
 @heredoc_end=#<Parser::Source::Range (string) 20...27>,
 @node=s(:dstr,
  s(:str, ""),
  s(:begin,
    s(:int, 1)),
  s(:str, " a\n"))>
```

This is required to calculate the correct whitespace for the heredoc body.

We need to adjust the translation layer to account for this.

With this fix, we also won't need to ignore the tilde heredoc fixture anymore.

e7372e3ba5
2024-04-12 13:55:35 +00:00
..
parser [ruby/prism] Fix parser translation's heredoc whitespace calculation 2024-04-12 13:55:35 +00:00
ripper [ruby/prism] Use require_relative in the Prism codebase 2024-03-18 16:12:49 +00:00
parser.rb [ruby/prism] Fix incorrect paring when using invalid regexp options 2024-03-25 12:16:32 +00:00
parser33.rb [ruby/prism] Fix up some minor parser incompatibilities 2024-03-04 14:39:52 +00:00
parser34.rb [ruby/prism] Fix up some minor parser incompatibilities 2024-03-04 14:39:52 +00:00
ripper.rb [ruby/prism] Shareable constant nodes 2024-03-15 12:31:26 +00:00
ruby_parser.rb [ruby/prism] Use Sexp#line_max not Sexp#max_line 2024-03-25 12:13:52 +00:00