Skip to content

Land a design for NavBar and NavTo that works across editors #7523

Closed

Description

With the changes in #6644 , JavaScript and TypeScript currently have different NavBar implementations - which is different to the NavTo implementation. We should aim to unify the behavior and reuse logic as much as possible.

There are a couple of design challenges to work through:

  • The presentation and usage of NavBars is different across editors. For example, in Visual Studio, you have a list of containers, and beside it a list of members in that container, and this is commonly used to understand/navigate the structure of the code. In VSCode, this is more a "Go to symbol" implementation, that is presented as a single list and is typically used to fuzzy search on a symbol name in the file (perhaps it should use 'navto' for file?).
  • The data structure is currently different. The API returns a NavigationBarItem[], and a NavigationBarItem contains a member childItems: NavigationBarItem[]. This lends itself to a tree-like structure which VSCode handles and shows all items in its single list, whereas VS expects ALL containers to be members of the top-level array returned, with only a single-level depth of childItems (the members for that container).
  • What constitutes a container? Currently TypeScript has a relatively classical structure, with the source file, namespaces and classes being containers. However it is not unusual in JavaScript to have functions within arrow functions within class members, etc... We need to figure out how this maps to editor models for presenting structure.

Activity

  1. mhegazy commented on May 23, 2016

    @mhegazy
    Contributor

    Basarat Ali Syed (@basarat) suggests adding a new API to return flattened list instead of having one API for all IDEs. see #8755.

  2. basarat commented on May 23, 2016

    @basarat
    Contributor

    Without looking at it too much isn't getNamedDeclarations (used on nav to) in a source file significantly slower than getNavigationBarItems (just the ast I think). I might be completely wrong 🌹

  3. mhegazy commented on May 23, 2016

    @mhegazy
    Contributor

    isn't getNamedDeclarations (used on nav to) in a source file significantly slower than getNavigationBarItems (just the ast I think). I might be completely wrong

    They should be comparable. both do a full walk over the tree.

  4. modified the milestones: TypeScript 2.1, on Sep 29, 2016
  5. felixfbecker commented on Jun 8, 2017

    @felixfbecker
    Contributor

    Is there any public API for getting symbols in a source file that is not UI-oriented? It seems like getNamedDeclarations does what I want, but it is marked as internal. It feels wrong using getNavigationTree to do static analysis, especially since the objects emitted are not linked to the node that defines them in any way.

  6. basarat commented on Jun 8, 2017

    @basarat
    Contributor

    Felix Becker (@felixfbecker) if you want to live on the edge : https://github.com/basarat/byots 🌹❤️

  7. mhegazy commented on Aug 31, 2017

    @mhegazy
    Contributor

    We have landed a design for unified nav-bar between JS and TS for VS and a new navtree for VSCode. We have had this in place for over a year now with no complaints from API uses. I do not think this is needed any longer.

  8. removed this from the milestone on Apr 26, 2018
  9. locked and limited conversation to collaborators on Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

InfrastructureIssue relates to TypeScript team infrastructure

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions