-
Notifications
You must be signed in to change notification settings - Fork 324
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
Add proposed textDocument/callHierarchy
extension
#420
Conversation
1cec34b
to
eefe165
Compare
A call hierarchy is IMO very similar to a type hierarchy. I can be expanded in two ways and we should be able to resolve the hierarchy lazy. So I would mimic what I have suggested for the TypeHierarchy here: #346 (comment) |
@dbaeumer, thanks for the feedback! So, you suggest to have two separate request types for the lazy loading? In the beginning to send |
Yes. That is the idea. |
eefe165
to
9335406
Compare
@dbaeumer, I have updated the proposal. Please have a look! |
9335406
to
9a41301
Compare
…y protocol. Links: microsoft/language-server-protocol#468 microsoft/vscode-languageserver-node#420 Signed-off-by: Alex Tugarev <[email protected]>
… protocol. Links: microsoft/language-server-protocol#468 microsoft/vscode-languageserver-node#420 Signed-off-by: Alex Tugarev <[email protected]>
textDocument/calls
extensiontextDocument/callHierarchy
extension
9a41301
to
c1b38ef
Compare
… protocol. Links: microsoft/language-server-protocol#468 microsoft/vscode-languageserver-node#420 Signed-off-by: Alex Tugarev <[email protected]>
c1b38ef
to
b6887d8
Compare
I have updated the PR again and added a separate |
… protocol. Links: microsoft/language-server-protocol#468 microsoft/vscode-languageserver-node#420 Signed-off-by: Alex Tugarev <[email protected]>
@AlexTugarev the big change that happend (see comment #420 (comment) and #420 (comment)) is that we moved from a vertex based result to an edge based result. The cost is that the result contains duplicate information (e.g. the |
@dbaeumer, thanks! This sounds good. I'll update this proposal shortly. |
@tsmaeder I allowed |
@aeschli, which part would be responsible to check if there is only a single reference (call) or a definition in that |
@AlexTugarev When the symbol at the position (or range) resolves in multiple definitions, the provideCalls result will contain calls to/from all of the definitions. The UI can decide to group the results under multiple root nodes (one for each definition). Position is probably also good enough. The definition provider and the reference provider also just take a position. I added it for convenience, and future considerations: There might be cases where a range would allow the user to be more specific on what to look for. E.g. in a reference like List one could say that selecting |
@AlexTugarev we plan to ship a new stable version of VS Code end of this week. So if you have something that corresponds to the new API I could create a new next version with the call hierarchy support as proposed so that people can try it out. |
@dbaeumer, that sounds good. I'll update it this PR tonight. |
@AlexTugarev ping me when the changes are available |
ca78873
to
89b4ffa
Compare
Adds the `textDocument/callHierarchy` request sent from the client to the server to request the call hierarchy for a symbol at the given text document position. LSP issue: language-server-protocol#468 Signed-off-by: Alex Tugarev <[email protected]>
89b4ffa
to
df4fb3b
Compare
@dbaeumer, please have a look. I'm not sure about the |
On the server part we usually register a request handler as long as the protocol is proposed. I will merge the PR in and will then prepare a new next version with the selection range proposal. |
Thanks @dbaeumer! |
I think the proposal has several deficiency that require further improvement. Comments inlined below: export interface CallHierarchyCall {
// If there are multiple `CallHierarchyCall` elements with the same `from`, will the `from: CallHierarchySymbol` be duplicated multiple times?
range: Range;
from: CallHierarchySymbol;
to: CallHierarchySymbol;
}
result: CallHierarchyCall[] | null
export interface CallHierarchySymbol {
// There is no id field. `name` or `detail` may not identify a specific target that can be suitable for further requests (e.g. node expansion).
name: string;
detail?: string;
kind: SymbolKind;
uri: string;
range: Range;
selectionRange: Range;
} In ccls (https://github.com/MaskRay/ccls/blob/master/src/messages/ccls_call.cc), we use: struct Out_cclsCall {
Usr usr; // language server specific
std::string id;
std::string_view name;
Location location;
CallType callType = CallType::Direct;
int numChildren;
// Empty if the |levels| limit is reached.
std::vector<Out_cclsCall> children;
}; The method |
@MaskRay can you please open a GitHub issue to discuss this. |
Does this being merged mean the extension is now an official part of LSP? Or are there additional steps required for that to happen? |
@HighCommander4 I wouldn't consider anything final until microsoft/language-server-protocol#468 has been closed. I think people look to the website for the final say in general. |
Thanks. Do you know what is needed for that to happen? Is it just a matter of someone writing a PR? Another question: is the proposed spec (the |
|
As a consequence of it not being finalized yet, it's important to understand that it's still subject to change. There continue to be discussions on how best to finalize this API, but since this PR is merged this is probably not the best place. Maybe create a new issue. Also, while there is nothing to actually dictate this, it is generally the case that the LSP API is closely aligned with the VS Code API, so you can see microsoft/vscode#70231 for how the API may change as well. |
This PR proposes a
textDocument/callHierarchy
request sent from the client to the server to request the call hierarchy for a symbol at the given text document position.A prototype implementation for TypeScript LS is implemented in typescript-language-server/typescript-language-server#98.
Related LSP issue: microsoft/language-server-protocol#468