It was previously only indexing the preamble decls. The new
implementation will index both the preamble and the main AST and
report both sets of symbols, preferring the ones from the main AST
whenever the symbol is present in both.
The symbols in the main AST slab always store all information
available in the preamble symbols, possibly adding more,
e.g. definition locations.
Details
Diff Detail
- Repository
- rCTE Clang Tools Extra
- Build Status
Buildable 21774 Build 21774: arc lint + arc unit
Event Timeline
This is still WIP, but wanted to share anyway the progress anyway.
Need to fix the FIXMEs currently added to the code and add tests.
clangd/index/FileIndex.cpp | ||
---|---|---|
60 | We need to be more careful here now that we have to slabs in the list. Should only erase when both are removed. | |
66 | This should definitely be done outside the lock, only the actual swap of the symbol tables should be there. |
As discussed offline, we could instead have a two-layer scheme for dynamic index. A top layer will contain main file symbols, second layer will contain preamble symbols.
clangd/index/FileIndex.h | ||
---|---|---|
70 | Any strong reason to unify the interface (and indexAST)? It seems to me that we do different things on PreambleAST and MainAST:
Therefore, we'd need to set different options for SymbolCollector accordingly. Having a single interface would make the implementation tricky (checking TopLevelDecls to see whether this is a PreambleASt). |
clangd/ClangdServer.cpp | ||
---|---|---|
71 | Maybe provide noop implementations for ParsingCallbacks::onPreambleAST() and ParsingCallbacks::onMainAST by default? | |
clangd/ClangdServer.h | ||
215 | Can we move this into ClangdServer.cpp as an implementation helper? | |
226 | nit: s/FileIdx/DymIdx? (also need to update the comment above) | |
clangd/index/FileIndex.cpp | ||
46 | nit: I'd try avoiding modify the input argument if possible. Maybe set Storage properly according to TopLevelDecls? |
- Move DynamicIndex into ClangdServer.cpp
- Rename FileIdx to DynamicIdx
- Avoid modifying input args
clangd/index/FileIndex.h | ||
---|---|---|
70 | The only reason is to keep the changes to FileIndex minimal in this change. We'll have to change more code to cover those differences, but I'm not sure I have enough context on what's going to be different for this change, a change that will plug xrefs into clangd is probably a better candidate for those. |
Can we move this into ClangdServer.cpp as an implementation helper?