-
Notifications
You must be signed in to change notification settings - Fork 94
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
Type hierarchy support #20
Conversation
Oh, this is neat! Random observations from playing with it:
I haven't looked deeply at the code but it looks reasonable. |
b587b4c
to
b32f199
Compare
Thanks for the feedback! I pushed an update that addresses many of the comments.
I implemented single-click navigation. The filename and line number are still there. I'm somewhat ambivalent about removing them, as they can still be useful (e.g. you could have different derived classes by the same name in different files). Perhaps keeping the filename only would make sense?
Haven't implemented this yet, will do in the next update.
I agree it's really tempting. But what do you do when there are multiple parents? If you show just one, or none, we might be misleading the user.
Yeah, the logic in the first draft only caused the view to be shown (i.e. have it appear in the panel), but not expanded or focused. I tried harder in this draft, should expand + focus now.
Fixed.
Just as another consumer of the tree view facility? Or is there some other connection? |
b32f199
to
7714e52
Compare
This is done now as well. I think the patch should be ready for review. |
The filename will be truncated most of the time: the panel is by default quite narrow, with indentation followed by the arrow indicator, followed by the name of the class, and finally the filename. If either the classname or the filename are long at all, it's going to be truncated. Once the extension is truncated it loses a lot of value as you can't tell it's a filename. I really think this is just going to be visual noise. It's also inconsistent with other places where we show classnames (like the workspace symbols panel) where the small grey text is the namespace rather than the filename.
I think we could show a dummy node "multiple parents" - it's not really elegant, but this is a rare case and it'd be great to avoid the awkward "reverse direction" interaction in the common case. |
7714e52
to
603ff80
Compare
Addressed review comments. |
I implemented this in a separate PR: https://github.com/HighCommander4/vscode-clangd/pull/1/commits |
Er, whoops, didn't mean to create a PR against my own fork... let's try that again: #44 |
Not quite wanted I wanted either, as that PR contains both commits. Sorry, the GitHub isn't strong with me: what's the proper way to create a PR against this main fork which depends on another PR (i.e. this one), and only contains that second commit? |
Not possible. isaacs/github#959 (comment) |
Review ping :) |
sorry, I planned to do the review, but somehow got distracted and forgot it. Will try to review it today or tomorrow.
I think you could create two branches in "clangd/vscode-clangd" repo (you should have permission), and send a PR against two branches. |
Thanks, will try that next time. For now, if you'd like to see the parts of the patch that have been split out to implement the "try to show parents as well" suggestion, you can look at just the second commit in #44. |
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.
please also resolve the clang-format issue on the CI.
btw, I saw an exception in the debug console when playing around this patch locally, no sure which operation caused it.
Clang Language Server is now active!
extension.js:135
rejected promise not handled within 1 second: Error: TreeError [clangd.typeHierarchyView] Data tree node not found: [object Object]
extensionHostProcess.js:976
stack trace: Error: TreeError [clangd.typeHierarchyView] Data tree node not found: [object Object]
at V.getDataNode (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1125:302)
at V.reveal (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:1124:883)
at q.reveal (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:5414:769)
at p.reveal (file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:4248:298)
at file:///Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js:4247:442
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:85:5)
This adds support for the textDocument/typeHierarchy and typeHierarchy/resolve requests which clangd supports, and displays their results in a tree view. The tree view shows either parents or children at a given time, and allows the user to switch between the two views. Fixes clangd#21
603ff80
to
ec81e62
Compare
Thanks for the review, I believe I addressed all of the comments.
Based on the stack trace, it is probably caused by the call to It's worth noting that #44 makes changes that could fix this (because we now have to support |
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.
Thanks, I think it is good to go. just a few more nits.
btw, I saw an exception in the debug console when playing around this patch locally, no sure which operation caused it.
Based on the stack trace, it is probably caused by the call to this.treeView.reveal() in TypeHierarchyProvider.reveal(). However, I have not been able to trigger it.
I saw it again today, but no luck to get stable reproduce steps (and it doesn't seem to hurt the functionality). Let's see whether it'll disappear after #44.
btw, please don't force-push commits, it makes reviewers harder to see the difference, I'd just append new commits.
Sorry, still getting used to the GitHub workflow which seems quite different from the Phabricator one (where I do I assume I should squash the commits together before merging, though, to avoid polluting the repo history with "Address review comments" commits. |
This is a first draft which I'm posting for feedback.
Currently, the type hierarchy view only shows derived classes (
Children
direction), which is the more useful one (since base classes can be navigated to from the base clauses in the class definition).We will need to make a UX choice around how to incorporate the
Parents
direction as well. My suggestion is:This is how vscode's built-in call hierarchy view works (for showing callers vs. callees), and given the similarity in the protocols, I am venturing a guess that this is how vscode's built-in type hierarchy view (which doesn't exist yet, but will eventually replace this when it does) will work as well.
Thoughts / feedback on this direction is welcome.