clang 10.0.0git

Public Types | Public Member Functions | List of all members
clang::CodeCompletionContext Class Reference

The context in which code completion occurred, so that the code-completion consumer can process the results accordingly. More...

`#include "clang/Sema/CodeCompleteConsumer.h"`

## Public Types
enum | Kind { CCC_Other, CCC_OtherWithMacros, CCC_TopLevel, CCC_ObjCInterface, CCC_ObjCImplementation, CCC_ObjCIvarList, CCC_ClassStructUnion, CCC_Statement, CCC_Expression, CCC_ObjCMessageReceiver, CCC_DotMemberAccess, CCC_ArrowMemberAccess, CCC_ObjCPropertyAccess, CCC_EnumTag, CCC_UnionTag, CCC_ClassOrStructTag, CCC_ObjCProtocolName, CCC_Namespace, CCC_Type, CCC_NewName, CCC_SymbolOrNewName, CCC_Symbol, CCC_MacroName, CCC_MacroNameUse, CCC_PreprocessorExpression, CCC_PreprocessorDirective, CCC_NaturalLanguage, CCC_SelectorName, CCC_TypeQualifiers, CCC_ParenthesizedExpression, CCC_ObjCInstanceMessage, CCC_ObjCClassMessage, CCC_ObjCInterfaceName, CCC_ObjCCategoryName, CCC_IncludedFile, CCC_Recovery }
using | VisitedContextSet = llvm::SmallPtrSet< DeclContext *, 8 >

## Public Member Functions
| CodeCompletionContext (Kind CCKind)
| Construct a new code-completion context of the given kind. More...
| CodeCompletionContext (Kind CCKind, QualType T, ArrayRef< IdentifierInfo *> SelIdents=None)
| Construct a new code-completion context of the given kind. More...
bool | isUsingDeclaration () const
void | setIsUsingDeclaration (bool V)
Kind | getKind () const
| Retrieve the kind of code-completion context. More...
QualType | getPreferredType () const
| Retrieve the type that this expression would prefer to have, e.g., if the expression is a variable initializer or a function argument, the type of the corresponding variable or function parameter. More...
void | setPreferredType (QualType T)
QualType | getBaseType () const
| Retrieve the type of the base object in a member-access expression. More...
ArrayRef< IdentifierInfo * > | getSelIdents () const
| Retrieve the Objective-C selector identifiers. More...
bool | wantConstructorResults () const
| Determines whether we want C++ constructors as results within this context. More...
void | setCXXScopeSpecifier (CXXScopeSpec SS)
| Sets the scope specifier that comes before the completion token. More...
void | addVisitedContext (DeclContext *Ctx)
| Adds a visited context. More...
const VisitedContextSet & | getVisitedContexts () const
| Retrieves all visited contexts. More...
llvm::Optional< const CXXScopeSpec * > | getCXXScopeSpecifier ()

## Detailed Description

The context in which code completion occurred, so that the code-completion consumer can process the results accordingly.

Definition at line 187 of file CodeCompleteConsumer.h.

## Member Typedef Documentation

## ◆ VisitedContextSet

using clang::CodeCompletionContext::VisitedContextSet = llvm::SmallPtrSet<DeclContext *, 8>

Definition at line 337 of file CodeCompleteConsumer.h.

## Member Enumeration Documentation

## ◆ Kind

enum clang::CodeCompletionContext::Kind

