malaperle added a comment.

Sorry for the delay, I'm looking into this now. I actually don't query (or even 
store!) any symbol names in the index interface now, only Occurrences queried 
by USR which is enough for findReferences and findDefinitions. It looks like 
storing names is the main part in this patch. So our two interfaces have almost 
no overlap :) But as I want to implement "Open Workspace Symbol" soon, I'll try 
to add symbol names too and see how it everything fits and make proposals.

Here's how the index "provider" interface looks like now:

  class ClangdIndexDataOccurrence {
  public:
    enum class OccurrenceType {
       OCCURRENCE,
       DEFINITION_OCCURRENCE
     };
  
    virtual OccurrenceType getKind() const = 0;
    virtual std::string getPath() = 0;
    virtual uint32_t getStartOffset(SourceManager &SM) = 0;
    virtual uint32_t getEndOffset(SourceManager &SM) = 0;
  };
  
  ///An occurrence that also has definition with a body that requires additional
  ///locations to keep track of the beginning and end of the body.
  class ClangdIndexDataDefinitionOccurrence : public ClangdIndexDataOccurrence {
    virtual uint32_t getDefStartOffset(SourceManager &SM) = 0;
    virtual uint32_t getDefEndOffset(SourceManager &SM) = 0;
  };
  
  class ClangdIndexDataProvider {
    virtual void foreachOccurrence(const USR& Usr, index::SymbolRoleSet Roles, 
llvm::function_ref<bool(ClangdIndexDataOccurrence&)> Receiver) = 0;
  
    // Those are mainly for debug for now. They dump information about file
    //dependencies.
    virtual void dumpIncludedBy(StringRef File) {}
    virtual void dumpInclusions(StringRef File) {}
  };

https://github.com/MarkZ3/clang-tools-extra/blob/IndexFunctionsPrototype/clangd/index/ClangdIndexDataProvider.h

I've successfully implemented this interface with both ClangdIndexDataStorage 
(the storage solution I worked on) and libIndexStore (patch 
https://reviews.llvm.org/D39050, see also 
https://github.com/MarkZ3/clang-tools-extra/tree/IndexWithLibIndexStore, 
WARNING: proof of concept code only)



================
Comment at: clangd/ASTIndex.h:51
+  llvm::Expected<std::vector<std::string>>
+  getAllOccurrences(llvm::StringRef UID) const override {
+    // FIXME(ioeric): implement this.
----------------
UID == usr?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D40548



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to