clang 20.0.0git
|
Captures a result of code completion. More...
#include "clang/Sema/CodeCompleteConsumer.h"
Public Types | |
enum | ResultKind { RK_Declaration = 0 , RK_Keyword , RK_Macro , RK_Pattern } |
Describes the kind of result generated. More... | |
Public Member Functions | |
CodeCompletionResult (const NamedDecl *Declaration, unsigned Priority, NestedNameSpecifier *Qualifier=nullptr, bool QualifierIsInformative=false, bool Accessible=true, std::vector< FixItHint > FixIts=std::vector< FixItHint >()) | |
Build a result that refers to a declaration. | |
CodeCompletionResult (const char *Keyword, unsigned Priority=CCP_Keyword) | |
Build a result that refers to a keyword or symbol. | |
CodeCompletionResult (const IdentifierInfo *Macro, const MacroInfo *MI=nullptr, unsigned Priority=CCP_Macro) | |
Build a result that refers to a macro. | |
CodeCompletionResult (CodeCompletionString *Pattern, unsigned Priority=CCP_CodePattern, CXCursorKind CursorKind=CXCursor_NotImplemented, CXAvailabilityKind Availability=CXAvailability_Available, const NamedDecl *D=nullptr) | |
Build a result that refers to a pattern. | |
CodeCompletionResult (CodeCompletionString *Pattern, const NamedDecl *D, unsigned Priority) | |
Build a result that refers to a pattern with an associated declaration. | |
const NamedDecl * | getDeclaration () const |
Retrieve the declaration stored in this result. | |
const char * | getKeyword () const |
Retrieve the keyword stored in this result. | |
CodeCompletionString * | CreateCodeCompletionString (Sema &S, const CodeCompletionContext &CCContext, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments) |
Create a new code-completion string that describes how to insert this result into a program. | |
CodeCompletionString * | CreateCodeCompletionString (ASTContext &Ctx, Preprocessor &PP, const CodeCompletionContext &CCContext, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo, bool IncludeBriefComments) |
If possible, create a new code completion string for the given result. | |
CodeCompletionString * | CreateCodeCompletionStringForMacro (Preprocessor &PP, CodeCompletionAllocator &Allocator, CodeCompletionTUInfo &CCTUInfo) |
Creates a new code-completion string for the macro result. | |
CodeCompletionString * | createCodeCompletionStringForDecl (Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result, bool IncludeBriefComments, const CodeCompletionContext &CCContext, PrintingPolicy &Policy) |
CodeCompletionString * | createCodeCompletionStringForOverride (Preprocessor &PP, ASTContext &Ctx, CodeCompletionBuilder &Result, bool IncludeBriefComments, const CodeCompletionContext &CCContext, PrintingPolicy &Policy) |
StringRef | getOrderedName (std::string &Saved) const |
Retrieve the name that should be used to order a result. | |
Public Attributes | |
const NamedDecl * | Declaration = nullptr |
When Kind == RK_Declaration or RK_Pattern, the declaration we are referring to. | |
union { | |
const char * Keyword | |
When Kind == RK_Keyword, the string representing the keyword or symbol's spelling. More... | |
CodeCompletionString * Pattern | |
When Kind == RK_Pattern, the code-completion string that describes the completion text to insert. More... | |
const IdentifierInfo * Macro | |
When Kind == RK_Macro, the identifier that refers to a macro. More... | |
}; | |
unsigned | Priority |
The priority of this particular code-completion result. | |
unsigned | StartParameter = 0 |
Specifies which parameter (of a function, Objective-C method, macro, etc.) we should start with when formatting the result. | |
ResultKind | Kind |
The kind of result stored here. | |
CXCursorKind | CursorKind |
The cursor kind that describes this result. | |
CXAvailabilityKind | Availability = CXAvailability_Available |
The availability of this result. | |
std::vector< FixItHint > | FixIts |
Fix-its that must be applied before inserting the text for the corresponding completion. | |
bool | Hidden: 1 |
Whether this result is hidden by another name. | |
bool | InBaseClass: 1 |
Whether this is a class member from base class. | |
bool | QualifierIsInformative: 1 |
Whether this result was found via lookup into a base class. | |
bool | StartsNestedNameSpecifier: 1 |
Whether this declaration is the beginning of a nested-name-specifier and, therefore, should be followed by '::'. | |
bool | AllParametersAreInformative: 1 |
Whether all parameters (of a function, Objective-C method, etc.) should be considered "informative". | |
bool | DeclaringEntity: 1 |
Whether we're completing a declaration of the given entity, rather than a use of that entity. | |
bool | FunctionCanBeCall: 1 |
When completing a function, whether it can be a call. | |
NestedNameSpecifier * | Qualifier = nullptr |
If the result should have a nested-name-specifier, this is it. | |
const UsingShadowDecl * | ShadowDecl = nullptr |
If this Decl was unshadowed by using declaration, this can store a pointer to the UsingShadowDecl which was used in the unshadowing process. | |
const MacroInfo * | MacroDefInfo = nullptr |
If the result is RK_Macro, this can store the information about the macro definition. | |
Captures a result of code completion.
Definition at line 761 of file CodeCompleteConsumer.h.
Describes the kind of result generated.
Enumerator | |
---|---|
RK_Declaration | Refers to a declaration. |
RK_Keyword | Refers to a keyword or symbol. |
RK_Macro | Refers to a macro. |
RK_Pattern | Refers to a precomputed pattern. |
Definition at line 764 of file CodeCompleteConsumer.h.
|
inline |
Build a result that refers to a declaration.
Definition at line 885 of file CodeCompleteConsumer.h.
|
inline |
Build a result that refers to a keyword or symbol.
Definition at line 900 of file CodeCompleteConsumer.h.
|
inline |
Build a result that refers to a macro.
Definition at line 908 of file CodeCompleteConsumer.h.
|
inline |
Build a result that refers to a pattern.
Definition at line 918 of file CodeCompleteConsumer.h.
|
inline |
Build a result that refers to a pattern with an associated declaration.
Definition at line 931 of file CodeCompleteConsumer.h.
CodeCompletionString * CodeCompletionResult::CreateCodeCompletionString | ( | ASTContext & | Ctx, |
Preprocessor & | PP, | ||
const CodeCompletionContext & | CCContext, | ||
CodeCompletionAllocator & | Allocator, | ||
CodeCompletionTUInfo & | CCTUInfo, | ||
bool | IncludeBriefComments | ||
) |
If possible, create a new code completion string for the given result.
Definition at line 3449 of file SemaCodeComplete.cpp.
References Availability, createCodeCompletionStringForDecl(), CreateCodeCompletionStringForMacro(), Declaration, getCompletionPrintingPolicy(), clang::Decl::getDeclContext(), clang::getPatternCompletionComment(), Keyword, Kind, Pattern, Priority, clang::Result, RK_Declaration, RK_Keyword, RK_Macro, and RK_Pattern.
CodeCompletionString * CodeCompletionResult::CreateCodeCompletionString | ( | Sema & | S, |
const CodeCompletionContext & | CCContext, | ||
CodeCompletionAllocator & | Allocator, | ||
CodeCompletionTUInfo & | CCTUInfo, | ||
bool | IncludeBriefComments | ||
) |
Create a new code-completion string that describes how to insert this result into a program.
S | The semantic analysis that created the result. |
Allocator | The allocator that will be used to allocate the string itself. |
Definition at line 3389 of file SemaCodeComplete.cpp.
References clang::Sema::Context, CreateCodeCompletionString(), and clang::Sema::PP.
Referenced by CreateCodeCompletionString().
CodeCompletionString * CodeCompletionResult::createCodeCompletionStringForDecl | ( | Preprocessor & | PP, |
ASTContext & | Ctx, | ||
CodeCompletionBuilder & | Result, | ||
bool | IncludeBriefComments, | ||
const CodeCompletionContext & | CCContext, | ||
PrintingPolicy & | Policy | ||
) |
Definition at line 3536 of file SemaCodeComplete.cpp.
References AddFunctionParameterChunks(), AddFunctionTypeQualsToCompletionString(), AddQualifierToCompletionString(), AddResultTypeChunk(), AddTemplateParameterChunks(), AddTypedNameChunk(), AllParametersAreInformative, clang::CodeCompletionString::CK_HorizontalSpace, clang::CodeCompletionString::CK_LeftAngle, clang::CodeCompletionString::CK_LeftParen, clang::CodeCompletionString::CK_RightAngle, clang::CodeCompletionString::CK_RightParen, Declaration, DeclaringEntity, extractFunctorCallOperator(), FormatFunctionParameter(), formatObjCParamQualifiers(), clang::Function, FunctionCanBeCall, clang::QualType::getAsString(), clang::CodeCompletionContext::getBaseType(), clang::getCompletionComment(), clang::Decl::getDeclContext(), clang::Selector::getIdentifierInfoForSlot(), clang::NamedDecl::getNameAsString(), clang::Selector::getNameForSlot(), clang::Selector::getNumArgs(), clang::Type::getObjCSubstitutions(), clang::Type::isBlockPointerType(), clang::QualType::isNull(), clang::Selector::isUnarySelector(), clang::FunctionDecl::isVariadic(), Keyword, clang::Sema::MarkDeducedTemplateParameters(), MaybeAddSentinel(), P, clang::FunctionDecl::param_begin(), clang::FunctionDecl::param_end(), clang::FunctionDecl::param_size(), clang::Parameter, Qualifier, QualifierIsInformative, clang::Result, clang::Decl::specific_attrs(), StartParameter, StartsNestedNameSpecifier, and clang::QualType::substObjCTypeArgs().
Referenced by CreateCodeCompletionString(), and createCodeCompletionStringForOverride().
CodeCompletionString * CodeCompletionResult::CreateCodeCompletionStringForMacro | ( | Preprocessor & | PP, |
CodeCompletionAllocator & | Allocator, | ||
CodeCompletionTUInfo & | CCTUInfo | ||
) |
Creates a new code-completion string for the macro result.
Similar to the above overloads, except this only requires preprocessor information. The result kind must be RK_Macro
.
Definition at line 3397 of file SemaCodeComplete.cpp.
References Availability, clang::CodeCompletionString::CK_Comma, clang::CodeCompletionString::CK_LeftParen, clang::CodeCompletionString::CK_RightParen, clang::Preprocessor::getMacroInfo(), clang::IdentifierInfo::getName(), clang::MacroInfo::isC99Varargs(), clang::MacroInfo::isFunctionLike(), clang::MacroInfo::isVariadic(), Kind, Macro, clang::MacroInfo::param_begin(), clang::MacroInfo::param_end(), Priority, clang::Result, and RK_Macro.
Referenced by CreateCodeCompletionString().
CodeCompletionString * CodeCompletionResult::createCodeCompletionStringForOverride | ( | Preprocessor & | PP, |
ASTContext & | Ctx, | ||
CodeCompletionBuilder & | Result, | ||
bool | IncludeBriefComments, | ||
const CodeCompletionContext & | CCContext, | ||
PrintingPolicy & | Policy | ||
) |
Definition at line 3505 of file SemaCodeComplete.cpp.
References clang::CodeCompletionString::CK_HorizontalSpace, createCodeCompletionStringForDecl(), printOverrideString(), and clang::Result.
Referenced by AddOverrideResults().
|
inline |
Retrieve the declaration stored in this result.
This might be nullptr if Kind is RK_Pattern.
Definition at line 942 of file CodeCompleteConsumer.h.
References Declaration, Kind, RK_Declaration, and RK_Pattern.
|
inline |
Retrieve the keyword stored in this result.
Definition at line 949 of file CodeCompleteConsumer.h.
References Keyword, Kind, and RK_Keyword.
StringRef CodeCompletionResult::getOrderedName | ( | std::string & | Saved | ) | const |
Retrieve the name that should be used to order a result.
If the name needs to be constructed as a string, that string will be saved into Saved and the returned StringRef will refer to it.
Definition at line 837 of file CodeCompleteConsumer.cpp.
References clang::Declaration, and Id.
Referenced by clang::operator<().
union { ... } clang::CodeCompletionResult::@215 |
bool clang::CodeCompletionResult::AllParametersAreInformative |
Whether all parameters (of a function, Objective-C method, etc.) should be considered "informative".
Definition at line 856 of file CodeCompleteConsumer.h.
Referenced by createCodeCompletionStringForDecl().
CXAvailabilityKind clang::CodeCompletionResult::Availability = CXAvailability_Available |
The availability of this result.
Definition at line 809 of file CodeCompleteConsumer.h.
Referenced by CreateCodeCompletionString(), and CreateCodeCompletionStringForMacro().
CXCursorKind clang::CodeCompletionResult::CursorKind |
The cursor kind that describes this result.
Definition at line 806 of file CodeCompleteConsumer.h.
const NamedDecl* clang::CodeCompletionResult::Declaration = nullptr |
When Kind == RK_Declaration or RK_Pattern, the declaration we are referring to.
In the latter case, the declaration might be NULL.
Definition at line 780 of file CodeCompleteConsumer.h.
Referenced by CreateCodeCompletionString(), createCodeCompletionStringForDecl(), and getDeclaration().
bool clang::CodeCompletionResult::DeclaringEntity |
Whether we're completing a declaration of the given entity, rather than a use of that entity.
Definition at line 860 of file CodeCompleteConsumer.h.
Referenced by createCodeCompletionStringForDecl().
std::vector<FixItHint> clang::CodeCompletionResult::FixIts |
Fix-its that must be applied before inserting the text for the corresponding completion.
By default, CodeCompletionBuilder only returns completions with empty fix-its. Extra completions with non-empty fix-its should be explicitly requested by setting CompletionOptions::IncludeFixIts.
For the clients to be able to compute position of the cursor after applying fix-its, the following conditions are guaranteed to hold for RemoveRange of the stored fix-its:
The intuition is that provided fix-its change code around the identifier we complete, but are not allowed to touch the identifier itself or the completion point. One example of completions with corrections are the ones replacing '.' with '->' and vice versa:
std::unique_ptr<std::vector<int>> vec_ptr; In 'vec_ptr.^', one of the completions is 'push_back', it requires replacing '.' with '->'. In 'vec_ptr->^', one of the completions is 'release', it requires replacing '->' with '.'.
Definition at line 839 of file CodeCompleteConsumer.h.
bool clang::CodeCompletionResult::FunctionCanBeCall |
When completing a function, whether it can be a call.
This will usually be true, but we have some heuristics, e.g. when a pointer to a non-static member function is completed outside of that class' scope, it can never be a call.
Definition at line 866 of file CodeCompleteConsumer.h.
Referenced by createCodeCompletionStringForDecl().
bool clang::CodeCompletionResult::Hidden |
Whether this result is hidden by another name.
Definition at line 842 of file CodeCompleteConsumer.h.
bool clang::CodeCompletionResult::InBaseClass |
Whether this is a class member from base class.
Definition at line 845 of file CodeCompleteConsumer.h.
Referenced by setInBaseClass().
const char* clang::CodeCompletionResult::Keyword |
When Kind == RK_Keyword, the string representing the keyword or symbol's spelling.
Definition at line 785 of file CodeCompleteConsumer.h.
Referenced by CreateCodeCompletionString(), createCodeCompletionStringForDecl(), and getKeyword().
ResultKind clang::CodeCompletionResult::Kind |
The kind of result stored here.
Definition at line 803 of file CodeCompleteConsumer.h.
Referenced by CreateCodeCompletionString(), CreateCodeCompletionStringForMacro(), getDeclaration(), and getKeyword().
const IdentifierInfo* clang::CodeCompletionResult::Macro |
When Kind == RK_Macro, the identifier that refers to a macro.
Definition at line 792 of file CodeCompleteConsumer.h.
Referenced by CreateCodeCompletionStringForMacro().
const MacroInfo* clang::CodeCompletionResult::MacroDefInfo = nullptr |
If the result is RK_Macro, this can store the information about the macro definition.
This should be set in most cases but can be missing when the macro has been undefined.
Definition at line 882 of file CodeCompleteConsumer.h.
CodeCompletionString* clang::CodeCompletionResult::Pattern |
When Kind == RK_Pattern, the code-completion string that describes the completion text to insert.
Definition at line 789 of file CodeCompleteConsumer.h.
Referenced by CreateCodeCompletionString().
unsigned clang::CodeCompletionResult::Priority |
The priority of this particular code-completion result.
Definition at line 796 of file CodeCompleteConsumer.h.
Referenced by CreateCodeCompletionString(), CreateCodeCompletionStringForMacro(), and setInBaseClass().
NestedNameSpecifier* clang::CodeCompletionResult::Qualifier = nullptr |
If the result should have a nested-name-specifier, this is it.
When QualifierIsInformative
, the nested-name-specifier is informative rather than required.
Definition at line 871 of file CodeCompleteConsumer.h.
Referenced by createCodeCompletionStringForDecl().
bool clang::CodeCompletionResult::QualifierIsInformative |
Whether this result was found via lookup into a base class.
Definition at line 848 of file CodeCompleteConsumer.h.
Referenced by createCodeCompletionStringForDecl().
const UsingShadowDecl* clang::CodeCompletionResult::ShadowDecl = nullptr |
If this Decl was unshadowed by using declaration, this can store a pointer to the UsingShadowDecl which was used in the unshadowing process.
This information can be used to uprank CodeCompletionResults / which have corresponding using decl::qualified::name;
nearby.
Definition at line 877 of file CodeCompleteConsumer.h.
unsigned clang::CodeCompletionResult::StartParameter = 0 |
Specifies which parameter (of a function, Objective-C method, macro, etc.) we should start with when formatting the result.
Definition at line 800 of file CodeCompleteConsumer.h.
Referenced by createCodeCompletionStringForDecl().
bool clang::CodeCompletionResult::StartsNestedNameSpecifier |
Whether this declaration is the beginning of a nested-name-specifier and, therefore, should be followed by '::'.
Definition at line 852 of file CodeCompleteConsumer.h.
Referenced by createCodeCompletionStringForDecl().