Enumerator
CCC_Other | An unspecified code-completion context.
CCC_OtherWithMacros | An unspecified code-completion context where we should also add macro completions.
CCC_TopLevel | Code completion occurred within a "top-level" completion context, e.g., at namespace or global scope.
CCC_ObjCInterface | Code completion occurred within an Objective-C interface, protocol, or category interface.
CCC_ObjCImplementation | Code completion occurred within an Objective-C implementation or category implementation.
CCC_ObjCIvarList | Code completion occurred within the instance variable list of an Objective-C interface, implementation, or category implementation.
CCC_ClassStructUnion | Code completion occurred within a class, struct, or union.
CCC_Statement | Code completion occurred where a statement (or declaration) is expected in a function, method, or block.
CCC_Expression | Code completion occurred where an expression is expected.
CCC_ObjCMessageReceiver | Code completion occurred where an Objective-C message receiver is expected.
CCC_DotMemberAccess | Code completion occurred on the right-hand side of a member access expression using the dot operator. The results of this completion are the members of the type being accessed. The type itself is available via `CodeCompletionContext::getType()`.
CCC_ArrowMemberAccess | Code completion occurred on the right-hand side of a member access expression using the arrow operator. The results of this completion are the members of the type being accessed. The type itself is available via `CodeCompletionContext::getType()`.
CCC_ObjCPropertyAccess | Code completion occurred on the right-hand side of an Objective-C property access expression. The results of this completion are the members of the type being accessed. The type itself is available via `CodeCompletionContext::getType()`.
CCC_EnumTag | Code completion occurred after the "enum" keyword, to indicate an enumeration name.
CCC_UnionTag | Code completion occurred after the "union" keyword, to indicate a union name.
CCC_ClassOrStructTag | Code completion occurred after the "struct" or "class" keyword, to indicate a struct or class name.
CCC_ObjCProtocolName | Code completion occurred where a protocol name is expected.
CCC_Namespace | Code completion occurred where a namespace or namespace alias is expected.
CCC_Type | Code completion occurred where a type name is expected.
CCC_NewName | Code completion occurred where a new name is expected.
CCC_SymbolOrNewName | Code completion occurred where both a new name and an existing symbol is permissible.
CCC_Symbol | Code completion occurred where an existing name(such as type, function or variable) is expected.
CCC_MacroName | Code completion occurred where an macro is being defined.
CCC_MacroNameUse | Code completion occurred where a macro name is expected (without any arguments, in the case of a function-like macro).
CCC_PreprocessorExpression | Code completion occurred within a preprocessor expression.
CCC_PreprocessorDirective | Code completion occurred where a preprocessor directive is expected.
CCC_NaturalLanguage | Code completion occurred in a context where natural language is expected, e.g., a comment or string literal. This context usually implies that no completions should be added, unless they come from an appropriate natural-language dictionary.
CCC_SelectorName | Code completion for a selector, as in an @selector expression.
CCC_TypeQualifiers | Code completion within a type-qualifier list.
CCC_ParenthesizedExpression | Code completion in a parenthesized expression, which means that we may also have types here in C and Objective-C (as well as in C++).
CCC_ObjCInstanceMessage | Code completion where an Objective-C instance message is expected.
CCC_ObjCClassMessage | Code completion where an Objective-C class message is expected.
CCC_ObjCInterfaceName | Code completion where the name of an Objective-C class is expected.
CCC_ObjCCategoryName | Code completion where an Objective-C category name is expected.
CCC_IncludedFile | Code completion inside the filename part of a #include directive.
CCC_Recovery | An unknown context, in which we are recovering from a parsing error and don't know which completions we should give.

Definition at line 189 of file CodeCompleteConsumer.h.

## Constructor & Destructor Documentation

## ◆ CodeCompletionContext() [1/2]

clang::CodeCompletionContext::CodeCompletionContext | ( | Kind | CCKind | ) |
| inline

Construct a new code-completion context of the given kind.

Definition at line 367 of file CodeCompleteConsumer.h.

## ◆ CodeCompletionContext() [2/2]

clang::CodeCompletionContext::CodeCompletionContext | ( | Kind | CCKind,
|  | QualType | T,
|  | ArrayRef< IdentifierInfo *> | SelIdents = `None`
| ) |  |
| inline

Construct a new code-completion context of the given kind.

Definition at line 371 of file CodeCompleteConsumer.h.

References CCC_ArrowMemberAccess, CCC_DotMemberAccess, CCC_ObjCClassMessage, CCC_ObjCInstanceMessage, and CCC_ObjCPropertyAccess.

## Member Function Documentation

## ◆ addVisitedContext()

void clang::CodeCompletionContext::addVisitedContext | ( | DeclContext * | Ctx | ) |
| inline

Adds a visited context.

Definition at line 413 of file CodeCompleteConsumer.h.

## ◆ getBaseType()

QualType clang::CodeCompletionContext::getBaseType | ( |  | ) | const
| inline

Retrieve the type of the base object in a member-access expression.

Definition at line 396 of file CodeCompleteConsumer.h.

Referenced by clang::CodeCompletionResult::createCodeCompletionStringForDecl().

