-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
API for hierarchical document symbol data #34968
Comments
LSP side of this: microsoft/language-server-protocol#136 |
Indeed needed.. |
We want to define, maybe propose, the API this milestone and build a UI for this in May. |
Proposal is to have a new type like |
FYI, this is also related to #11587 |
First cut of the API proposal export class HierarchicalSymbolInformation {
name: string;
kind: SymbolKind;
location: Location; // use location#range to point to the 'identifier' or 'goto' position
range: Range; // full symbol range as opposed
children: HierarchicalSymbolInformation[]; // child items
constructor(name: string, kind: SymbolKind, location: Location, range: Range);
}
export interface DocumentSymbolProvider {
provideDocumentSymbols(document: TextDocument, token: CancellationToken): ProviderResult<HierarchicalSymbolInformation | SymbolInformation[]>;
} |
I'm the author of the Code Outline extension. Here's my take on this:
This could work nicely for languages where methods can be defined outside of the class body or where symbols belong to namespaces independent of the order of definition. However...
This approach would work better if you're ever planning to incorporate other sources of regions such as the folding provider (I'm planning to show folding regions as containers once |
An alternative would be a export class Hierarchy<T> {
parent: T;
children: Hierarchy<T>[];
constructor(element: T);
}
export class SymbolInformation {
detail: string;
range: Range;
//more...
}
export interface DocumentSymbolProvider {
provideDocumentSymbols(
document: TextDocument,
token: CancellationToken
): ProviderResult<SymbolInformation[] | Hierarchy<SymbolInformation>[]>;
} |
@patrys I think you've misunderstood what I said. I'm not talking about grouping things like imports; imports shouldn't even appear in the outline tree. My comment is about providing data for rendering in the outline tree that is not shown in the flat document symbol list (because when not rendered in a tree it's less useful). |
@mofux Yeah, an earlier version had a |
I think not having it could encourage people to just add it to the name.. I'd already done that in Dart because it seemed useful. If it's a separate field at least it could be rendered more subtle. |
@jrieken Thanks for your thoughts. What shape would this Another thought: |
Given that the |
I have added a simple 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"
function funcA(a, b) {}
// have to hover "funcB"
const funcB = (a, b) => {}
// have to hover "function" keyword
this.funcC = function(a, b) {}
// no hover position can reveal the function signature
this.funcD = (a, b) => {} |
I guess it would use the |
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. |
The ability to have modifiers on |
After discussing this today we wanna make two ranges |
Is it going to be possible for extensions to contribute |
@pltrant This issue is about the underlying API, not configuration |
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
SymbolInformation
-objects, e.g. add an optionalchildren
-property.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.The text was updated successfully, but these errors were encountered: