20#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_DEX_H
21#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_INDEX_DEX_DEX_H
28#include "llvm/ADT/StringSet.h"
38 template <
typename SymbolRange,
typename RefsRange,
typename RelationsRange>
41 for (
auto &&Sym : Symbols)
42 this->Symbols.push_back(&Sym);
43 for (
auto &&
Ref : Refs)
44 this->Refs.try_emplace(
Ref.first,
Ref.second);
45 for (
auto &&Rel : Relations)
46 this->Relations[std::make_pair(Rel.Subject,
47 static_cast<uint8_t
>(Rel.Predicate))]
48 .push_back(Rel.Object);
52 template <
typename SymbolRange,
typename RefsRange,
typename RelationsRange,
55 Payload &&BackingData,
size_t BackingDataSize)
56 :
Dex(std::forward<
SymbolRange>(Symbols), std::forward<RefsRange>(Refs),
57 std::forward<RelationsRange>(Relations)) {
58 KeepAlive = std::shared_ptr<void>(
59 std::make_shared<Payload>(std::move(BackingData)),
nullptr);
60 this->BackingDataSize = BackingDataSize;
63 template <
typename SymbolRange,
typename RefsRange,
typename RelationsRange,
64 typename FileRange,
typename Payload>
67 size_t BackingDataSize)
68 :
Dex(std::forward<
SymbolRange>(Symbols), std::forward<RefsRange>(Refs),
69 std::forward<RelationsRange>(Relations),
70 std::forward<
Payload>(BackingData), BackingDataSize) {
71 this->Files = std::forward<FileRange>(Files);
72 this->IdxContents = IdxContents;
86 llvm::function_ref<
void(
const Ref &)>
Callback)
const override;
99 std::unique_ptr<Iterator> iterator(
const Token &Tok)
const;
100 std::unique_ptr<Iterator>
101 createFileProximityIterator(llvm::ArrayRef<std::string> ProximityPaths)
const;
102 std::unique_ptr<Iterator>
103 createTypeBoostingIterator(llvm::ArrayRef<std::string> Types)
const;
106 std::vector<const Symbol *> Symbols;
108 std::vector<float> SymbolQuality;
109 llvm::DenseMap<SymbolID, const Symbol *> LookupTable;
116 llvm::DenseMap<Token, PostingList> InvertedIndex;
118 llvm::DenseMap<SymbolID, llvm::ArrayRef<Ref>> Refs;
120 "RelationKind should be of same size as a uint8_t");
121 llvm::DenseMap<std::pair<SymbolID, uint8_t>, std::vector<SymbolID>> Relations;
122 std::shared_ptr<void> KeepAlive;
124 llvm::StringSet<> Files;
128 size_t BackingDataSize = 0;
Symbol index queries consist of specific requirements for the requested symbol, such as high fuzzy ma...
This defines posting list interface: a storage for identifiers of symbols which can be characterized ...
Token objects represent a characteristic of a symbol, which can be used to perform efficient search.
An efficient structure of storing large set of symbol references in memory.
Interface for symbol indexes that can be used for searching or matching symbols among a set of symbol...
An immutable symbol container that stores a set of symbols.
In-memory Dex trigram-based index implementation.
size_t estimateMemoryUsage() const override
Returns estimated size of index (in bytes).
bool refs(const RefsRequest &Req, llvm::function_ref< void(const Ref &)> Callback) const override
Finds all occurrences (e.g.
void relations(const RelationsRequest &Req, llvm::function_ref< void(const SymbolID &, const Symbol &)> Callback) const override
static std::unique_ptr< SymbolIndex > build(SymbolSlab, RefSlab, RelationSlab)
Builds an index from slabs. The index takes ownership of the slab.
Dex(SymbolRange &&Symbols, RefsRange &&Refs, RelationsRange &&Relations, FileRange &&Files, IndexContents IdxContents, Payload &&BackingData, size_t BackingDataSize)
void lookup(const LookupRequest &Req, llvm::function_ref< void(const Symbol &)> Callback) const override
Looks up symbols with any of the given symbol IDs and applies Callback on each matched symbol.
Dex(SymbolRange &&Symbols, RefsRange &&Refs, RelationsRange &&Relations, Payload &&BackingData, size_t BackingDataSize)
llvm::unique_function< IndexContents(llvm::StringRef) const > indexedFiles() const override
Dex(SymbolRange &&Symbols, RefsRange &&Refs, RelationsRange &&Relations)
bool fuzzyFind(const FuzzyFindRequest &Req, llvm::function_ref< void(const Symbol &)> Callback) const override
Constructs iterators over tokens extracted from the query and exhausts it while applying Callback to ...
A Token represents an attribute of a symbol, such as a particular trigram present in the name (used f...
llvm::SmallVector< llvm::StringRef, ProximityURILimit > generateProximityURIs(llvm::StringRef URI)
Returns Search Token for a number of parent directories of given Path.
IndexContents
Describes what data is covered by an index.
llvm::unique_function< void(llvm::Expected< T >)> Callback
A Callback<T> is a void function that accepts Expected<T>.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Represents a symbol occurrence in the source file.
Represents a symbol range where the symbol can potentially have multiple tokens.
The class presents a C++ symbol, e.g.