Skip to content

Annotate references with the name of the entity they occur in #396

Open

Description

The response to textDocument/references is currently just Location[] | null.

However, clients may want to show, for each reference, information such as the name of the entity (e.g. function or class) in which the reference occurs, which they cannot easily compute on the client side.

Could the protocol be extended so the response is something like Reference[] | null, where Reference contains both a Location and possibly extra information like the name of the containing entity?

Activity

  1. dbaeumer commented on Apr 9, 2018

    @dbaeumer
    Member

    I like the idea.

  2. added
    feature-request
    on Apr 9, 2018
  3. raja-s commented on Jan 14, 2019

    @raja-s

    Having a separate Reference structure is a good idea. There are potentially other interesting information a language server might want to include, for example the access type (read/write/both) in the case of references to a variable.

  4. dbaeumer commented on Dec 1, 2020

    @dbaeumer
    Member

    From #1155: a preview in a reference structure would be helpful as well.

  5. avivdolev commented on Jul 10, 2022

    @avivdolev

    I think this proposal could also help in #763
    Also, just want to +1 for adding access types (read/get | write/set) - it's super useful during debugging to know the possible places that modify something (rather than just read it).

    Another implementation to consider, at least for backward-compatibility, is to keep the current Location[] | null response, and augment the Location type with a metadata field that can hold a key-value map, same way it was done for notebooks:

    interface Location {
    	uri: DocumentUri;
    	range: Range;
    
              /**
    	 * Additional metadata stored with the location
    	 * document.
    	 */
    	metadata?: LSPObject;
    }
    
  6. foolmoron commented on Aug 21, 2023

    @foolmoron

    Another implementation to consider, at least for backward-compatibility, is to keep the current Location[] | null response, and augment the Location type with a metadata field that can hold a key-value map, same way it was done for notebooks

    It's equally BC to extend the Location interface with new props isn't it? Old usages can ignore the new props. Less data nesting that way.

  7. avivdolev commented on Aug 22, 2023

    @avivdolev

    Momin Khan (@foolmoron)
    Yes it is- just took an example from another extension. Either way will be super helpful.
    IMO one advantage for a metadata field is that each language can use its own key-value implementation of metadata, instead of finding some props that are useful to any arbitrary language.

  8. adonovan commented on Sep 8, 2024

    @adonovan

    See #1911 for a generalization of 'references' queries to allow servers to offer a variety of other queries that take the same form of input (a selection) and produce the same form of results (a set of [annotated] source locations) so that the client can re-use the same UI machinery for all of them.

  9. BloodyTalonsHuisman commented on May 20, 2026

    @BloodyTalonsHuisman

    All this was to make sure the data is safe in between user and receiver preventing rogue trusted handlers. Giving more to the user and server for safer security. Notebook can be changed to be very trigger happy taking files changing computers codes preventing use from using notebook like it was ment to be used. So I think this is how you protect are data from now on , just saying

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestreferences

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions