You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to support a real outline view (#5605) and a breadcrumb bar (#9418, #31162) we need better document symbol information. Today, the API doesn't allow providers to return tree data and it also doesn't spec what the ranges of symbols should be. Some language extensions make the range be the whole symbol range, some make it the identifier range. It needs a new or refined API to support hierarchies, I see two options
allow a tree of SymbolInformation-objects, e.g. add an optional children-property.
have two range-objects on SymbolInformation-objects, one being the whole range and one being the identifier range. While this looks counter intuitive and worst than having tree-style-data it makes merging of different data sets from different providers easy.
Reacted by mihailik, Alexander, bizzyman, myfairsyer, Emil Gelev, Vincent Poinpoin, Yukai Huang, Joshua Tepper, KamasamaK, Patryk Zawadzki and 8 more
Proposal is to have a new type like DocumentSymbolInformation which has children and a symbol range. A DocumentSymbolProvider is free to return the new type, or oldSymbolInformation objects. In the latter case, we cannot render a tree and because of that providers should signal what they return upon registration.
exportclassHierarchicalSymbolInformation{name: string;kind: SymbolKind;location: Location;// use location#range to point to the 'identifier' or 'goto' positionrange: Range;// full symbol range as opposedchildren: HierarchicalSymbolInformation[];// child itemsconstructor(name: string,kind: SymbolKind,location: Location,range: Range);}exportinterfaceDocumentSymbolProvider{provideDocumentSymbols(document: TextDocument,token: CancellationToken): ProviderResult<HierarchicalSymbolInformation|SymbolInformation[]>;}
Wrt hovers: We are thinking to simply invoke the existing HoverProviders and to reuse that information. We need for special API - all information needed for that request (document & position) is already there.
I'm afraid it isn't that simple, consider these cases that show the hover positions required to get the correct function signature:
// have to hover "funcA"functionfuncA(a,b){}// have to hover "funcB"constfuncB=(a,b)=>{}// have to hover "function" keywordthis.funcC=function(a,b){}// no hover position can reveal the function signaturethis.funcD=(a,b)=>{}
I guess it would use the gotoRange so giving the extension control over this. Not sure about the last two samples and how often you use this to refer to the global but as soon as you have inside a function or class it works correctly.
Maybe not directly related, but wouldn't it make sense that we specify a way to provide additional symbol information (like arguments of a function type symbol), so they can be rendered in the outline tree later on?
Something else that comes to mind was an editor that I used in the past which had green/yellow/red icons (with static variants) next to public/protected/private methods and properties. It was a quick way to check member ordering without having to run something like tslint.
Is it going to be possible for extensions to contribute configurationDefaults for the Outline (to show and to set follow cursor and sort type)? It would seem logical since we can do that for things like the minimap. It's beneficial for creating a curated experience with certain specialized extensions (and users can always override said defaults).
Activity
jrieken commentedon Jan 5, 2018
LSP side of this: microsoft/language-server-protocol#136
Leedehai commentedon Apr 14, 2018
Indeed needed..
jrieken commentedon Apr 17, 2018
We want to define, maybe propose, the API this milestone and build a UI for this in May.
jrieken commentedon Apr 19, 2018
Proposal is to have a new type like
DocumentSymbolInformationwhich haschildrenand asymbolrange. ADocumentSymbolProvideris free to return the new type, or oldSymbolInformationobjects. In the latter case, we cannot render a tree and because of that providers should signal what they return upon registration.eamodio commentedon Apr 21, 2018
FYI, this is also related to #11587
jrieken commentedon Apr 23, 2018
First cut of the API proposal
first cut of _proposed_ api for hierarchy of document symbols, #34968
30 remaining items
mofux commentedon Jun 13, 2018
I'm afraid it isn't that simple, consider these cases that show the hover positions required to get the correct function signature:
jrieken commentedon Jun 13, 2018
I guess it would use the
gotoRangeso giving the extension control over this. Not sure about the last two samples and how often you usethisto refer to the global but as soon as you have inside a function or class it works correctly.mattacosta commentedon Jun 13, 2018
Something else that comes to mind was an editor that I used in the past which had green/yellow/red icons (with static variants) next to public/protected/private methods and properties. It was a quick way to check member ordering without having to run something like tslint.
KamasamaK commentedon Jun 13, 2018
The ability to have modifiers on
kindis proposed in #23927.jrieken commentedon Jun 14, 2018
After discussing this today we wanna make two ranges
fullRangebecomesrangeandgotoRangewill becomeselectionRange.pltrant commentedon Jun 15, 2018
Is it going to be possible for extensions to contribute
configurationDefaultsfor the Outline (to show and to set follow cursor and sort type)? It would seem logical since we can do that for things like the minimap. It's beneficial for creating a curated experience with certain specialized extensions (and users can always override said defaults).jrieken commentedon Jun 18, 2018
Patrick Trant (@pltrant) This issue is about the underlying API, not configuration
renames: range/selectionRange #34968
move DocumentSymbol API to vscode.d.ts, #34968
adjust return type signature, #34968