Go to the documentation of this file.
27 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_QUALITY_H
28 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_QUALITY_H
32 #include "clang/Sema/CodeCompleteConsumer.h"
33 #include "llvm/ADT/ArrayRef.h"
34 #include "llvm/ADT/StringRef.h"
35 #include "llvm/ADT/StringSet.h"
45 class CodeCompletionResult;
77 void merge(
const CodeCompletionResult &SemaCCResult);
83 llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
84 const SymbolQualitySignals &);
145 llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
152 template <
typename T,
typename Compare = std::greater<T>>
class TopN {
155 TopN(
size_t N, Compare Greater = Compare())
156 : N(N), Greater(std::move(Greater)) {}
161 bool Dropped =
false;
162 if (Heap.size() >= N) {
164 if (N > 0 && Greater(V, Heap.front())) {
165 std::pop_heap(Heap.begin(), Heap.end(), Greater);
166 Heap.back() = std::move(V);
167 std::push_heap(Heap.begin(), Heap.end(), Greater);
170 Heap.push_back(std::move(V));
171 std::push_heap(Heap.begin(), Heap.end(), Greater);
173 assert(Heap.size() <= N);
174 assert(std::is_heap(Heap.begin(), Heap.end(), Greater));
179 std::vector<value_type>
items() && {
180 std::sort_heap(Heap.begin(), Heap.end(), Greater);
181 assert(Heap.size() <= N);
182 return std::move(Heap);
187 std::vector<value_type> Heap;
193 std::string
sortText(
float Score, llvm::StringRef Tiebreak =
"");
198 CodeCompleteConsumer::OverloadCandidate::CandidateKind
Kind =
199 CodeCompleteConsumer::OverloadCandidate::CandidateKind::CK_Function;
201 llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
207 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_QUALITY_H
void merge(const CodeCompletionResult &SemaResult)
bool ImplementationDetail
Some operations such as code completion produce a set of candidates.
std::vector< value_type > items() &&
enum clang::clangd::SymbolQualitySignals::SymbolCategory Category
const Symbol * IndexResult
float evaluateSymbolAndRelevance(float SymbolQuality, float SymbolRelevance)
Combine symbol quality and relevance into a single score.
llvm::StringRef SymbolURI
These are used to calculate proximity between the index symbol and the query.
TopN(size_t N, Compare Greater=Compare())
Support lookups like FileDistance, but the lookup keys are symbol scopes.
Attributes of a symbol that affect how much we like it.
uint32_t NumberOfOptionalParameters
bool push(value_type &&V)
TopN<T> is a lossy container that preserves only the "best" N elements.
const CodeCompletionResult * SemaResult
The class presents a C++ symbol, e.g.
uint32_t NumberOfParameters
enum clang::clangd::SymbolRelevanceSignals::QueryType Query
enum clang::clangd::SymbolRelevanceSignals::AccessibleScope Scope
float SemaFileProximityScore
FIXME: unify with index proximity score - signals should be source-independent.
URIDistance * FileProximityMatch
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
bool TypeMatchesPreferred
ScopeDistance * ScopeProximityMatch
llvm::StringRef Name
The name of the symbol (for ContextWords). Must be explicitly assigned.
llvm::Optional< float > Score
bool NeedsFixIts
Whether fixits needs to be applied for that completion or not.
std::string sortText(float Score, llvm::StringRef Name)
Returns a string that sorts in the same order as (-Score, Tiebreak), for LSP.
llvm::Optional< llvm::StringRef > SymbolScope
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
llvm::StringSet * ContextWords
Lowercase words relevant to the context (e.g. near the completion point).
CodeCompleteConsumer::OverloadCandidate::CandidateKind Kind
float NameMatch
0-1+ fuzzy-match score for unqualified name. Must be explicitly assigned.
Attributes of a symbol-query pair that affect how much we like it.
A context is an immutable container for per-request data that must be propagated through layers that ...
void merge(const CodeCompletionResult &SemaCCResult)