-
Notifications
You must be signed in to change notification settings - Fork 328
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
Provide metadata about symbols with DefinitionLink #415
Conversation
Enhanced textDocument/definition, textDocument/implementation, and textDocument/typeDefinition to potentially return a DefinitionLink. This new interface includes metadata about the ranges of both the originating source symbol and the target symbol. This will help provide more context to the user while navigating between different symbols in an editor. Signed-off-by: Remy Suen <[email protected]>
88044e4
to
74d1577
Compare
types/src/main.ts
Outdated
@@ -1656,7 +1696,7 @@ export interface SignatureHelp { | |||
* For most programming languages there is only one location at which a symbol is | |||
* defined. If no definition can be found `null` is returned. | |||
*/ | |||
export type Definition = Location | Location[] | null; | |||
export type Definition = Location | Location[] | DefinitionLink | DefinitionLink[] | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deeper question that we need to decide is whether we want to deprecate Location for definitions and ask for providing a DefinitionLink instead. If so we shouldn't or them into the Defintion, but rather list them in the results.
Location is semantically equal to DefinitionLink if originSelectionRange and targetSelectionRange are not provided.
What is your opinion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbaeumer Your suggestion seems reasonable to me. We can add a deprecation notice to Definition
then to try to help discourage people from using it.
It is too bad that we cannot simply extend DefinitionLink
from Location
as the attribute names don't match (and range
in Location
as-is is a little ambiguous compared to the more specific names in DefinitionLink
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear why, but in the VS Code API, @jrieken thought it would not be a good idea to "mix DefinitionLink
into Definition
" as is being done here. See microsoft/vscode#54424
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the above comment as always a good PR. |
@dbaeumer I just noticed Should I update that one too to return |
@rcjsuen let me think about the references request. Spontaneously I would say yes. But we would need a different name then since a references request returning |
@rcjsuen haven't forgotten you. Was busy doing other thing. Will look into this this week. |
@dbaeumer No rush. We all have our own obligations and timelines. microsoft/language-server-protocol#524 has also been quiet, so... shrugs This might get delayed either way as I'll be on/off during the first half of October. |
@rcjsuen we should return However I dislike the name |
@dbaeumer I would say |
@rcjsuen almost all LSP data types do have an URI and non are called links except
Now thinking about it again this doesn't make sense for reference results since there is no origin and no target. There might be two ranges if we want to support this (match range indicating what should be selected and a reveal range). So may be we stick with DefinitionLink. However I am not sure which of these properties should be optional. |
@dbaeumer Wouldn't the origin of a |
@rcjsuen sorry for the long silence. I had a discussion with @jrieken about this lately and we decided to name this Regarding your comment: I am not sure I understand this. Isn't this the whole purpose of the reference result to list all locations where a symbol is referenced. And the position where the cursor is is the input param to the request. If we want to expand this to a valid range then I think this need to go onto the reference result which then might look like this interface ReferenceResult {
range: Range;
locations: Location[];
} Does that make sense ? |
Hi, @dbaeumer. I presume What you suggested with If so, since we are no longer reusing the new type for |
@dbaeumer What should we return here if we are deprecating
|
Signed-off-by: Remy Suen <[email protected]>
Signed-off-by: Remy Suen <[email protected]>
Signed-off-by: Remy Suen <[email protected]>
Yes.
Yes and we should address this in another PR if this is necessary at all.
After thinking about this I would actually not deprecate
and the change the return value of the request to |
@dbaeumer Is the name |
@rcjsuen I would do the same there. Have a type alias for |
Thank you, @dbaeumer. I understand. It is the same as what you mentioned in #346 (comment). I will do some poking at this pull request then... |
I merged this in since I am in the process of adding goto declaration which will reuse LocationLink I am still not sure if we should deprecate Definition or not just keep it. @rcjsuen strong feelings about this. |
I merged this in since I am in the process of adding goto declaration which will reuse LocationLink I am still not sure if we should deprecate Definition or not just keep it. @rcjsuen strong feelings about this. |
2 similar comments
I merged this in since I am in the process of adding goto declaration which will reuse LocationLink I am still not sure if we should deprecate Definition or not just keep it. @rcjsuen strong feelings about this. |
I merged this in since I am in the process of adding goto declaration which will reuse LocationLink I am still not sure if we should deprecate Definition or not just keep it. @rcjsuen strong feelings about this. |
I merged this in since I am in the process of adding goto declaration which will reuse LocationLink I am still not sure if we should deprecate Definition or not just keep it. @rcjsuen strong feelings about this. |
3 similar comments
I merged this in since I am in the process of adding goto declaration which will reuse LocationLink I am still not sure if we should deprecate Definition or not just keep it. @rcjsuen strong feelings about this. |
I merged this in since I am in the process of adding goto declaration which will reuse LocationLink I am still not sure if we should deprecate Definition or not just keep it. @rcjsuen strong feelings about this. |
I merged this in since I am in the process of adding goto declaration which will reuse LocationLink I am still not sure if we should deprecate Definition or not just keep it. @rcjsuen strong feelings about this. |
@dbaeumer Thank you for merging this in, Dirk. Sorry that I've been busy with work and couldn't get the chance to finish things off. :( I don't have a strong feeling about the deprecation of |
I merged this in since I am in the process of adding goto declaration which will reuse LocationLink I am still not sure if we should deprecate Definition or not just keep it. @rcjsuen strong feelings about this. |
I've updated
textDocument/definition
,textDocument/implementation
, andtextDocument/typeDefinition
, to potentially return aDefinitionLink
. This new interface includes metadata about the ranges of both the originating source symbol and the target symbol. This will help provide more context to the user while navigating between different symbols in an editor.For example, instead of simply highlighting a word, the editor can now understand that the source symbol's range extends beyond standard word boundaries. This will allow it to highlight/underline stuff like an entire
java.util.List
in a Javaimport
statement.This implements microsoft/language-server-protocol#524.