clang-tools 19.0.0git
Classes | Public Types | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
clang::clangd::CodeCompleteOptions Struct Reference

#include <CodeComplete.h>

Classes

struct  IncludeInsertionIndicator
 A visual indicator to prepend to the completion label to indicate whether completion result would trigger an #include insertion or not. More...
 

Public Types

enum  IncludeInsertion { IWYU , NeverInsert }
 
enum  CodeCompletionParse { AlwaysParse , ParseIfReady , NeverParse }
 Whether to use the clang parser, or fallback to text-based completion (using identifiers in the current file and symbol indexes). More...
 
enum  CodeCompletionRankingModel { Heuristics , DecisionForest }
 Model to use for ranking code completion candidates. More...
 

Public Member Functions

clang::CodeCompleteOptions getClangCompleteOpts () const
 Returns options that can be passed to clang's completion engine.
 

Public Attributes

bool EnableSnippets = false
 When true, completion items will contain expandable code snippets in completion (e.g.
 
bool IncludeIneligibleResults = false
 Include results that are not legal completions in the current context.
 
std::optional< bool > BundleOverloads
 Combine overloads into a single completion item where possible.
 
size_t Limit = 0
 Limit the number of results returned (0 means no limit).
 
MarkupKind DocumentationFormat = MarkupKind::PlainText
 Whether to present doc comments as plain-text or markdown.
 
enum clang::clangd::CodeCompleteOptions::IncludeInsertion InsertIncludes = IncludeInsertion::IWYU
 
bool ImportInsertions = false
 Whether include insertions for Objective-C code should use #import instead of #include.
 
struct clang::clangd::CodeCompleteOptions::IncludeInsertionIndicator IncludeIndicator
 
bool ShowOrigins = false
 Expose origins of completion items in the label (for debugging).
 
const SymbolIndexIndex = nullptr
 If Index is set, it is used to augment the code completion results.
 
const ASTSignalsMainFileSignals = nullptr
 
bool IncludeFixIts = false
 Include completions that require small corrections, e.g.
 
bool EnableFunctionArgSnippets = true
 Whether to generate snippets for function arguments on code-completion.
 
bool AllScopes = false
 Whether to include index symbols that are not defined in the scopes visible from the code completion point.
 
enum clang::clangd::CodeCompleteOptions::CodeCompletionParse RunParser = ParseIfReady
 
std::function< void(const CodeCompletion &, const SymbolQualitySignals &, const SymbolRelevanceSignals &, float Score)> RecordCCResult
 Callback invoked on all CompletionCandidate after they are scored and before they are ranked (by -Score).
 
CodeCompletionRankingModel RankingModel = DefaultRankingModel
 
std::function< DecisionForestScores(const SymbolQualitySignals &, const SymbolRelevanceSignals &, float Base)> DecisionForestScorer = &evaluateDecisionForest
 Callback used to score a CompletionCandidate if DecisionForest ranking model is enabled.
 
float DecisionForestBase = 1.3f
 Weight for combining NameMatch and Prediction of DecisionForest.
 

Static Public Attributes

static const CodeCompletionRankingModel DefaultRankingModel = CodeCompleteOptions::Heuristics
 

Detailed Description

Definition at line 42 of file CodeComplete.h.

Member Enumeration Documentation

◆ CodeCompletionParse

Whether to use the clang parser, or fallback to text-based completion (using identifiers in the current file and symbol indexes).

Enumerator
AlwaysParse 

Block until we can run the parser (e.g.

preamble is built). Return an error if this fails.

ParseIfReady 

Run the parser if inputs (preamble) are ready.

Otherwise, use text-based completion.

NeverParse 

Always use text-based completion.

Definition at line 112 of file CodeComplete.h.

◆ CodeCompletionRankingModel

Model to use for ranking code completion candidates.

Enumerator
Heuristics 
DecisionForest 

Definition at line 134 of file CodeComplete.h.

◆ IncludeInsertion

Enumerator
IWYU 
NeverInsert 

Definition at line 68 of file CodeComplete.h.

Member Function Documentation

◆ getClangCompleteOpts()

clang::CodeCompleteOptions clang::clangd::CodeCompleteOptions::getClangCompleteOpts ( ) const

Returns options that can be passed to clang's completion engine.

Definition at line 2111 of file CodeComplete.cpp.

Member Data Documentation

◆ AllScopes

bool clang::clangd::CodeCompleteOptions::AllScopes = false

Whether to include index symbols that are not defined in the scopes visible from the code completion point.

This applies in contexts without explicit scope qualifiers.

Such completions can insert scope qualifiers.

Definition at line 108 of file CodeComplete.h.

◆ BundleOverloads

std::optional<bool> clang::clangd::CodeCompleteOptions::BundleOverloads

Combine overloads into a single completion item where possible.

If none, the implementation may choose an appropriate behavior. (In practice, ClangdLSPServer enables bundling if the client claims to supports signature help).

Definition at line 59 of file CodeComplete.h.

Referenced by clang::clangd::clangdMain().

◆ DecisionForestBase

float clang::clangd::CodeCompleteOptions::DecisionForestBase = 1.3f

Weight for combining NameMatch and Prediction of DecisionForest.

CompletionScore is NameMatch * pow(Base, Prediction). The optimal value of Base largely depends on the semantics of the model and prediction score (e.g. algorithm used during training, number of trees, etc.). Usually if the range of Prediction is [-20, 20] then a Base in [1.2, 1.7] works fine. Semantics: E.g. For Base = 1.3, if the Prediction score reduces by 2.6 points then completion score reduces by 50% or 1.3^(-2.6).

Definition at line 156 of file CodeComplete.h.

◆ DecisionForestScorer

std::function<DecisionForestScores( const SymbolQualitySignals &, const SymbolRelevanceSignals &, float Base)> clang::clangd::CodeCompleteOptions::DecisionForestScorer = &evaluateDecisionForest

Callback used to score a CompletionCandidate if DecisionForest ranking model is enabled.

This allows us to inject experimental models and compare them with baseline model using A/B testing.

Definition at line 147 of file CodeComplete.h.

◆ DefaultRankingModel

const CodeCompleteOptions::CodeCompletionRankingModel clang::clangd::CodeCompleteOptions::DefaultRankingModel = CodeCompleteOptions::Heuristics
static

Definition at line 138 of file CodeComplete.h.

◆ DocumentationFormat

MarkupKind clang::clangd::CodeCompleteOptions::DocumentationFormat = MarkupKind::PlainText

Whether to present doc comments as plain-text or markdown.

Definition at line 66 of file CodeComplete.h.

◆ EnableFunctionArgSnippets

bool clang::clangd::CodeCompleteOptions::EnableFunctionArgSnippets = true

Whether to generate snippets for function arguments on code-completion.

Needs snippets to be enabled as well.

Definition at line 101 of file CodeComplete.h.

Referenced by clang::clangd::clangdMain().

◆ EnableSnippets

bool clang::clangd::CodeCompleteOptions::EnableSnippets = false

When true, completion items will contain expandable code snippets in completion (e.g.

return ${1:expression} or `foo(${1:int a}, ${2:int b})).

Definition at line 49 of file CodeComplete.h.

Referenced by LLVMFuzzerTestOneInput().

◆ ImportInsertions

bool clang::clangd::CodeCompleteOptions::ImportInsertions = false

Whether include insertions for Objective-C code should use #import instead of #include.

Definition at line 75 of file CodeComplete.h.

Referenced by clang::clangd::clangdMain().

◆ IncludeFixIts

bool clang::clangd::CodeCompleteOptions::IncludeFixIts = false

Include completions that require small corrections, e.g.

change '.' to '->' on member access etc.

Definition at line 97 of file CodeComplete.h.

◆ IncludeIndicator

struct clang::clangd::CodeCompleteOptions::IncludeInsertionIndicator clang::clangd::CodeCompleteOptions::IncludeIndicator

◆ IncludeIneligibleResults

bool clang::clangd::CodeCompleteOptions::IncludeIneligibleResults = false

Include results that are not legal completions in the current context.

For example, private members are usually inaccessible.

Definition at line 53 of file CodeComplete.h.

Referenced by clang::clangd::clangdMain().

◆ Index

const SymbolIndex* clang::clangd::CodeCompleteOptions::Index = nullptr

If Index is set, it is used to augment the code completion results.

FIXME(ioeric): we might want a better way to pass the index around inside clangd.

Definition at line 92 of file CodeComplete.h.

◆ InsertIncludes

enum clang::clangd::CodeCompleteOptions::IncludeInsertion clang::clangd::CodeCompleteOptions::InsertIncludes = IncludeInsertion::IWYU

◆ Limit

size_t clang::clangd::CodeCompleteOptions::Limit = 0

Limit the number of results returned (0 means no limit).

If more results are available, we set CompletionList.isIncomplete.

Definition at line 63 of file CodeComplete.h.

Referenced by clang::clangd::clangdMain().

◆ MainFileSignals

const ASTSignals* clang::clangd::CodeCompleteOptions::MainFileSignals = nullptr

Definition at line 94 of file CodeComplete.h.

◆ RankingModel

CodeCompletionRankingModel clang::clangd::CodeCompleteOptions::RankingModel = DefaultRankingModel

Definition at line 139 of file CodeComplete.h.

Referenced by clang::clangd::clangdMain().

◆ RecordCCResult

std::function<void(const CodeCompletion &, const SymbolQualitySignals &, const SymbolRelevanceSignals &, float Score)> clang::clangd::CodeCompleteOptions::RecordCCResult

Callback invoked on all CompletionCandidate after they are scored and before they are ranked (by -Score).

Thus the results are yielded in arbitrary order.

This callbacks allows capturing various internal structures used by clangd during code completion. Eg: Symbol quality and relevance signals.

Definition at line 131 of file CodeComplete.h.

◆ RunParser

enum clang::clangd::CodeCompleteOptions::CodeCompletionParse clang::clangd::CodeCompleteOptions::RunParser = ParseIfReady

◆ ShowOrigins

bool clang::clangd::CodeCompleteOptions::ShowOrigins = false

Expose origins of completion items in the label (for debugging).

Definition at line 85 of file CodeComplete.h.

Referenced by clang::clangd::clangdMain().


The documentation for this struct was generated from the following files: