-
Notifications
You must be signed in to change notification settings - Fork 799
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
Document Symbols Request, clarify location of Symbol. #132
Comments
Here are some more examples to consider... Q1. If
Q2. If
Q3. If
|
Actually I am leaning towards not to strictly spec this, however we can give recommendations. The LSP is meant to help with integrating smartness into a tool. The idea of the LSP is not do support program analysis for which this has to be spec clearly. |
@dbaeumer I agree with not giving a strict spec. I hope the recommendations will be enough to give guidance to LSP-server-implementors and LSP-client-implementors on the following areas of smartness:
|
I too would like this to be clarified. I had assumed that the range of the symbol was for the string (so that clients could select the symbol's name when you selected the symbol in an 'Outline' view) but it seems that I was wrong and the range should be for the entire scope of the symbol...? |
As I commented here: microsoft/vscode#11587 (comment) -- I think it would be great for the LSP to define a range for both usages. You wouldn't have to completely spec what exactly each encompasses but just having them gives a better idea of usage and expectation. |
The current state with both ranges (this issue) and containerName (#112) not being strictly enough specified makes unclear how to properly support a tree-based navigation of the code (outline). I would suggest that:
|
I discovered another problem with containerName in the ocaml-language-server. cc @arxanas @freebroccolo Consider the following ocaml:
The ocaml-language-server reports three symbols:
Here the containerName PROPOSALI think we should add an optional "containerRange" field to each element that already has a "containerName". It will unambiguously identify which documentSymbol is the parent. I think this will be the easiest incremental proposal to implement. It doesn't require anyone to define what precisely is meant by "range". And I'm certain that every LSP server which currently emits a "containerName" will already know how to print the range it associates with that container symbol. |
Then it doesn't really solve the initial issue ;) |
IMO we should do the following:
In the last milestone I added means to propose new protocol more easily. It is described here: https://github.com/Microsoft/language-server-protocol/blob/master/contributing.md So may be someone wants to provide this as a PR. |
Here is an example about what I mean: export interface SymbolInformation {
/**
* The name of this symbol.
*/
name: string;
/**
* The kind of this symbol.
*/
kind: SymbolKind;
/**
* The location of this symbol. The location's range is used by a tool
* to reveal the location in the editor. If the symbol is selected in the
* tool the range's start information is used to position the cursor. So
* the range usually spwans more then the actual symbol's name and does
* normally include thinks like visibility modifiers.
*
* The range doesn't have to denote a node range in the sense of a abstract
* syntax tree. It can therefore not be used to re-construct a hierarchy of
* the symbols.
*/
location: Location;
/**
* The name of the symbol containing this symbol. This information is for
* user interface purposes (e.g. to render a qaulifier in the user interface
* if necessary). It can't be used to re-infer a hierarchy for the document
* symbols.
*/
containerName?: string;
} |
I clarified the indented behavior in the spec and the implementation. |
Suppose you have this code:
Then for the Document Symbols Request what is the location range for the symbol Foo?
Foo
(length of 3)? (that being just the range of the identifier)class Foo {
... to}
.This has implications for: #112
The text was updated successfully, but these errors were encountered: