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

Implement call hierarchy request #2151

Merged
merged 35 commits into from
Jan 22, 2023
Merged

Conversation

jwortmann
Copy link
Member

@jwortmann jwortmann commented Dec 26, 2022

There is no Sublime API to visualize and interact with a tree structure, like for example the folders and files in the sidebar. So I made my own implementation for that, using a HtmlSheet. Let me know what you think!

It can be tested e.g. with LSP-pyright:

call_hierarchy.webm

For now only with "incoming calls" (which is quite similar to "Find References"), but just due to lack of a good solution how a toggle or so can be represented in the UI. VSCode has a small button to change between incoming/outgoing calls.

The "TreeView" is a quite generic implementation (inspired by the VSCode API). So it should be straightforward to reuse it for the "type hierarchy" request, but I haven't tested that because I don't know which language server supports type hierarchy requests.

Closes #1429.

@rchl
Copy link
Member

rchl commented Dec 26, 2022

Nice!
For now just one initial feedback after quick testing that the initial expand should be done automatically as this is the point of opening it in the first place.

@predrag-codetribe

This comment was marked as resolved.

@jwortmann
Copy link
Member Author

The first item is expanded now, and I added a toggle button to switch between incoming / outgoing calls.

Not sure what's going on with the CI. The lint errors seem to be completely unrelated to this PR. But I don't get those errors on the main branch...
If you merge my other PR, I can rebase on main and see if I can fix them.

@jwortmann
Copy link
Member Author

My OS, doesn't recognise ⏵ or ⏷ (12.2.1 On MacOS 12.2.1)

Oh, I see. I think it uses the code font for these characters, i.e. the font you configured in Preferences.sublime-settings. And it seems those characters are not supported by this font. I guess we can try to set the "system" font for them, and then see if the arrows are rendered correctly.

One other thing, Currently when I click a node, it will take me to the Location and close the Call Hierarchy. I will just see one file.

I would rather open a side by side view. That way I could still see the Call Hierarchy and click other Locations, to have a better look how they are called.

Yeah I had this in mind already, but haven't tried it yet. I wonder whether there is a way to open the new tab to the left of the "Call Hierarchy" sheet. So that the call hierarchy sheet will always be the rightmost tab.
But it doesn't look bad in your recording.

@predrag-codetribe

This comment was marked as resolved.

@predrag-codetribe

This comment was marked as outdated.

plugin/core/tree_view.py Outdated Show resolved Hide resolved
@rchl
Copy link
Member

rchl commented Dec 27, 2022

General note: The "Incoming" / "Outgoing" naming from the spec is IMO not very easy to understand. I think we could adopt the VSCode naming which uses "Callers of" / "Calls from".

@rchl
Copy link
Member

rchl commented Dec 27, 2022

(BTW. Adding support for Call Hierarchy in typescript-language-server/typescript-language-server#649 also)

@jwortmann jwortmann marked this pull request as ready for review December 29, 2022 17:17
Copy link
Member

@rchl rchl left a comment

Choose a reason for hiding this comment

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

Since we are OK with this approach, it would be nice if you could also add some bits about it to documentation (at least the new command name) and maybe add to main menu if relevant to you.

boot.py Outdated
@@ -190,27 +195,39 @@ def on_post_window_command(self, window: sublime.Window, command_name: str, args
sublime.set_timeout(panel_manager.update_log_panel)


class LspOpenLocationCommand(sublime_plugin.TextCommand):
class LspOpenLocationCommand(LspWindowCommand):
Copy link
Member

@rchl rchl Dec 29, 2022

Choose a reason for hiding this comment

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

boot.py Outdated Show resolved Hide resolved
plugin/call_hierarchy.py Outdated Show resolved Hide resolved
plugin/call_hierarchy.py Show resolved Hide resolved
plugin/call_hierarchy.py Outdated Show resolved Hide resolved
plugin/core/tree_view.py Show resolved Hide resolved
boot.py Show resolved Hide resolved
boot.py Outdated Show resolved Hide resolved
plugin/call_hierarchy.py Outdated Show resolved Hide resolved
plugin/core/protocol.py Outdated Show resolved Hide resolved
plugin/core/open.py Outdated Show resolved Hide resolved
rchl added 2 commits January 22, 2023 20:59
* main:
  workaround for View Listeners not being attached for new transient view (sublimelsp#2174)
  Make Document Symbols behavior more consistent with built-in Goto Symbol (sublimelsp#2166)
  docs: fsautocomplete config - remove redundant argument (sublimelsp#2165)
  Allow missing window/workDoneProgress/create request from the server (sublimelsp#2159)
  Use "plaintext" language ID for plain text files (sublimelsp#2164)
  Improve type annotations (sublimelsp#2162)
  Don't use "escapeall" extension when formatting with mdpopups (sublimelsp#2163)
@rchl rchl merged commit ba5aba3 into sublimelsp:main Jan 22, 2023
rchl added a commit that referenced this pull request Jan 22, 2023
* origin/main:
  feat(API): allow setting additional text in permanent server status (#2173)
  Implement call hierarchy request (#2151)
  workaround for View Listeners not being attached for new transient view (#2174)
@jwortmann jwortmann deleted the call-hierarchy branch January 23, 2023 12:22
rchl added a commit that referenced this pull request Jan 31, 2023
* main: (80 commits)
  Perform inlay hint action on double instead of single click (#2175)
  support canceling pending completions request (#2177)
  Implement type hierarchy request (#2180)
  fix stale state or lack of updates on changing branches (#2182)
  Add timestamp and request duration in LSP logs (#2181)
  don't show diagnostics panel on save by default (#2179)
  trigger "on_server_response_async" also for "initialize" response (#2172)
  feat(API): allow setting additional text in permanent server status (#2173)
  Implement call hierarchy request (#2151)
  workaround for View Listeners not being attached for new transient view (#2174)
  Make Document Symbols behavior more consistent with built-in Goto Symbol (#2166)
  docs: fsautocomplete config - remove redundant argument (#2165)
  Allow missing window/workDoneProgress/create request from the server (#2159)
  Use "plaintext" language ID for plain text files (#2164)
  Improve type annotations (#2162)
  Don't use "escapeall" extension when formatting with mdpopups (#2163)
  Cut 1.21.0
  Fix inlay hint parts wrapping into multiple lines (#2153)
  Ensure commands triggered from minihtml run on correct view (#2154)
  Add "Source Action" entry to the "Edit" main menu (#2149)
  ...
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.

Implement textDocument/callHierarchy
5 participants