## ◆ getCXXScopeSpecifier()

llvm::Optional<const CXXScopeSpec *> clang::CodeCompletionContext::getCXXScopeSpecifier | ( |  | ) |
| inline

Definition at line 422 of file CodeCompleteConsumer.h.

References clang::getCompletionKindString(), and clang::None.

## ◆ getKind()

Kind clang::CodeCompletionContext::getKind | ( |  | ) | const
| inline

Retrieve the kind of code-completion context.

Definition at line 386 of file CodeCompleteConsumer.h.

Referenced by clang::getDeclUsageType(), and clang::CodeCompleteConsumer::OverloadCandidate::getFunctionTemplate().

## ◆ getPreferredType()

QualType clang::CodeCompletionContext::getPreferredType | ( |  | ) | const
| inline

Retrieve the type that this expression would prefer to have, e.g., if the expression is a variable initializer or a function argument, the type of the corresponding variable or function parameter.

Definition at line 391 of file CodeCompleteConsumer.h.

## ◆ getSelIdents()

ArrayRef<IdentifierInfo *> clang::CodeCompletionContext::getSelIdents | ( |  | ) | const
| inline

Retrieve the Objective-C selector identifiers.

Definition at line 399 of file CodeCompleteConsumer.h.

References wantConstructorResults().

## ◆ getVisitedContexts()

const VisitedContextSet& clang::CodeCompletionContext::getVisitedContexts | ( |  | ) | const
| inline

Retrieves all visited contexts.

Definition at line 418 of file CodeCompleteConsumer.h.

## ◆ isUsingDeclaration()

bool clang::CodeCompletionContext::isUsingDeclaration | ( |  | ) | const
| inline

Definition at line 382 of file CodeCompleteConsumer.h.

## ◆ setCXXScopeSpecifier()

void clang::CodeCompletionContext::setCXXScopeSpecifier | ( | CXXScopeSpec | SS | ) |
| inline

Sets the scope specifier that comes before the completion token.

This is expected to be set in code completions on qualfied specifiers (e.g. "a::b::").

Definition at line 408 of file CodeCompleteConsumer.h.

Referenced by clang::Sema::CodeCompleteQualifiedId().

## ◆ setIsUsingDeclaration()

void clang::CodeCompletionContext::setIsUsingDeclaration | ( | bool | V | ) |
| inline

Definition at line 383 of file CodeCompleteConsumer.h.

References V.

Referenced by clang::Sema::CodeCompleteQualifiedId().

## ◆ setPreferredType()

void clang::CodeCompletionContext::setPreferredType | ( | QualType | T | ) |
| inline

Definition at line 392 of file CodeCompleteConsumer.h.

Referenced by clang::Sema::CodeCompleteMemberReferenceExpr().

## ◆ wantConstructorResults()

bool CodeCompletionContext::wantConstructorResults | ( |  | ) | const

Determines whether we want C++ constructors as results within this context.

Definition at line 44 of file CodeCompleteConsumer.cpp.

References CCC_ArrowMemberAccess, CCC_ClassOrStructTag, CCC_ClassStructUnion, CCC_DotMemberAccess, CCC_EnumTag, CCC_Expression, CCC_IncludedFile, CCC_MacroName, CCC_MacroNameUse, CCC_Namespace, CCC_NaturalLanguage, CCC_NewName, CCC_ObjCCategoryName, CCC_ObjCClassMessage, CCC_ObjCImplementation, CCC_ObjCInstanceMessage, CCC_ObjCInterface, CCC_ObjCInterfaceName, CCC_ObjCIvarList, CCC_ObjCMessageReceiver, CCC_ObjCPropertyAccess, CCC_ObjCProtocolName, CCC_Other, CCC_OtherWithMacros, CCC_ParenthesizedExpression, CCC_PreprocessorDirective, CCC_PreprocessorExpression, CCC_Recovery, CCC_SelectorName, CCC_Statement, CCC_Symbol, CCC_SymbolOrNewName, CCC_TopLevel, CCC_Type, CCC_TypeQualifiers, and CCC_UnionTag.

Referenced by getSelIdents().

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

- include/clang/Sema/CodeCompleteConsumer.h
- lib/Sema/CodeCompleteConsumer.cpp