36

I'm trying to find a "View the Call Hierarchy" feature in Visual Studio/VSCodium.

What I want to do is right-click on a method's name (or press a keyboard shortcut), and a new pane opens up, displaying all the methods that call the clicked method, and the call tree of this method.

I found that in Eclipse and PyCharm but I only found "Find all references" in VSCode.

EDIT: I want to do that in Python, but if a such feature exists for all languages, that would be nice.

3
  • 1
    Possible duplicate of Visual Studio Code show call hierarchy
    – BuZZ-dEE
    Commented Aug 14, 2019 at 20:29
  • 1
    I have (re-)opened this request: github.com/microsoft/vscode-python/issues/12945
    – GuSuku
    Commented Jul 14, 2020 at 0:20
  • 3
    I wonder if this feature is still in progress. I am looking for call heirarchy / call tree view for C/C++ functions in VsCode. This is a really helpful feature for programmers. I recently switched to VsCode after almost 10+ years using Eclipse IDE. We had this call heirarchy in Eclipse IDE that is super useful when it comes to understanding code flow. Could someone direct me if there are any free extensions available if VsCode doesn't support by its own? Commented Nov 16, 2020 at 18:04

1 Answer 1

34

This is currently (v1.33) a preview feature. See release notes re: call hierarchy.

A call hierarchy view shows all calls from or to a function and allows you to drill into callers of callers and calls of calls. The image below shows that function foo is being called by bar and bang, then bar is being called by bang and fib.

call hierarchy demo picture

This is a preview feature and there aren't any extensions currently providing real data for it. However, if you are an extension author, we invite you to validate our proposed API. If you are interested, there is a sample extension for testing: https://github.com/jrieken/demo-callhierarchy.

There is already a bound command for this, editor.showCallHierarchy. You will have to see whether any python extension has support for this feature.

---------- Update -------------------

v1.43 Release notes: https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_43.md#call-hierarchy-support-for-javascript-and-typescript

call heirarchy


In the v1.50 Insiders' Build is the ability to dismiss/exclude selected entries in the call heirarchy (possibly after you have reviewed that entry). See https://github.com/microsoft/vscode/issues/98155

Note the X dismiss button in the demo:

call hierarchy dismiss demo

[thanks to @VonC for finding this PR and pointing it out]

8
  • 3
    Could you please advice is there a shortcut that allow to open this view?
    – SternK
    Commented Dec 6, 2019 at 13:05
  • 7
    @SternK Shift + Alt + H Commented Sep 4, 2020 at 7:37
  • 3
    You might also update this very good answer with VSCode 1.50 PR github.com/microsoft/vscode/issues/98155
    – VonC
    Commented Sep 19, 2020 at 6:23
  • @VonC Thank you I have added the v1.50PR info to the answer.
    – Mark
    Commented Sep 19, 2020 at 20:10
  • 1
    I have version 1.52.0 and I still don't have this? Shift+Alt+H only opens up the help menu.
    – JoeManiaci
    Commented Dec 14, 2020 at 23:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.