From 5c405241fa0fa7ef72fbcdf9a3eddaecb94e2246 Mon Sep 17 00:00:00 2001 From: ykiko Date: Sat, 2 Nov 2024 14:04:15 +0800 Subject: [PATCH] Improve index format. --- include/Index/Index.h | 14 +++++++------- src/Index/Indexer.cpp | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/Index/Index.h b/include/Index/Index.h index f4f9681c..4dc4c94b 100644 --- a/include/Index/Index.h +++ b/include/Index/Index.h @@ -23,6 +23,8 @@ using String = Array; #undef MAKE_CLANGD_HAPPY +using SymbolID = uint64_t; + struct File { String path; // TODO: some flags. @@ -30,19 +32,17 @@ struct File { Value include; }; -struct SymbolID { - uint64_t value; - String USR; -}; - struct Relation { RelationKind kind; Value location; - Value related; + SymbolID related; }; struct Symbol { - Value id; + /// The hash of this symbol, used for quick lookup. + SymbolID id; + /// The unique identifier of this symbol. + String USR; /// The name of this symbol. String name; /// The document of this symbol. diff --git a/src/Index/Indexer.cpp b/src/Index/Indexer.cpp index 2c81f944..dcce2634 100644 --- a/src/Index/Indexer.cpp +++ b/src/Index/Indexer.cpp @@ -145,7 +145,7 @@ public: static memory::SymbolID generateSymbolID(const clang::Decl* decl) { llvm::SmallString<128> USR; clang::index::generateUSRForDecl(decl, USR); - return memory::SymbolID{llvm::hash_value(USR), USR.str().str()}; + return llvm::hash_value(USR); } /// Add a symbol to the index.