[prism] Fix extra newline after require kwarg#765
Conversation
froydnj
left a comment
There was a problem hiding this comment.
idk if I'm a fan of this approach -- I think there's a lot of complexity around symbol nodes (e.g. 'require':) that I'm not sure this is going to handle. If nothing else, I think there should be some more tests around hashes with :require symbol keys in various formats (single-quoted, double-quoted, etc.). I know this same issue comes up with require: keys in hashes, so it'd be good to have tests for those regardless.
I do think having a proper MethodName token or some such that we can check for "require" instead of the current approach would be better and more robust overall. That would also handle the issue where we format require = foo with newlines after it, even though there isn't anything to require that.
bb8c4a2 to
90d3713
Compare
|
This seems to have introduced a very few cases in ripper where a heredoc immediately followed by a receiver-less method call overindents the method call on Stripe's codebase. Trying to minimize a test case. |
Closes #762
This bit in the line metadata handling looks for
"require"as a DirectPart to determine when we're in a series ofrequirecalls, which we insert a blank line after. This was happening afterrequire:as a kwarg (or hash key etc.) in the Prism implementation because in Ripper, keys would always be a DirectPart of"name:", whereas Prism separately emitted the name and then a colon as two parts.This PR tries to always emit assoc node keys as
"name:"to circumvent this. I don't know if it's my favorite approach in the world (part of me wonders if we should instead have more descriptive token types that aren't justDirectPartfor this), but this is what Ripper does, so I figured I'd keep it simple and just follow that.