Repository navigation
feat: improved go to definition - #9040
Merged
Merged
Conversation
|
Mathlib CI status (docs):
|
This doesn't make a difference in VS Code, since it destroys the order we provide it with anyways through sorting, but it might be useful for NeoVim.
mhuisi
force-pushed
the
mhuisi/go-to-implementation
branch
from
July 21, 2025 14:44
2bef641 to
5c40531
Compare
Collaborator
|
Reference manual CI status:
|
mhuisi
enabled auto-merge
July 21, 2025 15:35
1 task done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR improves the 'Go to Definition' UX, specifically:
toStringoftoString 0will yield results forToString.toStringandToString Nat.+of1 + 1will yield results forHAdd.hAdd,HAdd α α αandAdd Nat.+of1 + 1will yield results forHAdd.hAdd,HAdd α α α,Add Nat,macro_rules | `($x + $y) => ...andinfixl:65 " + " => HAdd.hAdd.xforx : Array Natwill yield results forArrayandNat.Details
'Go to Definition' for type class projections was first implemented by #1767, but there were still a couple of shortcomings with the implementation. E.g. in order to jump to the instance in
toString 0, one had to add another space within the application and then use 'Go to Definition' on that, or macros would block instances from being displayed. Then, when the .ilean format was added, most 'Go to Definition' requests were already handled using the .ileans in the watchdog process, and so the file worker never received them to handle them with the semantic information that it has available.This PR resolves most of the issues with the previous implementation and refactors the 'Go to Definition' control flow so that 'Go to Definition' requests are always handled by the file worker, with the watchdog merely using its .ilean position information to update the positions in the response to a more up-to-date state. This is necessary because the file worker obtains its position information from the .oleans, which need to be rebuilt in order to be up-to-date, while the watchdog always receives .ilean update notifications from each active file worker with the current position information in the editor.
Finally, all of the 'Go to Definition' code is refactored to be easier to maintain.
Breaking changes
InfoTree.hoverableInfoAt?has been generalized toInfoTree.hoverableInfoAtM?and now takes a generalfilterargument instead of several boolean flags, as was the case before.