File indexing completed on 2026-05-10 08:37:04
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef LLVM_CLANG_SEMA_SEMACODECOMPLETION_H
0014 #define LLVM_CLANG_SEMA_SEMACODECOMPLETION_H
0015
0016 #include "clang/AST/ASTFwd.h"
0017 #include "clang/AST/Type.h"
0018 #include "clang/Basic/AttributeCommonInfo.h"
0019 #include "clang/Basic/IdentifierTable.h"
0020 #include "clang/Basic/LLVM.h"
0021 #include "clang/Basic/SourceLocation.h"
0022 #include "clang/Lex/ModuleLoader.h"
0023 #include "clang/Sema/CodeCompleteConsumer.h"
0024 #include "clang/Sema/DeclSpec.h"
0025 #include "clang/Sema/Designator.h"
0026 #include "clang/Sema/HeuristicResolver.h"
0027 #include "clang/Sema/Ownership.h"
0028 #include "clang/Sema/SemaBase.h"
0029 #include "llvm/ADT/StringRef.h"
0030 #include <optional>
0031
0032 namespace clang {
0033 class DeclGroupRef;
0034 class MacroInfo;
0035 class Scope;
0036 class TemplateName;
0037
0038 class SemaCodeCompletion : public SemaBase {
0039 public:
0040 SemaCodeCompletion(Sema &S, CodeCompleteConsumer *CompletionConsumer);
0041
0042 using TemplateTy = OpaquePtr<TemplateName>;
0043 using DeclGroupPtrTy = OpaquePtr<DeclGroupRef>;
0044
0045
0046 CodeCompleteConsumer *CodeCompleter;
0047 HeuristicResolver Resolver;
0048
0049
0050 enum ParserCompletionContext {
0051
0052 PCC_Namespace,
0053
0054 PCC_Class,
0055
0056
0057 PCC_ObjCInterface,
0058
0059
0060 PCC_ObjCImplementation,
0061
0062
0063 PCC_ObjCInstanceVariableList,
0064
0065
0066 PCC_Template,
0067
0068
0069 PCC_MemberTemplate,
0070
0071 PCC_Expression,
0072
0073
0074 PCC_Statement,
0075
0076
0077 PCC_ForInit,
0078
0079
0080 PCC_Condition,
0081
0082
0083
0084 PCC_RecoveryInFunction,
0085
0086 PCC_Type,
0087
0088
0089 PCC_ParenthesizedExpression,
0090
0091
0092 PCC_LocalDeclarationSpecifiers,
0093
0094 PCC_TopLevelOrExpression,
0095 };
0096
0097 void CodeCompleteModuleImport(SourceLocation ImportLoc, ModuleIdPath Path);
0098 void CodeCompleteOrdinaryName(Scope *S,
0099 ParserCompletionContext CompletionContext);
0100 void CodeCompleteDeclSpec(Scope *S, DeclSpec &DS, bool AllowNonIdentifiers,
0101 bool AllowNestedNameSpecifiers);
0102
0103 struct CodeCompleteExpressionData;
0104 void CodeCompleteExpression(Scope *S, const CodeCompleteExpressionData &Data);
0105 void CodeCompleteExpression(Scope *S, QualType PreferredType,
0106 bool IsParenthesized = false);
0107 void CodeCompleteMemberReferenceExpr(Scope *S, Expr *Base, Expr *OtherOpBase,
0108 SourceLocation OpLoc, bool IsArrow,
0109 bool IsBaseExprStatement,
0110 QualType PreferredType);
0111 void CodeCompletePostfixExpression(Scope *S, ExprResult LHS,
0112 QualType PreferredType);
0113 void CodeCompleteTag(Scope *S, unsigned TagSpec);
0114 void CodeCompleteTypeQualifiers(DeclSpec &DS);
0115 void CodeCompleteFunctionQualifiers(DeclSpec &DS, Declarator &D,
0116 const VirtSpecifiers *VS = nullptr);
0117 void CodeCompleteBracketDeclarator(Scope *S);
0118 void CodeCompleteCase(Scope *S);
0119 enum class AttributeCompletion {
0120 Attribute,
0121 Scope,
0122 None,
0123 };
0124 void CodeCompleteAttribute(
0125 AttributeCommonInfo::Syntax Syntax,
0126 AttributeCompletion Completion = AttributeCompletion::Attribute,
0127 const IdentifierInfo *Scope = nullptr);
0128
0129
0130
0131
0132
0133
0134
0135
0136 QualType ProduceCallSignatureHelp(Expr *Fn, ArrayRef<Expr *> Args,
0137 SourceLocation OpenParLoc);
0138 QualType ProduceConstructorSignatureHelp(QualType Type, SourceLocation Loc,
0139 ArrayRef<Expr *> Args,
0140 SourceLocation OpenParLoc,
0141 bool Braced);
0142 QualType ProduceCtorInitMemberSignatureHelp(
0143 Decl *ConstructorDecl, CXXScopeSpec SS, ParsedType TemplateTypeTy,
0144 ArrayRef<Expr *> ArgExprs, IdentifierInfo *II, SourceLocation OpenParLoc,
0145 bool Braced);
0146 QualType ProduceTemplateArgumentSignatureHelp(
0147 TemplateTy, ArrayRef<ParsedTemplateArgument>, SourceLocation LAngleLoc);
0148 void CodeCompleteInitializer(Scope *S, Decl *D);
0149
0150
0151
0152 void CodeCompleteDesignator(const QualType BaseType,
0153 llvm::ArrayRef<Expr *> InitExprs,
0154 const Designation &D);
0155 void CodeCompleteAfterIf(Scope *S, bool IsBracedThen);
0156
0157 void CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS, bool EnteringContext,
0158 bool IsUsingDeclaration, QualType BaseType,
0159 QualType PreferredType);
0160 void CodeCompleteUsing(Scope *S);
0161 void CodeCompleteUsingDirective(Scope *S);
0162 void CodeCompleteNamespaceDecl(Scope *S);
0163 void CodeCompleteNamespaceAliasDecl(Scope *S);
0164 void CodeCompleteOperatorName(Scope *S);
0165 void CodeCompleteConstructorInitializer(
0166 Decl *Constructor, ArrayRef<CXXCtorInitializer *> Initializers);
0167
0168 void CodeCompleteLambdaIntroducer(Scope *S, LambdaIntroducer &Intro,
0169 bool AfterAmpersand);
0170 void CodeCompleteAfterFunctionEquals(Declarator &D);
0171
0172 void CodeCompleteObjCAtDirective(Scope *S);
0173 void CodeCompleteObjCAtVisibility(Scope *S);
0174 void CodeCompleteObjCAtStatement(Scope *S);
0175 void CodeCompleteObjCAtExpression(Scope *S);
0176 void CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS);
0177 void CodeCompleteObjCPropertyGetter(Scope *S);
0178 void CodeCompleteObjCPropertySetter(Scope *S);
0179 void CodeCompleteObjCPassingType(Scope *S, ObjCDeclSpec &DS,
0180 bool IsParameter);
0181 void CodeCompleteObjCMessageReceiver(Scope *S);
0182 void CodeCompleteObjCSuperMessage(Scope *S, SourceLocation SuperLoc,
0183 ArrayRef<const IdentifierInfo *> SelIdents,
0184 bool AtArgumentExpression);
0185 void CodeCompleteObjCClassMessage(Scope *S, ParsedType Receiver,
0186 ArrayRef<const IdentifierInfo *> SelIdents,
0187 bool AtArgumentExpression,
0188 bool IsSuper = false);
0189 void CodeCompleteObjCInstanceMessage(
0190 Scope *S, Expr *Receiver, ArrayRef<const IdentifierInfo *> SelIdents,
0191 bool AtArgumentExpression, ObjCInterfaceDecl *Super = nullptr);
0192 void CodeCompleteObjCForCollection(Scope *S, DeclGroupPtrTy IterationVar);
0193 void CodeCompleteObjCSelector(Scope *S,
0194 ArrayRef<const IdentifierInfo *> SelIdents);
0195 void
0196 CodeCompleteObjCProtocolReferences(ArrayRef<IdentifierLocPair> Protocols);
0197 void CodeCompleteObjCProtocolDecl(Scope *S);
0198 void CodeCompleteObjCInterfaceDecl(Scope *S);
0199 void CodeCompleteObjCClassForwardDecl(Scope *S);
0200 void CodeCompleteObjCSuperclass(Scope *S, IdentifierInfo *ClassName,
0201 SourceLocation ClassNameLoc);
0202 void CodeCompleteObjCImplementationDecl(Scope *S);
0203 void CodeCompleteObjCInterfaceCategory(Scope *S, IdentifierInfo *ClassName,
0204 SourceLocation ClassNameLoc);
0205 void CodeCompleteObjCImplementationCategory(Scope *S,
0206 IdentifierInfo *ClassName,
0207 SourceLocation ClassNameLoc);
0208 void CodeCompleteObjCPropertyDefinition(Scope *S);
0209 void CodeCompleteObjCPropertySynthesizeIvar(Scope *S,
0210 IdentifierInfo *PropertyName);
0211 void CodeCompleteObjCMethodDecl(Scope *S,
0212 std::optional<bool> IsInstanceMethod,
0213 ParsedType ReturnType);
0214 void CodeCompleteObjCMethodDeclSelector(
0215 Scope *S, bool IsInstanceMethod, bool AtParameterName,
0216 ParsedType ReturnType, ArrayRef<const IdentifierInfo *> SelIdents);
0217 void CodeCompleteObjCClassPropertyRefExpr(Scope *S,
0218 const IdentifierInfo &ClassName,
0219 SourceLocation ClassNameLoc,
0220 bool IsBaseExprStatement);
0221 void CodeCompletePreprocessorDirective(bool InConditional);
0222 void CodeCompleteInPreprocessorConditionalExclusion(Scope *S);
0223 void CodeCompletePreprocessorMacroName(bool IsDefinition);
0224 void CodeCompletePreprocessorExpression();
0225 void CodeCompletePreprocessorMacroArgument(Scope *S, IdentifierInfo *Macro,
0226 MacroInfo *MacroInfo,
0227 unsigned Argument);
0228 void CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled);
0229 void CodeCompleteNaturalLanguage();
0230 void CodeCompleteAvailabilityPlatformName();
0231 void
0232 GatherGlobalCodeCompletions(CodeCompletionAllocator &Allocator,
0233 CodeCompletionTUInfo &CCTUInfo,
0234 SmallVectorImpl<CodeCompletionResult> &Results);
0235 };
0236
0237 }
0238
0239 #endif