-
Notifications
You must be signed in to change notification settings - Fork 122
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
Make folding range a listener #1013
Conversation
2a75484
to
e7f3079
Compare
c01556e
to
e4912b0
Compare
e7f3079
to
eb64a46
Compare
@@ -251,5 +251,101 @@ def visit_block_local_variable_node(node) | |||
@listeners[:on_block_local_variable]&.each { |l| T.unsafe(l).on_block_local_variable(node) } | |||
super | |||
end | |||
|
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.
Not for this PR, but as followup maybe we can order these alphabetically?
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.
We're doing work to ship the event emitter in YARP, so maybe let's hold off since we may be able to get rid of this entire file.
@@ -96,6 +94,7 @@ def run(request) | |||
|
|||
# Run listeners for the document | |||
emitter = EventEmitter.new | |||
folding_range = Requests::FoldingRanges.new(document.parse_result.comments, emitter, @message_queue) |
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.
folding_range = Requests::FoldingRanges.new(document.parse_result.comments, emitter, @message_queue) | |
folding_ranges = Requests::FoldingRanges.new(document.parse_result.comments, emitter, @message_queue) |
(nit) just for consistency with the others.
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.
Actually, to match the LSP spec, maybe we keep the name as folding_range
, but rename the class?
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.
Yeah, in the beginning of the project we named a few requests wrong (using plural where it should've been singular).
Let's handle that in a separate PR though.
@@ -96,6 +94,7 @@ def run(request) | |||
|
|||
# Run listeners for the document | |||
emitter = EventEmitter.new | |||
folding_range = Requests::FoldingRanges.new(document.parse_result.comments, emitter, @message_queue) |
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.
Not directly related to this PR, but now with 5 requests depending on this code path, I feel we'll need more sophisticated error handling so failures to propagate too much, especially if we decided to invert the response updating logic to extensions.
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.
Yeah, agreed. We need to think about how we could collect errors on a per listener basis.
* Temporarily disable .github/workflows/lsp_check.yml * Temporarily disable some tests * Preparation for YARP migration * Migrate DocumentSymbol request to YARP * Migrate Hover request to YARP * Migrate PathCompletion request to YARP * Migrate Sorbet request to YARP * Migrate InlayHints request to YARP * Migrate ShowSyntaxTree request to YARP * Migrate SelectionRange request to YARP * Migrate Definition request to YARP * Migrate Diagnostics request to YARP * Migrate CodeActionResolve request to YARP * Update selection ranges expectations * Fix rebase discrepancies * Add YARP RBI annotations (#978) * Migrate code lens to yarp (#979) Migrate CodeLens to YARP * Update `SERVER_EXTENSIONS.md` for YARP (#984) Co-authored-by: Andy Waite <andyw8@users.noreply.github.com> * Update text references from Syntax Tree to YARP (#986) Co-authored-by: Andy Waite <andyw8@users.noreply.github.com> * Fix rebase discrepancies * Migrate folding range to YARP (#980) * Fix rebase discrepancies 3 * Migrate semantic highlighting to YARP (#1000) Co-authored-by: Alexandre Terrasa <Morriar@users.noreply.github.com> * Migrate document highlight to YARP (#1005) * Simplify block locals handling in semantic highlighting (#1011) * Fix latest breaking changes * Make folding range a listener (#1013) * Migrate DocumentLink request to YARP (#982) * Migrate DocumentLink to YARP * Only parse comments where needed * Fix type * PR feedback * Fix argument order * Re-enable DocumentLink integration test --------- Co-authored-by: Andy Waite <andyw8@users.noreply.github.com> * Re-enable CI (#1022) * Re-generate YARP RBIs * Re-enable tests * Fix typechecking errors * Use locations for creating document symbol entries --------- Co-authored-by: Andy Waite <andyw8@users.noreply.github.com> Co-authored-by: Andy Waite <13400+andyw8@users.noreply.github.com> Co-authored-by: Alexandre Terrasa <Morriar@users.noreply.github.com>
fix: do not redirect to OUTPUT channel while debugger close on error
Motivation
Closes #677
Closes #610
Closes #750
After migrating to YARP, turning folding range into a listener became a little easier.
Implementation
Since we discovered that the clients dedup many responses, I think we should avoid extra complexity in the server just to avoid duplicate items. Some tests now include a few duplicates, but this allows us to get a clean listener implementation for folding range.
In terms of the migration, the only odd thing for this one is that we need to emit partial ranges and collect comments after receiving all events. I did this in the
_response
implementation, let me know if you have concerns.Automated Tests
Updated the tests where duplication happens.