-
Notifications
You must be signed in to change notification settings - Fork 11
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
Show variable references in call hierarchy #272
Comments
Yes this is what I'd like to have with CDT-LSP plugin too. Both r/w marking and also access to counter in foo call hierarchy. |
Please be aware of that the call hierarchy is (currently) limited to function calls. See this clangd issue |
Yes clangd does not provide that out of the box, still this can be implemented similar to what CDT editor does: it gets all variable references, finds containing functions and then stitches these to form displayed call tree. Would imagine it should be possible with CDT LSP plugin to do similar thing; you probably can store reference to function body for each variable reference and then while scanning for references build a tree going up from that function asking LSP for callers. Detecting if particular variable reference is read or write should be doable too. |
IMO a better solution would be to fix it on the server side. That's what its made and used for. |
Yes LSP server-side implementation is an option too, but looking at referenced clangd issue I do not think it will be available in clangd any time soon. |
With clangd/clangd#1308 now implemented in clangd I see variable references are available in There are a quite a few missing features with how references are displayed compared to CDT Call Hierarchy, for example:
Is it possible to somehow feed these clangd references into CDT call hierarchy view so all those useful features are reused? I see that CDT call hierarchy implementation works off CDT Indexer contents but guess there could be some way to adapt for clangd data. |
I'am afraid that your're right here. All these information come form the indexer. |
Investigated this a bit, here is clangd ticket on function signatures clangd/clangd#915 Another PR about supporting outgoing call hierarchy has this small change https://github.com/llvm/llvm-project/pull/77556/files#diff-6b181f30bc00c60d34c1c294c74c3278276a3df6d72ecdfe49a680a9461656deR1755 allowing modified Regarding more compact tree representation which would fold multiple entries for same parent into single entry with |
Currently CDT editor can show references to variable reads and writes annotated in call hierarchy.
Please add this feature to CDT LSP plugin. Since read and write access to variable is visible in function body provided by LSP it should technically be possible to bind these to function call hierarchies.
Lack of this feature can be partially worked around by wrapping variables into read/write accessor functions, but there are downsides:
The text was updated successfully, but these errors were encountered: