clang-tools  7.0.0
Classes | Typedefs | Functions
clang::clangd::dex Namespace Reference

Classes

class  Iterator
 Iterator is the interface for Query Tree node. More...
 
struct  Token
 A Token represents an attribute of a symbol, such as a particular trigram present in the name (used for fuzzy search). More...
 

Typedefs

using DocID = uint32_t
 Symbol position in the list of all index symbols sorted by a pre-computed symbol quality. More...
 
using PostingList = std::vector< DocID >
 Contains sorted sequence of DocIDs all of which belong to symbols matching certain criteria, i.e. More...
 
using PostingListRef = llvm::ArrayRef< DocID >
 Immutable reference to PostingList object. More...
 

Functions

std::vector< DocIDconsume (Iterator &It)
 Exhausts given iterator and returns all processed DocIDs. More...
 
std::unique_ptr< Iteratorcreate (PostingListRef Documents)
 Returns a document iterator over given PostingList. More...
 
std::unique_ptr< IteratorcreateAnd (std::vector< std::unique_ptr< Iterator >> Children)
 Returns AND Iterator which performs the intersection of the PostingLists of its children. More...
 
std::unique_ptr< IteratorcreateOr (std::vector< std::unique_ptr< Iterator >> Children)
 Returns OR Iterator which performs the union of the PostingLists of its children. More...
 
template<typename... Args>
std::unique_ptr< IteratorcreateAnd (Args... args)
 This allows createAnd(create(...), create(...)) syntax. More...
 
template<typename... Args>
std::unique_ptr< IteratorcreateOr (Args... args)
 This allows createOr(create(...), create(...)) syntax. More...
 
template<typename HeadT , typename... TailT>
void populateChildren (std::vector< std::unique_ptr< Iterator >> &Children, HeadT &Head, TailT &... Tail)
 
template<typename HeadT >
void populateChildren (std::vector< std::unique_ptr< Iterator >> &Children, HeadT &Head)
 
std::vector< TokengenerateIdentifierTrigrams (llvm::StringRef Identifier)
 Returns list of unique fuzzy-search trigrams from unqualified symbol. More...
 
std::vector< TokengenerateQueryTrigrams (llvm::StringRef Query)
 Returns list of unique fuzzy-search trigrams given a query. More...
 

Typedef Documentation

◆ DocID

using clang::clangd::dex::DocID = typedef uint32_t

Symbol position in the list of all index symbols sorted by a pre-computed symbol quality.

Definition at line 46 of file Iterator.h.

◆ PostingList

using clang::clangd::dex::PostingList = typedef std::vector<DocID>

Contains sorted sequence of DocIDs all of which belong to symbols matching certain criteria, i.e.

containing a Search Token. PostingLists are values for the inverted index.

Definition at line 50 of file Iterator.h.

◆ PostingListRef

using clang::clangd::dex::PostingListRef = typedef llvm::ArrayRef<DocID>

Immutable reference to PostingList object.

Definition at line 52 of file Iterator.h.

Function Documentation

◆ consume()

std::vector< DocID > clang::clangd::dex::consume ( Iterator It)

Exhausts given iterator and returns all processed DocIDs.

The result contains sorted DocumentIDs.

Definition at line 221 of file Iterator.cpp.

References clang::clangd::dex::Iterator::advance(), clang::clangd::dex::Iterator::peek(), and clang::clangd::dex::Iterator::reachedEnd().

◆ create()

std::unique_ptr< Iterator > clang::clangd::dex::create ( PostingListRef  Documents)

Returns a document iterator over given PostingList.

Definition at line 228 of file Iterator.cpp.

◆ createAnd() [1/2]

template<typename... Args>
std::unique_ptr<Iterator> clang::clangd::dex::createAnd ( Args...  args)

This allows createAnd(create(...), create(...)) syntax.

Definition at line 122 of file Iterator.h.

◆ createAnd() [2/2]

std::unique_ptr< Iterator > clang::clangd::dex::createAnd ( std::vector< std::unique_ptr< Iterator >>  Children)

Returns AND Iterator which performs the intersection of the PostingLists of its children.

Definition at line 233 of file Iterator.cpp.

◆ createOr() [1/2]

template<typename... Args>
std::unique_ptr<Iterator> clang::clangd::dex::createOr ( Args...  args)

This allows createOr(create(...), create(...)) syntax.

Definition at line 129 of file Iterator.h.

◆ createOr() [2/2]

std::unique_ptr< Iterator > clang::clangd::dex::createOr ( std::vector< std::unique_ptr< Iterator >>  Children)

Returns OR Iterator which performs the union of the PostingLists of its children.

Definition at line 238 of file Iterator.cpp.

◆ generateIdentifierTrigrams()

std::vector< Token > clang::clangd::dex::generateIdentifierTrigrams ( llvm::StringRef  Identifier)

Returns list of unique fuzzy-search trigrams from unqualified symbol.

First, given Identifier (unqualified symbol name) is segmented using FuzzyMatch API and lowercased. After segmentation, the following technique is applied for generating trigrams: for each letter or digit in the input string the algorithms looks for the possible next and skip-1-next symbols which can be jumped to during fuzzy matching. Each combination of such three symbols is inserted into the result.

Trigrams can start at any character in the input. Then we can choose to move to the next character, move to the start of the next segment, or skip over a segment.

Note: the returned list of trigrams does not have duplicates, if any trigram belongs to more than one class it is only inserted once.

Definition at line 34 of file Trigram.cpp.

References clang::clangd::calculateRoles(), clang::clangd::Head, and clang::clangd::Tail.

◆ generateQueryTrigrams()

std::vector< Token > clang::clangd::dex::generateQueryTrigrams ( llvm::StringRef  Query)

Returns list of unique fuzzy-search trigrams given a query.

Query is segmented using FuzzyMatch API and downcasted to lowercase. Then, the simplest trigrams - sequences of three consecutive letters and digits are extracted and returned after deduplication.

Definition at line 94 of file Trigram.cpp.

References clang::clangd::calculateRoles(), clang::clangd::Head, and clang::clangd::Tail.

◆ populateChildren() [1/2]

template<typename HeadT , typename... TailT>
void clang::clangd::dex::populateChildren ( std::vector< std::unique_ptr< Iterator >> &  Children,
HeadT &  Head,
TailT &...  Tail 
)

Definition at line 136 of file Iterator.h.

◆ populateChildren() [2/2]

template<typename HeadT >
void clang::clangd::dex::populateChildren ( std::vector< std::unique_ptr< Iterator >> &  Children,
HeadT &  Head 
)

Definition at line 143 of file Iterator.h.