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

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

Closed
billti opened this issue Mar 15, 2016 · 6 comments
Closed

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

billti opened this issue Mar 15, 2016 · 6 comments
Assignees
Labels
Infrastructure Issue relates to TypeScript team infrastructure

Comments

@billti
Copy link
Member

billti commented Mar 15, 2016

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.
@mhegazy
Copy link
Contributor

mhegazy commented May 23, 2016

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

@basarat
Copy link
Contributor

basarat commented May 23, 2016

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 🌹

@mhegazy
Copy link
Contributor

mhegazy commented May 23, 2016

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.

@ghost ghost mentioned this issue Jun 3, 2016
@ghost ghost mentioned this issue Jun 16, 2016
@mhegazy mhegazy modified the milestones: TypeScript 2.1, Future Sep 29, 2016
@felixfbecker
Copy link
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.

@basarat
Copy link
Contributor

basarat commented Jun 8, 2017

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

@mhegazy
Copy link
Contributor

mhegazy commented Aug 31, 2017

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.

@mhegazy mhegazy closed this as completed Aug 31, 2017
@mhegazy mhegazy removed this from the Future milestone Apr 26, 2018
@microsoft microsoft locked and limited conversation to collaborators Jul 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Infrastructure Issue relates to TypeScript team infrastructure
Projects
None yet
Development

No branches or pull requests

4 participants