Douglas Gregor | 2436e71 | 2009-09-17 21:32:03 +0000 | [diff] [blame^] | 1 | //===---------------- 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 | |
| 16 | using namespace clang; |
| 17 | |
| 18 | /// \brief Set the code-completion consumer for semantic analysis. |
| 19 | void Sema::setCodeCompleteConsumer(CodeCompleteConsumer *CCC) { |
| 20 | assert(((CodeCompleter != 0) != (CCC != 0)) && |
| 21 | "Already set or cleared a code-completion consumer?"); |
| 22 | CodeCompleter = CCC; |
| 23 | } |
| 24 | |
| 25 | void 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 | |
| 37 | void Sema::CodeCompleteQualifiedId(Scope *S, const CXXScopeSpec &SS, |
| 38 | bool EnteringContext) { |
| 39 | if (!SS.getScopeRep() || !CodeCompleter) |
| 40 | return; |
| 41 | |
| 42 | CodeCompleter->CodeCompleteQualifiedId(S, |
| 43 | (NestedNameSpecifier *)SS.getScopeRep(), |
| 44 | EnteringContext); |
| 45 | } |