blob: 50b8ffd1f49bba3554b56d450b1d42d21ae9caf5 [file] [log] [blame]
Douglas Gregor81b747b2009-09-17 21:32:03 +00001//===---------------- SemaCodeComplete.cpp - Code Completion ----*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines the code-completion semantic actions.
11//
12//===----------------------------------------------------------------------===//
13#include "Sema.h"
14#include "clang/Sema/CodeCompleteConsumer.h"
15
16using namespace clang;
17
18/// \brief Set the code-completion consumer for semantic analysis.
19void Sema::setCodeCompleteConsumer(CodeCompleteConsumer *CCC) {
20 assert(((CodeCompleter != 0) != (CCC != 0)) &&
21 "Already set or cleared a code-completion consumer?");
22 CodeCompleter = CCC;
23}
24
25void Sema::CodeCompleteMemberReferenceExpr(Scope *S, ExprTy *BaseE,
26 SourceLocation OpLoc,
27 bool IsArrow) {
28 if (!BaseE || !CodeCompleter)
29 return;
30
31 Expr *Base = static_cast<Expr *>(BaseE);
32 QualType BaseType = Base->getType();
33
34 CodeCompleter->CodeCompleteMemberReferenceExpr(S, BaseType, IsArrow);
35}
36
Douglas Gregor374929f2009-09-18 15:37:17 +000037void Sema::CodeCompleteTag(Scope *S, unsigned TagSpec) {
38 if (!CodeCompleter)
39 return;
40
41 TagDecl::TagKind TK;
42 switch ((DeclSpec::TST)TagSpec) {
43 case DeclSpec::TST_enum:
44 TK = TagDecl::TK_enum;
45 break;
46
47 case DeclSpec::TST_union:
48 TK = TagDecl::TK_union;
49 break;
50
51 case DeclSpec::TST_struct:
52 TK = TagDecl::TK_struct;
53 break;
54
55 case DeclSpec::TST_class:
56 TK = TagDecl::TK_class;
57 break;
58
59 default:
60 assert(false && "Unknown type specifier kind in CodeCompleteTag");
61 return;
62 }
63 CodeCompleter->CodeCompleteTag(S, TK);
64}
65
Douglas Gregor81b747b2009-09-17 21:32:03 +000066void Sema::CodeCompleteQualifiedId(Scope *S, const CXXScopeSpec &SS,
67 bool EnteringContext) {
68 if (!SS.getScopeRep() || !CodeCompleter)
69 return;
70
71 CodeCompleter->CodeCompleteQualifiedId(S,
72 (NestedNameSpecifier *)SS.getScopeRep(),
73 EnteringContext);
74}
Douglas Gregor49f40bd2009-09-18 19:03:04 +000075
76void Sema::CodeCompleteUsing(Scope *S) {
77 if (!CodeCompleter)
78 return;
79
80 CodeCompleter->CodeCompleteUsing(S);
81}
82
83void Sema::CodeCompleteUsingDirective(Scope *S) {
84 if (!CodeCompleter)
85 return;
86
87 CodeCompleter->CodeCompleteUsingDirective(S);
88}
89
90void Sema::CodeCompleteNamespaceDecl(Scope *S) {
91 if (!CodeCompleter)
92 return;
93
94 CodeCompleter->CodeCompleteNamespaceDecl(S);
95}
96
97void Sema::CodeCompleteNamespaceAliasDecl(Scope *S) {
98 if (!CodeCompleter)
99 return;
100
101 CodeCompleter->CodeCompleteNamespaceAliasDecl(S);
102}
103
104