Skip to content

Add container information to CallHierarchyItem #37061

Description

@mjbvz

From microsoft/vscode#89616

Search Terms

  • call hierarchy
  • tsserver

Problem

Currently using the call hierarchy api, it can be difficult to browse through long list of callers and understand where those callers are:

Screen Shot 2020-02-26 at 3 12 17 PM

Suggestion

Add optional information about the container on the CallHierarchyItem type. For example, the NavTooItem has:

containerName?: string;
containerKind?: ScriptElementKind;

We should consider something similar for CallHierarchyItem

/cc Johannes Rieken (@jrieken)

Activity

  1. added
    Domain: API
    Domain: LS: Symbol Navigation
    Suggestion
    on Feb 27, 2020
  2. DanielRosenwasser commented on Feb 27, 2020

    @DanielRosenwasser
    Member

    Given that you're in call hierarchy, won't you end up with many of the same icons anyway? What sorts of distinctions would be helpful here, and would they only apply to methods on classes?

  3. added
    In Discussion
    Needs Proposal
    on Feb 27, 2020
  4. mjbvz commented on Feb 27, 2020

    @mjbvz
    ContributorAuthor

    Yes I don't think we would use the containerKind to display an icon. It may be helpful to understand the type of the callee for example

  5. mjbvz commented on Feb 27, 2020

    @mjbvz
    ContributorAuthor

    Johannes Rieken (@jrieken) Do you think we should show the file name for every entry?

    Screen Shot 2020-02-26 at 5 22 03 PM

    This is similar to workspace symbol search results

  6. jrieken commented on Feb 27, 2020

    @jrieken
    Contributor

    In a very first version we showed the file name and that was disliked - often different (contained) types are in the same file. Also file paths are very long.

    That's why container name is wanted, which sometimes might be a file name but often is a class or namespace name. Having this will provide much more context and will make it easier to work with the call hierarchy (which by its nature can be confusing already)

  7. added
    VS Code Priority
    on Apr 9, 2020
  8. mjbvz commented on Apr 15, 2020

    @mjbvz
    ContributorAuthor

    Here's my proposal for the TS Server api:

    interface CallHierarchyItem {
        /**
          * Name of symbol's container symbol (if any), such as the class name.
         */
        containerName?: string;
    }

    Not sure we have a use for containerKind so I'm leaving that out for now

  9. added
    Fix Available
    on Jun 9, 2020
  10. jrieken commented on Sep 1, 2020

    @jrieken
    Contributor

    Matt Bierner (@mjbvz) did we adopt this? I don't see a difference when selfhosting

  11. mjbvz commented on Sep 1, 2020

    @mjbvz
    ContributorAuthor

    Andrew Branch (@andrewbranch) Looks like TS does not return a value for containerName. It's undefined in all the cases I've tested

  12. andrewbranch commented on Sep 1, 2020

    @andrewbranch
    Member

    It turns out there’s a data conversion function on the server layer, which our normal test suite doesn’t touch, that returns an object with a specific set of keys, so the new property was left out of the serialization. PR incoming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Domain: APIDomain: LS: Symbol NavigationFix AvailableIn DiscussionNeeds ProposalSuggestionVS Code Priority

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    ⌂ Proxy