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>
40 bool SupportContainedRefs)
42 for (
auto &&Sym : Symbols)
43 this->Symbols.push_back(&Sym);
44 for (
auto &&
Ref : Refs)
45 this->Refs.try_emplace(
Ref.first,
Ref.second);
46 for (
auto &&Rel : Relations) {
47 this->Relations[std::make_pair(Rel.Subject,
48 static_cast<uint8_t
>(Rel.Predicate))]
49 .push_back(Rel.Object);
51 this->ReverseRelations[std::make_pair(Rel.Object,
static_cast<uint8_t
>(
53 .push_back(Rel.Subject);
56 buildIndex(SupportContainedRefs);
59 template <
typename SymbolRange,
typename RefsRange,
typename RelationsRange,
62 Payload &&BackingData,
size_t BackingDataSize,
bool SupportContainedRefs)
63 :
Dex(std::forward<
SymbolRange>(Symbols), std::forward<RefsRange>(Refs),
64 std::forward<RelationsRange>(Relations), SupportContainedRefs) {
65 KeepAlive = std::shared_ptr<void>(
66 std::make_shared<Payload>(std::move(BackingData)),
nullptr);
67 this->BackingDataSize = BackingDataSize;
70 template <
typename SymbolRange,
typename RefsRange,
typename RelationsRange,
71 typename FileRange,
typename Payload>
73 FileRange &&Files,
IndexContents IdxContents, Payload &&BackingData,
74 size_t BackingDataSize,
bool SupportContainedRefs)
75 :
Dex(std::forward<
SymbolRange>(Symbols), std::forward<RefsRange>(Refs),
76 std::forward<RelationsRange>(Relations),
77 std::forward<Payload>(BackingData), BackingDataSize,
78 SupportContainedRefs) {
79 this->Files = std::forward<FileRange>(Files);
80 this->IdxContents = IdxContents;
85 bool SupportContainedRefs);
95 llvm::function_ref<
void(
const Ref &)>
Callback)
const override;
124 ContainedRefsResult containedRefsResult()
const {
129 void buildIndex(
bool EnableOutgoingCalls);
130 llvm::iterator_range<std::vector<RevRef>::const_iterator>
131 lookupRevRefs(
const SymbolID &Container)
const;
132 std::unique_ptr<Iterator> iterator(
const Token &Tok)
const;
133 std::unique_ptr<Iterator>
134 createFileProximityIterator(llvm::ArrayRef<std::string> ProximityPaths)
const;
135 std::unique_ptr<Iterator>
136 createTypeBoostingIterator(llvm::ArrayRef<std::string> Types)
const;
139 std::vector<const Symbol *> Symbols;
141 std::vector<float> SymbolQuality;
142 llvm::DenseMap<SymbolID, const Symbol *> LookupTable;
149 llvm::DenseMap<Token, PostingList> InvertedIndex;
151 llvm::DenseMap<SymbolID, llvm::ArrayRef<Ref>> Refs;
152 std::vector<RevRef> RevRefs;
154 "RelationKind should be of same size as a uint8_t");
155 llvm::DenseMap<std::pair<SymbolID, uint8_t>, std::vector<SymbolID>> Relations;
157 llvm::DenseMap<std::pair<SymbolID, uint8_t>, std::vector<SymbolID>>
159 std::shared_ptr<void> KeepAlive;
161 llvm::StringSet<> Files;
167 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 ...
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.
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
Dex(SymbolRange &&Symbols, RefsRange &&Refs, RelationsRange &&Relations, bool SupportContainedRefs)
static std::unique_ptr< SymbolIndex > build(SymbolSlab, RefSlab, RelationSlab, bool SupportContainedRefs)
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, bool SupportContainedRefs)
void reverseRelations(const RelationsRequest &, llvm::function_ref< void(const SymbolID &, const Symbol &)>) const override
bool containedRefs(const ContainedRefsRequest &Req, llvm::function_ref< void(const ContainedRefsResult &)> Callback) const override
Find all symbols that are referenced by a symbol and apply Callback on each result.
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.
llvm::unique_function< IndexContents(llvm::StringRef) const > indexedFiles() const override
Dex(SymbolRange &&Symbols, RefsRange &&Refs, RelationsRange &&Relations, Payload &&BackingData, size_t BackingDataSize, bool SupportContainedRefs)
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 ...
Token objects represent a characteristic of a symbol, which can be used to perform efficient search.
llvm::SmallVector< llvm::StringRef, ProximityURILimit > generateProximityURIs(llvm::StringRef URI)
Returns Search Token for a number of parent directories of given Path.
FIXME: Skip testing on windows temporarily due to the different escaping code mode.
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.
SymbolLocation Location
The source location where the symbol is named.
Represents a symbol range where the symbol can potentially have multiple tokens.
The class presents a C++ symbol, e.g.