#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_INDEX_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_INDEX_H
+#include "ExpectedTypes.h"
#include "clang/Index/IndexSymbol.h"
#include "clang/Lex/Lexer.h"
#include "llvm/ADT/DenseMap.h"
/// e.g. return type of a function, or type of a variable.
llvm::StringRef ReturnType;
+ /// Raw representation of the OpaqueType of the symbol, used for scoring
+ /// purposes.
+ llvm::StringRef Type;
+
struct IncludeHeaderWithReferences {
IncludeHeaderWithReferences() = default;
CB(S.CompletionSnippetSuffix);
CB(S.Documentation);
CB(S.ReturnType);
+ CB(S.Type);
auto RawCharPointerCB = [&CB](const char *&P) {
llvm::StringRef S(P);
CB(S);
writeVar(Strings.index(Sym.CompletionSnippetSuffix), OS);
writeVar(Strings.index(Sym.Documentation), OS);
writeVar(Strings.index(Sym.ReturnType), OS);
+ writeVar(Strings.index(Sym.Type), OS);
auto WriteInclude = [&](const Symbol::IncludeHeaderWithReferences &Include) {
writeVar(Strings.index(Include.IncludeHeader), OS);
Sym.CompletionSnippetSuffix = Data.consumeString(Strings);
Sym.Documentation = Data.consumeString(Strings);
Sym.ReturnType = Data.consumeString(Strings);
+ Sym.Type = Data.consumeString(Strings);
Sym.IncludeHeaders.resize(Data.consumeVar());
for (auto &I : Sym.IncludeHeaders) {
I.IncludeHeader = Data.consumeString(Strings);
// The current versioning scheme is simple - non-current versions are rejected.
// If you make a breaking change, bump this version number to invalidate stored
// data. Later we may want to support some backward compatibility.
-constexpr static uint32_t Version = 7;
+constexpr static uint32_t Version = 8;
Expected<IndexFileIn> readRIFF(StringRef Data) {
auto RIFF = riff::readFile(Data);
if (!Include.empty())
S.IncludeHeaders.emplace_back(Include, 1);
+ if (S.Flags & Symbol::IndexedForCodeCompletion) {
+ if (auto T = OpaqueType::fromCompletionResult(*ASTCtx, SymbolCompletion))
+ S.Type = T->raw();
+ }
+
S.Origin = Opts.Origin;
if (ND.getAvailability() == AR_Deprecated)
S.Flags |= Symbol::Deprecated;
IO.mapOptional("CompletionSnippetSuffix", Sym.CompletionSnippetSuffix);
IO.mapOptional("Documentation", Sym.Documentation);
IO.mapOptional("ReturnType", Sym.ReturnType);
+ IO.mapOptional("Type", Sym.Type);
IO.mapOptional("IncludeHeaders", Sym.IncludeHeaders);
}
};