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
Use a strategy pattern and inject encoder to process semantic tokens #94
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.
I like this refactor a lot, thanks for working on this. I've put in some comments to push the refactor forward and clean it up a little bit more.
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.
This looks really nice. One, final, round of comments.
There are still tests to be written for the encoder. I'd prefer to merge this PR first and make those changes in a separate PR, if you are all good with that. |
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.
Looks great, thanks for working on this 🙏
…pes/node-17.0.35 Bump @types/node from 17.0.34 to 17.0.35
Motivation
Related to: https://github.com/Shopify/ruby-dev-exp-issues/issues/518
As suggested by @paracycle on Slack:
Because
#compute_delta
is one of the possible encoding for our semantic tokens, we can use a decorator dedicated to encoding to modify the tokens gathered fromRequests::SemanticHighlighting
.This PR is to demonstrate the refactor to use the decorator pattern in the semantic highlighting request.
@paracycle Let me know if this was what you envisioned.
Implementation
The primary concern I have is that the requests are not set up to use the decorator pattern. I had to go against the request (
BaseRequest
) calling convention to make it work.This is how a request is usually run:
This is how
SemanticHighlighting
needs to be run using the decorator pattern:Vini previously had a concern for performance, since this would mean we're doing a two pass on the tokens array. However, I think this pattern is more maintainable, understandable and would allow us to have better tests. I think we can optimize later on if it becomes an issue. Wdyt?
Automated Tests
This is a proof of concept. If this is 👍, there is still additional work to be done to refactor the tests. The
SemanticHighlighting
class can be tested separately fromEncoder::Decorator
, which is nice.Manual Tests
N/A