[PATCH] D40548: [clangd] Prototyping index support and naive index-based global code completion. WIP

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 28 07:14:13 PST 2017


ilya-biryukov added a comment.

In https://reviews.llvm.org/D40548#937626, @malaperle wrote:

> Hi Eric! As you might know I'm working on persisted indexing. I was wondering which cases needed the index for code completion? Could you give a small example? I thought the AST alone would be sufficient for that. I'll look at this patch more closely a bit later but I can look at what needs to be added in the persisted index interface/data.


Just wanted to chime in to give my perspective on some of the work that's being done here.

The index would allow to implement a project-wide completion (e.g., even if you don't `#include "llvm/ADT/DenseMap.h"`, you'll get completion for `DenseMap` and the #include will be added automatically upon completing an item). 
This is not aiming  trying to have persistent indexes, instead trying to figure out how the right interfaces and plug things into `ClangdServer` properly, so that we can later play around with different implementations of the indexes. (I.e., we'll probably have our internal implementation at Google at some point).

I guess the main thing right now would be to align on how the `SymbolIndex` interface should look like.



================
Comment at: clangd/ClangdLSPServer.h:37
+      llvm::Optional<Path> CompileCommandsDir,
+      std::vector<
+          std::pair<llvm::StringRef, CombinedSymbolIndex::WeightedIndex>>
----------------
Maybe pass a parameter of type `SymbolIndex&` instead of a vector, which is used to create `CombinedSymbolIndex` later?
It seems that `ClangdServer` does not really care about the specific index implementation that's used (nor should it!)

We could have helper methods to conveniently create `CombinedSymbolIndex` from a list of indexes, or even create the default index for clangd. 


https://reviews.llvm.org/D40548





More information about the cfe-commits mailing list