-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add sliceLocation
helper to simplify location operations
#406
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! So much simpler.
@@ -2,9 +2,9 @@ name: CI | |||
|
|||
on: | |||
push: | |||
branches: [prism] | |||
branches: [prism, prism-squashed] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch
std::string_view Translator::sliceLocation(pm_location_t loc) { | ||
return std::string_view(reinterpret_cast<const char *>(loc.start), loc.end - loc.start); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a super strong opinion -- what do you think about moving this to Parser.cc
? It only relies on Prism's parse tree state and could feasibly be useful even when we're no longer translating.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that Parser
current doesn't have any other helper functions and we're still many PRs away from addressing all the feedback, I think it'd be simpler for future changes if we keep this and future helpers in the Translator by default, until we have a clearer understanding on how they'd be used outside of the translator.
* Add sliceLocation helper to simplify location operations * Run CI on prism-squahed too
Motivation
As suggested in sorbet#8485 (comment) and sorbet#8485 (comment)
Test plan
See included automated tests.