28 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_QUALITY_H 29 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_QUALITY_H 33 #include "clang/Sema/CodeCompleteConsumer.h" 34 #include "llvm/ADT/ArrayRef.h" 35 #include "llvm/ADT/StringRef.h" 45 class CodeCompletionResult;
58 bool Deprecated =
false;
59 bool ReservedName =
false;
61 bool ImplementationDetail =
false;
62 unsigned References = 0;
77 void merge(
const CodeCompletionResult &SemaCCResult);
81 float evaluate()
const;
83 llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
90 bool Forbidden =
false;
92 bool NeedsFixIts =
false;
93 bool InBaseClass =
false;
102 float SemaFileProximityScore = 0;
108 bool SemaSaysInScope =
false;
116 } Scope = GlobalScope;
126 bool IsInstanceMember =
false;
129 bool HadContextType =
false;
131 bool HadSymbolType =
false;
133 bool TypeMatchesPreferred =
false;
135 void merge(
const CodeCompletionResult &
SemaResult);
139 float evaluate()
const;
141 llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
148 template <
typename T,
typename Compare = std::greater<T>>
class TopN {
151 TopN(
size_t N, Compare Greater = Compare())
152 : N(N), Greater(std::move(Greater)) {}
157 bool Dropped =
false;
158 if (Heap.size() >= N) {
160 if (N > 0 && Greater(V, Heap.front())) {
161 std::pop_heap(Heap.begin(), Heap.end(), Greater);
162 Heap.back() = std::move(V);
163 std::push_heap(Heap.begin(), Heap.end(), Greater);
166 Heap.push_back(std::move(V));
167 std::push_heap(Heap.begin(), Heap.end(), Greater);
169 assert(Heap.size() <= N);
170 assert(std::is_heap(Heap.begin(), Heap.end(), Greater));
175 std::vector<value_type>
items() && {
176 std::sort_heap(Heap.begin(), Heap.end(), Greater);
177 assert(Heap.size() <= N);
178 return std::move(Heap);
183 std::vector<value_type> Heap;
189 std::string
sortText(
float Score, llvm::StringRef Tiebreak =
"");
192 uint32_t NumberOfParameters = 0;
193 uint32_t NumberOfOptionalParameters = 0;
194 bool ContainsActiveParameter =
false;
195 CodeCompleteConsumer::OverloadCandidate::CandidateKind
Kind =
196 CodeCompleteConsumer::OverloadCandidate::CandidateKind::CK_Function;
198 llvm::raw_ostream &
operator<<(llvm::raw_ostream &,
204 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANGD_QUALITY_H
Some operations such as code completion produce a set of candidates.
llvm::Optional< llvm::StringRef > SymbolScope
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.
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
These are 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++ -*-===//
Support lookups like FileDistance, but the lookup keys are symbol scopes.
const CodeCompletionResult * SemaResult
std::vector< value_type > items() &&
llvm::raw_ostream & operator<<(llvm::raw_ostream &OS, const CodeCompletion &C)
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.