clang-tools 20.0.0git
Public Member Functions | Static Public Member Functions | List of all members
clang::clangd::dex::Dex Class Reference

In-memory Dex trigram-based index implementation. More...

#include <Dex.h>

Inheritance diagram for clang::clangd::dex::Dex:
Inheritance graph
[legend]

Public Member Functions

template<typename SymbolRange , typename RefsRange , typename RelationsRange >
 Dex (SymbolRange &&Symbols, RefsRange &&Refs, RelationsRange &&Relations)
 
template<typename SymbolRange , typename RefsRange , typename RelationsRange , typename Payload >
 Dex (SymbolRange &&Symbols, RefsRange &&Refs, RelationsRange &&Relations, Payload &&BackingData, size_t BackingDataSize)
 
template<typename SymbolRange , typename RefsRange , typename RelationsRange , typename FileRange , typename Payload >
 Dex (SymbolRange &&Symbols, RefsRange &&Refs, RelationsRange &&Relations, FileRange &&Files, IndexContents IdxContents, Payload &&BackingData, size_t BackingDataSize)
 
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 each symbol in the order of decreasing quality of the matched symbols.
 
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.
 
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
 
llvm::unique_function< IndexContents(llvm::StringRef) const > indexedFiles () const override
 
size_t estimateMemoryUsage () const override
 Returns estimated size of index (in bytes).
 
- Public Member Functions inherited from clang::clangd::SymbolIndex
virtual ~SymbolIndex ()=default
 
virtual bool fuzzyFind (const FuzzyFindRequest &Req, llvm::function_ref< void(const Symbol &)> Callback) const =0
 Matches symbols in the index fuzzily and applies Callback on each matched symbol before returning.
 
virtual void lookup (const LookupRequest &Req, llvm::function_ref< void(const Symbol &)> Callback) const =0
 Looks up symbols with any of the given symbol IDs and applies Callback on each matched symbol.
 
virtual bool refs (const RefsRequest &Req, llvm::function_ref< void(const Ref &)> Callback) const =0
 Finds all occurrences (e.g.
 
virtual void relations (const RelationsRequest &Req, llvm::function_ref< void(const SymbolID &Subject, const Symbol &Object)> Callback) const =0
 Finds all relations (S, P, O) stored in the index such that S is among Req.Subjects and P is Req.Predicate, and invokes Callback for (S, O) in each.
 
virtual IndexedFiles indexedFiles () const =0
 
virtual size_t estimateMemoryUsage () const =0
 Returns estimated size of index (in bytes).
 

Static Public Member Functions

static std::unique_ptr< SymbolIndexbuild (SymbolSlab, RefSlab, RelationSlab)
 Builds an index from slabs. The index takes ownership of the slab.
 

Additional Inherited Members

- Public Types inherited from clang::clangd::SymbolIndex
using IndexedFiles = llvm::unique_function< IndexContents(llvm::StringRef) const >
 Returns function which checks if the specified file was used to build this index or not.
 

Detailed Description

In-memory Dex trigram-based index implementation.

Definition at line 35 of file Dex.h.

Constructor & Destructor Documentation

◆ Dex() [1/3]

template<typename SymbolRange , typename RefsRange , typename RelationsRange >
clang::clangd::dex::Dex::Dex ( SymbolRange &&  Symbols,
RefsRange &&  Refs,
RelationsRange &&  Relations 
)
inline

Definition at line 39 of file Dex.h.

◆ Dex() [2/3]

template<typename SymbolRange , typename RefsRange , typename RelationsRange , typename Payload >
clang::clangd::dex::Dex::Dex ( SymbolRange &&  Symbols,
RefsRange &&  Refs,
RelationsRange &&  Relations,
Payload &&  BackingData,
size_t  BackingDataSize 
)
inline

Definition at line 54 of file Dex.h.

◆ Dex() [3/3]

template<typename SymbolRange , typename RefsRange , typename RelationsRange , typename FileRange , typename Payload >
clang::clangd::dex::Dex::Dex ( SymbolRange &&  Symbols,
RefsRange &&  Refs,
RelationsRange &&  Relations,
FileRange &&  Files,
IndexContents  IdxContents,
Payload &&  BackingData,
size_t  BackingDataSize 
)
inline

Definition at line 65 of file Dex.h.

Member Function Documentation

◆ build()

std::unique_ptr< SymbolIndex > clang::clangd::dex::Dex::build ( SymbolSlab  Symbols,
RefSlab  Refs,
RelationSlab  Rels 
)
static

Builds an index from slabs. The index takes ownership of the slab.

Definition at line 35 of file Dex.cpp.

Referenced by clang::clangd::loadIndex().

◆ estimateMemoryUsage()

size_t clang::clangd::dex::Dex::estimateMemoryUsage ( ) const
overridevirtual

Returns estimated size of index (in bytes).

Implements clang::clangd::SymbolIndex.

Definition at line 345 of file Dex.cpp.

References clang::clangd::Symbols.

◆ fuzzyFind()

bool clang::clangd::dex::Dex::fuzzyFind ( const FuzzyFindRequest Req,
llvm::function_ref< void(const Symbol &)>  Callback 
) const
overridevirtual

◆ indexedFiles()

llvm::unique_function< IndexContents(llvm::StringRef) const > clang::clangd::dex::Dex::indexedFiles ( ) const
overridevirtual

Implements clang::clangd::SymbolIndex.

Definition at line 339 of file Dex.cpp.

References clang::clangd::None.

◆ lookup()

void clang::clangd::dex::Dex::lookup ( const LookupRequest Req,
llvm::function_ref< void(const Symbol &)>  Callback 
) const
overridevirtual

Looks up symbols with any of the given symbol IDs and applies Callback on each matched symbol.

The returned symbol must be deep-copied if it's used outside Callback.

Implements clang::clangd::SymbolIndex.

Definition at line 291 of file Dex.cpp.

References ID, and clang::clangd::LookupRequest::IDs.

◆ refs()

bool clang::clangd::dex::Dex::refs ( const RefsRequest Req,
llvm::function_ref< void(const Ref &)>  Callback 
) const
overridevirtual

Finds all occurrences (e.g.

references, declarations, definitions) of symbols and applies Callback on each result.

Results should be returned in arbitrary order. The returned result must be deep-copied if it's used outside Callback. FIXME: there's no indication which result references which symbol.

Returns true if there will be more results (limited by Req.Limit);

Implements clang::clangd::SymbolIndex.

Definition at line 301 of file Dex.cpp.

References clang::clangd::RefsRequest::Filter, ID, clang::clangd::RefsRequest::IDs, clang::clangd::Ref::Kind, and clang::clangd::RefsRequest::Limit.

◆ relations()

void clang::clangd::dex::Dex::relations ( const RelationsRequest Req,
llvm::function_ref< void(const SymbolID &, const Symbol &)>  Callback 
) const
override

The documentation for this class was generated from the following files: