Repository navigation
Make go-to-definition on a typeclass projection application go to the instance(s) - #1767
Conversation
ba85f34 to
e06e665
Compare
|
Hmm the CI test failures are puzzling me (it looks like they're still not getting the instance locations for some reason), because everything passes locally when I do: |
|
The interactive tests are not designed for referencing core files in their output. Either you'll need to change the existing tests not to reference core instances, or we implement something in the vein of #1722 (comment) that would prevent these tests from showing instances. |
|
@rish987 Today we were discussing this PR in the dev meeting. Could you please clarify the semantics you are implementing? |
|
Sure, I was trying to follow what Sebastian described here, basically, on go-to-definition or go-to-type if we get an I think I may need some help with the tests though (I blindly copied over expected outputs that I just noticed include URIs on my local filesystem 😰 so of course it won't work). Perhaps we need some additional filtering to preserve existing behavior (and some new tests as well to specifically test the new functionality), I was discussing this with @Kha yesterday and it sounded like he had an idea regarding that? |
|
Right, the fundamental issue is that when looking at the typeclass method call |
…to the instance(s)
…ations (last Tuesday's meeting)
… is responsible for its `expr`.
…fo` node is responsible for its `expr`." This reverts commit d9767f2.
c0f1e26 to
760d9b7
Compare
|
Okay this should finally be ready! I've merged in #1903 so it depends on that PR being merged first. |
|
Whoops, didn't mean to close it! |
| structure InfoWithCtx where | ||
| ctx : Elab.ContextInfo | ||
| info : Elab.Info | ||
| children : PersistentArray InfoTree | ||
| deriving Inhabited, TypeName |
There was a problem hiding this comment.
Let's move this to InfoUtils and use it in hoverableInfoAt? and locationLinksOfInfo etc. The deriving TypeName should probably be left here though.
There was a problem hiding this comment.
Done, let me know what you think of the refactor.
There was a problem hiding this comment.
Hi, sorry to only comment on this now but InfoWithCtx is only really intended for use as a way of bundling data together in the RPC protocol so that interactive expressions and go-to-def in the infoview work. As Gabriel put it, it's a kind of "type popup + go-to-def thunk". Unless you need to do something with RPC here, it would be better not to move it and to add another type with whatever semantics you need instead.
There was a problem hiding this comment.
Duplicating it wouldn't be hard, but since the type is opaque in the RPC protocol I'm not really seeing the motivation. It's a sensible bundle of data to have in the server in general, and the name fits as well. Even if we don't necessarily need children in the widgets.
There was a problem hiding this comment.
The type seems like a better fit for Elab.InfoTree, if anything, because it was already hacky as far as the RPC interface is concerned — the outputs of delaboration are Elab.Infos but they should really be a much more restricted Delab.Info without variants like .ofCompletion. But okay, since InfoWithCtx is opaque we can always keep it around for uses such as in this PR but replace it with something else in the RPC interface. Btw @rish987 you probably want to also make the output of hoverableInfoAt? and termGoalAt? be InfoWithCtx, document what the children field is, and change the docstring to note that it's used for more than just RPC.
There was a problem hiding this comment.
Done, thanks for the suggestions.
6527820 to
acf4acb
Compare
aca714d to
9ebb657
Compare
This PR improves the 'Go to Definition' UX, specifically: - Using 'Go to Definition' on a type class projection will now extract the specific instances that were involved and provide them as locations to jump to. For example, using 'Go to Definition' on the `toString` of `toString 0` will yield results for `ToString.toString` and `ToString Nat`. - Using 'Go to Definition' on a macro that produces syntax with type class projections will now also extract the specific instances that were involved and provide them as locations to jump to. For example, using 'Go to Definition' on the `+` of `1 + 1` will yield results for `HAdd.hAdd`, `HAdd α α α` and `Add Nat`. - Using 'Go to Declaration' will now provide all the results of 'Go to Definition' in addition to the elaborator and the parser that were involved. For example, using 'Go to Declaration' on the `+` of `1 + 1` will yield results for `HAdd.hAdd`, `HAdd α α α`, `Add Nat`, ``macro_rules | `($x + $y) => ...`` and `infixl:65 " + " => HAdd.hAdd`. - Using 'Go to Type Definition' on a value with a type that contains multiple constants will now provide 'Go to Definition' results for each constant. For example, using 'Go to Type Definition' on `x` for `x : Array Nat` will yield results for `Array` and `Nat`. ### 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 to `InfoTree.hoverableInfoAtM?` and now takes a general `filter` argument instead of several boolean flags, as was the case before.
Closes #1722, pending #1903.