[clangd-dev] Implementing symbols in document (textDocument/documentSymbol)

Marc-André Laperle via clangd-dev clangd-dev at lists.llvm.org
Wed May 30 14:23:51 PDT 2018


I've been thinking about how to implement the "symbols in document" feature. I think it would make a lot of sense to reuse the in-memory index for this. One problem is that there is no current way to do "file-major" queries, i.e. get all symbols within one file.

I see a few options:
1) Change the YAML format, in-memory model and index interface to allow file-major queries. This is the most work. On the other hand, I don't think it's worth investing a ton of effort in the YAML format.
2) Change only the "in-memory" index and interface for file-major queries. Not sure how feasible that is, but perhaps a good solution.
3) Run a new SymbolCollector every time on textDocument/documentSymbol, only on the needed file. That way there is a lot less symbol to filter out (only need the ones in the main file).
4) Iterate through all symbols, keep only the ones in the correct file. This is basically workspace/symbol with another "file" parameter. This is likely the least amount of work.

I tried #4 and it seems to work fine but is probably not the most scalable so I am not sure how acceptable that is as an interim implementation.

Let me know what you think,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/clangd-dev/attachments/20180530/9f3ed4e0/attachment.html>

More information about the clangd-dev mailing list