diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-01-10 23:08:15 +0000 | 
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-01-10 23:08:15 +0000 | 
| commit | 504a6ae83ee2a8d9ce7e6b470efc96822be3b2ed (patch) | |
| tree | feb17bfc435f7445a7d71caad2d6f7c8ebb40aa3 /clang/lib/Parse | |
| parent | ec144538ae3afdd2c56b9f9bee2cba73eec40dce (diff) | |
| download | bcm5719-llvm-504a6ae83ee2a8d9ce7e6b470efc96822be3b2ed.tar.gz bcm5719-llvm-504a6ae83ee2a8d9ce7e6b470efc96822be3b2ed.zip  | |
Improve code completion by introducing patterns for the various C and
C++ grammatical constructs that show up in top-level (namespace-level)
declarations, member declarations, template declarations, statements,
expressions, conditions, etc. For example, we now provide a pattern
for
  static_cast<type>(expr)
when we can have an expression, or
  using namespace identifier;
when we can have a using directive.
Also, improves the results of code completion at the beginning of a
top-level declaration. Previously, we would see value names (function
names, global variables, etc.); now we see types, namespace names,
etc., but no values.
llvm-svn: 93134
Diffstat (limited to 'clang/lib/Parse')
| -rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 9 | ||||
| -rw-r--r-- | clang/lib/Parse/ParseExpr.cpp | 10 | ||||
| -rw-r--r-- | clang/lib/Parse/ParseExprCXX.cpp | 5 | ||||
| -rw-r--r-- | clang/lib/Parse/ParseStmt.cpp | 6 | ||||
| -rw-r--r-- | clang/lib/Parse/Parser.cpp | 2 | 
5 files changed, 23 insertions, 9 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index f429ac991d8..bc6dda8ed79 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -814,7 +814,14 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,                                          AccessSpecifier AS,                                          DeclSpecContext DSContext) {    if (Tok.is(tok::code_completion)) { -    Actions.CodeCompleteOrdinaryName(CurScope); +    Action::CodeCompletionContext CCC = Action::CCC_Namespace; +    if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) +      CCC = DSContext == DSC_class? Action::CCC_MemberTemplate  +                                  : Action::CCC_Template; +    else if (DSContext == DSC_class) +      CCC = Action::CCC_Class; + +    Actions.CodeCompleteOrdinaryName(CurScope, CCC);      ConsumeToken();    } diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index 4d6988d5f2c..669575c4f03 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -200,11 +200,6 @@ static prec::Level getBinOpPrecedence(tok::TokenKind Kind,  ///         expression ',' assignment-expression  ///  Parser::OwningExprResult Parser::ParseExpression() { -  if (Tok.is(tok::code_completion)) { -    Actions.CodeCompleteOrdinaryName(CurScope); -    ConsumeToken(); -  } -    OwningExprResult LHS(ParseAssignmentExpression());    if (LHS.isInvalid()) return move(LHS); @@ -248,6 +243,11 @@ Parser::ParseExpressionWithLeadingExtension(SourceLocation ExtLoc) {  /// ParseAssignmentExpression - Parse an expr that doesn't include commas.  ///  Parser::OwningExprResult Parser::ParseAssignmentExpression() { +  if (Tok.is(tok::code_completion)) { +    Actions.CodeCompleteOrdinaryName(CurScope, Action::CCC_Expression); +    ConsumeToken(); +  } +    if (Tok.is(tok::kw_throw))      return ParseThrowExpression(); diff --git a/clang/lib/Parse/ParseExprCXX.cpp b/clang/lib/Parse/ParseExprCXX.cpp index abd26d7d490..3efa6f0180c 100644 --- a/clang/lib/Parse/ParseExprCXX.cpp +++ b/clang/lib/Parse/ParseExprCXX.cpp @@ -585,6 +585,11 @@ Parser::ParseCXXTypeConstructExpression(const DeclSpec &DS) {  /// \returns true if there was a parsing, false otherwise.  bool Parser::ParseCXXCondition(OwningExprResult &ExprResult,                                 DeclPtrTy &DeclResult) { +  if (Tok.is(tok::code_completion)) { +    Actions.CodeCompleteOrdinaryName(CurScope, Action::CCC_Condition); +    ConsumeToken(); +  } +    if (!isCXXConditionDeclaration()) {      ExprResult = ParseExpression(); // expression      DeclResult = DeclPtrTy(); diff --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp index 277cc91d37c..21e960aa817 100644 --- a/clang/lib/Parse/ParseStmt.cpp +++ b/clang/lib/Parse/ParseStmt.cpp @@ -95,7 +95,7 @@ Parser::ParseStatementOrDeclaration(bool OnlyStatement) {      }    case tok::code_completion: -    Actions.CodeCompleteOrdinaryName(CurScope); +    Actions.CodeCompleteOrdinaryName(CurScope, Action::CCC_Statement);      ConsumeToken();      return ParseStatementOrDeclaration(OnlyStatement); @@ -955,7 +955,9 @@ Parser::OwningStmtResult Parser::ParseForStatement(AttributeList *Attr) {    DeclPtrTy SecondVar;    if (Tok.is(tok::code_completion)) { -    Actions.CodeCompleteOrdinaryName(CurScope); +    Actions.CodeCompleteOrdinaryName(CurScope,  +                                     C99orCXXorObjC? Action::CCC_ForInit +                                                   : Action::CCC_Expression);      ConsumeToken();    } diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp index 52c0153bfad..bf0c7b286a7 100644 --- a/clang/lib/Parse/Parser.cpp +++ b/clang/lib/Parse/Parser.cpp @@ -455,7 +455,7 @@ Parser::DeclGroupPtrTy Parser::ParseExternalDeclaration(CXX0XAttributeList Attr)      SingleDecl = ParseObjCMethodDefinition();      break;    case tok::code_completion: -    Actions.CodeCompleteOrdinaryName(CurScope); +    Actions.CodeCompleteOrdinaryName(CurScope, Action::CCC_Namespace);      ConsumeToken();      return ParseExternalDeclaration(Attr);    case tok::kw_using:  | 

