clang-tools 20.0.0git
|
Attributes of a symbol-query pair that affect how much we like it. More...
#include <Quality.h>
Classes | |
struct | DerivedSignals |
Set of derived signals computed by calculateDerivedSignals(). More... | |
Public Types | |
enum | AccessibleScope { FunctionScope , ClassScope , FileScope , GlobalScope } |
enum | QueryType { CodeComplete , Generic } |
Public Member Functions | |
DerivedSignals | calculateDerivedSignals () const |
void | merge (const CodeCompletionResult &SemaResult) |
void | merge (const Symbol &IndexResult) |
void | computeASTSignals (const CodeCompletionResult &SemaResult) |
float | evaluateHeuristics () const |
Public Attributes | |
llvm::StringRef | Name |
The name of the symbol (for ContextWords). Must be explicitly assigned. | |
float | NameMatch = 1 |
0-1+ fuzzy-match score for unqualified name. Must be explicitly assigned. | |
llvm::StringSet * | ContextWords = nullptr |
Lowercase words relevant to the context (e.g. near the completion point). | |
bool | Forbidden = false |
bool | NeedsFixIts = false |
Whether fixits needs to be applied for that completion or not. | |
bool | InBaseClass = false |
URIDistance * | FileProximityMatch = nullptr |
llvm::StringRef | SymbolURI |
These are used to calculate proximity between the index symbol and the query. | |
float | SemaFileProximityScore = 0 |
FIXME: unify with index proximity score - signals should be source-independent. | |
ScopeDistance * | ScopeProximityMatch = nullptr |
std::optional< llvm::StringRef > | SymbolScope |
bool | SemaSaysInScope = false |
enum clang::clangd::SymbolRelevanceSignals::AccessibleScope | Scope = GlobalScope |
enum clang::clangd::SymbolRelevanceSignals::QueryType | Query = Generic |
CodeCompletionContext::Kind | Context = CodeCompletionContext::CCC_Other |
bool | IsInstanceMember = false |
bool | HadContextType = false |
bool | HadSymbolType = false |
bool | TypeMatchesPreferred = false |
unsigned | FilterLength = 0 |
Length of the unqualified partial name of Symbol typed in CompletionPrefix. | |
const ASTSignals * | MainFileSignals = nullptr |
unsigned | MainFileRefs = 0 |
Number of references to the candidate in the main file. | |
unsigned | ScopeRefsInFile = 0 |
Number of unique symbols in the main file which belongs to candidate's namespace. | |
Attributes of a symbol-query pair that affect how much we like it.
SymbolRelevanceSignals::DerivedSignals clang::clangd::SymbolRelevanceSignals::calculateDerivedSignals | ( | ) | const |
Definition at line 382 of file Quality.cpp.
References ContextWords, clang::clangd::ScopeDistance::distance(), clang::clangd::URIDistance::distance(), clang::clangd::SymbolRelevanceSignals::DerivedSignals::FileProximityDistance, FileProximityMatch, Name, clang::clangd::SymbolRelevanceSignals::DerivedSignals::NameMatchesContext, clang::clangd::SymbolRelevanceSignals::DerivedSignals::ScopeProximityDistance, ScopeProximityMatch, SymbolScope, SymbolURI, clang::clangd::FileDistance::Unreachable, and clang::clangd::wordMatching().
Referenced by evaluateHeuristics().
void clang::clangd::SymbolRelevanceSignals::computeASTSignals | ( | const CodeCompletionResult & | SemaResult | ) |
Definition at line 300 of file Quality.cpp.
References clang::clangd::getSymbolID(), clang::clangd::hasUnstableLinkage(), ID, MainFileRefs, MainFileSignals, clang::clangd::printNamespaceScope(), clang::clangd::ASTSignals::ReferencedSymbols, clang::clangd::ASTSignals::RelatedNamespaces, Scope, ScopeRefsInFile, and SemaResult.
Referenced by merge().
float clang::clangd::SymbolRelevanceSignals::evaluateHeuristics | ( | ) | const |
Definition at line 396 of file Quality.cpp.
References calculateDerivedSignals(), ClassScope, CodeComplete, clang::clangd::SymbolRelevanceSignals::DerivedSignals::FileProximityDistance, clang::clangd::fileProximityScore(), FileScope, Forbidden, FunctionScope, GlobalScope, InBaseClass, IsInstanceMember, MainFileRefs, NameMatch, clang::clangd::SymbolRelevanceSignals::DerivedSignals::NameMatchesContext, NeedsFixIts, Query, Scope, clang::clangd::SymbolRelevanceSignals::DerivedSignals::ScopeProximityDistance, ScopeProximityMatch, clang::clangd::scopeProximityScore(), ScopeRefsInFile, Score, SemaFileProximityScore, SemaSaysInScope, and TypeMatchesPreferred.
Referenced by clang::clangd::locateSymbolTextually().
void clang::clangd::SymbolRelevanceSignals::merge | ( | const CodeCompletionResult & | SemaResult | ) |
Definition at line 326 of file Quality.cpp.
References computeASTSignals(), clang::clangd::computeScope(), Forbidden, clang::clangd::hasDeclInMainFile(), clang::clangd::hasUsingDeclInMainFile(), InBaseClass, clang::clangd::isInstanceMember(), IsInstanceMember, NeedsFixIts, Scope, SemaFileProximityScore, and SemaSaysInScope.
Referenced by clang::clangd::locateSymbolTextually().
void clang::clangd::SymbolRelevanceSignals::merge | ( | const Symbol & | IndexResult | ) |
Definition at line 283 of file Quality.cpp.
References FileScope, IndexResult, clang::clangd::isInstanceMember(), IsInstanceMember, MainFileRefs, MainFileSignals, clang::clangd::ASTSignals::ReferencedSymbols, clang::clangd::ASTSignals::RelatedNamespaces, Scope, ScopeRefsInFile, SymbolScope, SymbolURI, and clang::clangd::Symbol::VisibleOutsideFile.
CodeCompletionContext::Kind clang::clangd::SymbolRelevanceSignals::Context = CodeCompletionContext::CCC_Other |
llvm::StringSet* clang::clangd::SymbolRelevanceSignals::ContextWords = nullptr |
Lowercase words relevant to the context (e.g. near the completion point).
Definition at line 92 of file Quality.h.
Referenced by calculateDerivedSignals().
URIDistance* clang::clangd::SymbolRelevanceSignals::FileProximityMatch = nullptr |
Definition at line 98 of file Quality.h.
Referenced by calculateDerivedSignals().
unsigned clang::clangd::SymbolRelevanceSignals::FilterLength = 0 |
Length of the unqualified partial name of Symbol typed in CompletionPrefix.
bool clang::clangd::SymbolRelevanceSignals::Forbidden = false |
Definition at line 93 of file Quality.h.
Referenced by evaluateHeuristics(), and merge().
bool clang::clangd::SymbolRelevanceSignals::HadContextType = false |
bool clang::clangd::SymbolRelevanceSignals::HadSymbolType = false |
bool clang::clangd::SymbolRelevanceSignals::InBaseClass = false |
Definition at line 96 of file Quality.h.
Referenced by evaluateHeuristics(), and merge().
bool clang::clangd::SymbolRelevanceSignals::IsInstanceMember = false |
Definition at line 129 of file Quality.h.
Referenced by evaluateHeuristics(), and merge().
unsigned clang::clangd::SymbolRelevanceSignals::MainFileRefs = 0 |
Number of references to the candidate in the main file.
Definition at line 144 of file Quality.h.
Referenced by computeASTSignals(), evaluateHeuristics(), and merge().
const ASTSignals* clang::clangd::SymbolRelevanceSignals::MainFileSignals = nullptr |
Definition at line 142 of file Quality.h.
Referenced by computeASTSignals(), and merge().
llvm::StringRef clang::clangd::SymbolRelevanceSignals::Name |
The name of the symbol (for ContextWords). Must be explicitly assigned.
Definition at line 88 of file Quality.h.
Referenced by calculateDerivedSignals(), clang::clangd::getWorkspaceSymbols(), and clang::clangd::locateSymbolTextually().
float clang::clangd::SymbolRelevanceSignals::NameMatch = 1 |
0-1+ fuzzy-match score for unqualified name. Must be explicitly assigned.
Definition at line 90 of file Quality.h.
Referenced by evaluateHeuristics().
bool clang::clangd::SymbolRelevanceSignals::NeedsFixIts = false |
Whether fixits needs to be applied for that completion or not.
Definition at line 95 of file Quality.h.
Referenced by evaluateHeuristics(), and merge().
enum clang::clangd::SymbolRelevanceSignals::QueryType clang::clangd::SymbolRelevanceSignals::Query = Generic |
Referenced by evaluateHeuristics(), and clang::clangd::locateSymbolTextually().
enum clang::clangd::SymbolRelevanceSignals::AccessibleScope clang::clangd::SymbolRelevanceSignals::Scope = GlobalScope |
Referenced by computeASTSignals(), evaluateHeuristics(), and merge().
ScopeDistance* clang::clangd::SymbolRelevanceSignals::ScopeProximityMatch = nullptr |
Definition at line 108 of file Quality.h.
Referenced by calculateDerivedSignals(), and evaluateHeuristics().
unsigned clang::clangd::SymbolRelevanceSignals::ScopeRefsInFile = 0 |
Number of unique symbols in the main file which belongs to candidate's namespace.
This indicates how relevant the namespace is in the current file.
Definition at line 148 of file Quality.h.
Referenced by computeASTSignals(), evaluateHeuristics(), and merge().
float clang::clangd::SymbolRelevanceSignals::SemaFileProximityScore = 0 |
FIXME: unify with index proximity score - signals should be source-independent.
Proximity between best declaration and the query. [0-1], 1 is closest.
Definition at line 105 of file Quality.h.
Referenced by evaluateHeuristics(), and merge().
bool clang::clangd::SymbolRelevanceSignals::SemaSaysInScope = false |
Definition at line 111 of file Quality.h.
Referenced by evaluateHeuristics(), and merge().
std::optional<llvm::StringRef> clang::clangd::SymbolRelevanceSignals::SymbolScope |
Definition at line 109 of file Quality.h.
Referenced by calculateDerivedSignals(), and merge().
llvm::StringRef clang::clangd::SymbolRelevanceSignals::SymbolURI |
These are used to calculate proximity between the index symbol and the query.
Definition at line 101 of file Quality.h.
Referenced by calculateDerivedSignals(), and merge().
bool clang::clangd::SymbolRelevanceSignals::TypeMatchesPreferred = false |
Definition at line 136 of file Quality.h.
Referenced by evaluateHeuristics().