Skip to content
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

Merged
merged 1 commit into from
Sep 18, 2023
Merged

Conversation

vinistock
Copy link
Member

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.

@vinistock vinistock added this to the 2023-Q3 milestone Sep 15, 2023
@vinistock vinistock requested a review from a team as a code owner September 15, 2023 21:34
@vinistock vinistock self-assigned this Sep 15, 2023
@vinistock vinistock force-pushed the vs/make_folding_range_a_listener branch from e7f3079 to eb64a46 Compare September 18, 2023 15:20
@@ -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

Copy link
Contributor

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?

Copy link
Member Author

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Contributor

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?

Copy link
Member Author

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)
Copy link
Member

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.

Copy link
Member Author

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.

@vinistock vinistock merged commit ced0976 into yarp-clean Sep 18, 2023
21 checks passed
@vinistock vinistock deleted the vs/make_folding_range_a_listener branch September 18, 2023 17:31
vinistock added a commit that referenced this pull request Sep 19, 2023
* 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>
vinistock pushed a commit that referenced this pull request Feb 28, 2024
fix: do not redirect to OUTPUT channel while debugger close on error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants