Skip to content

API for hierarchical document symbol data #34968

Closed

Description

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.

Activity

  1. added
    editor-symbols
    feature-request
    on Sep 25, 2017
  2. jrieken commented on Jan 5, 2018

    @jrieken
    ContributorAuthor
  3. Leedehai commented on Apr 14, 2018

    @Leedehai

    Indeed needed..

  4. jrieken commented on Apr 17, 2018

    @jrieken
    ContributorAuthor

    We want to define, maybe propose, the API this milestone and build a UI for this in May.

  5. jrieken commented on Apr 19, 2018

    @jrieken
    ContributorAuthor

    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 old SymbolInformation objects. In the latter case, we cannot render a tree and because of that providers should signal what they return upon registration.

  6. eamodio commented on Apr 21, 2018

    @eamodio
    Contributor

    FYI, this is also related to #11587

  7. jrieken commented on Apr 23, 2018

    @jrieken
    ContributorAuthor

    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[]>;
    }
  8. 30 remaining items

  9. mofux commented on Jun 13, 2018

    @mofux

    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) => {}
  10. jrieken commented on Jun 13, 2018

    @jrieken
    ContributorAuthor

    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.

  11. mattacosta commented on Jun 13, 2018

    @mattacosta
    Contributor

    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.

  12. KamasamaK commented on Jun 13, 2018

    @KamasamaK

    The ability to have modifiers on kind is proposed in #23927.

  13. jrieken commented on Jun 14, 2018

    @jrieken
    ContributorAuthor

    After discussing this today we wanna make two ranges fullRange becomes range and gotoRange will become selectionRange.

  14. pltrant commented on Jun 15, 2018

    @pltrant

    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).

  15. jrieken commented on Jun 18, 2018

    @jrieken
    ContributorAuthor

    Patrick Trant (@pltrant) This issue is about the underlying API, not configuration

  16. locked and limited conversation to collaborators on Aug 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

apiapi-proposaleditor-symbolsfeature-requeston-testplanoutline

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions