27 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_QUALITY_H 28 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_QUALITY_H 29 #include "clang/Sema/CodeCompleteConsumer.h" 30 #include "llvm/ADT/ArrayRef.h" 31 #include "llvm/ADT/StringRef.h" 39 class CodeCompletionResult;
50 bool Deprecated =
false;
51 bool ReservedName =
false;
53 unsigned References = 0;
66 void merge(
const CodeCompletionResult &SemaCCResult);
70 float evaluate()
const;
72 llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
79 bool Forbidden =
false;
88 float SemaProximityScore = 0;
96 } Scope = GlobalScope;
106 bool IsInstanceMember =
false;
108 void merge(
const CodeCompletionResult &
SemaResult);
112 float evaluate()
const;
114 llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
121 template <
typename T,
typename Compare = std::greater<T>>
class TopN {
124 TopN(
size_t N, Compare Greater = Compare())
125 : N(N), Greater(std::move(Greater)) {}
130 bool Dropped =
false;
131 if (Heap.size() >= N) {
133 if (N > 0 && Greater(V, Heap.front())) {
134 std::pop_heap(Heap.begin(), Heap.end(), Greater);
135 Heap.back() = std::move(V);
136 std::push_heap(Heap.begin(), Heap.end(), Greater);
139 Heap.push_back(std::move(V));
140 std::push_heap(Heap.begin(), Heap.end(), Greater);
142 assert(Heap.size() <= N);
143 assert(std::is_heap(Heap.begin(), Heap.end(), Greater));
148 std::vector<value_type>
items() && {
149 std::sort_heap(Heap.begin(), Heap.end(), Greater);
150 assert(Heap.size() <= N);
151 return std::move(Heap);
156 std::vector<value_type> Heap;
162 std::string
sortText(
float Score, llvm::StringRef Tiebreak =
"");
Some operations such as code completion produce a set of candidates.
TopN(size_t N, Compare Greater=Compare())
std::string sortText(float Score, llvm::StringRef Name)
Returns a string that sorts in the same order as (-Score, Tiebreak), for LSP.
Attributes of a symbol that affect how much we like it.
llvm::raw_ostream & operator<<(llvm::raw_ostream &, const SymbolRelevanceSignals &)
bool push(value_type &&V)
const Symbol * IndexResult
A context is an immutable container for per-request data that must be propagated through layers that ...
llvm::StringRef SymbolURI
This is used to calculate proximity between the index symbol and the query.
float evaluateSymbolAndRelevance(float SymbolQuality, float SymbolRelevance)
Combine symbol quality and relevance into a single score.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
const CodeCompletionResult * SemaResult
std::vector< value_type > items() &&
Attributes of a symbol-query pair that affect how much we like it.
TopN<T> is a lossy container that preserves only the "best" N elements.