diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-09-14 23:59:36 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-09-14 23:59:36 +0000 |
commit | 0268810a46780144a2d5fb5a017c938d1199189c (patch) | |
tree | 6e06d1b58bdb7854ca6481a14459e3ef339e93bf /lib/Frontend/ASTUnit.cpp | |
parent | 6c52c7850bccb6991470668429a1e1edf01b0873 (diff) |
Introduce a new code-completion context for a parenthesized
expression, e.g., after the '(' that could also be a type cast. Here,
we provide types as code-completion results in C/Objective-C (C++
already had them), although we wouldn't in a normal expression context.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@113904 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/ASTUnit.cpp')
-rw-r--r-- | lib/Frontend/ASTUnit.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index c203ffa935..926e017f16 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -115,7 +115,8 @@ static unsigned getDeclShowContexts(NamedDecl *ND, | (1 << (CodeCompletionContext::CCC_ObjCIvarList - 1)) | (1 << (CodeCompletionContext::CCC_ClassStructUnion - 1)) | (1 << (CodeCompletionContext::CCC_Statement - 1)) - | (1 << (CodeCompletionContext::CCC_Type - 1)); + | (1 << (CodeCompletionContext::CCC_Type - 1)) + | (1 << (CodeCompletionContext::CCC_ParenthesizedExpression - 1)); // In C++, types can appear in expressions contexts (for functional casts). if (LangOpts.CPlusPlus) @@ -147,6 +148,7 @@ static unsigned getDeclShowContexts(NamedDecl *ND, // Values can appear in these contexts. Contexts = (1 << (CodeCompletionContext::CCC_Statement - 1)) | (1 << (CodeCompletionContext::CCC_Expression - 1)) + | (1 << (CodeCompletionContext::CCC_ParenthesizedExpression - 1)) | (1 << (CodeCompletionContext::CCC_ObjCMessageReceiver - 1)); } else if (isa<ObjCProtocolDecl>(ND)) { Contexts = (1 << (CodeCompletionContext::CCC_ObjCProtocolName - 1)); @@ -237,7 +239,8 @@ void ASTUnit::CacheCodeCompletionResults() { | (1 << (CodeCompletionContext::CCC_UnionTag - 1)) | (1 << (CodeCompletionContext::CCC_ClassOrStructTag - 1)) | (1 << (CodeCompletionContext::CCC_Type - 1)) - | (1 << (CodeCompletionContext::CCC_PotentiallyQualifiedName - 1)); + | (1 << (CodeCompletionContext::CCC_PotentiallyQualifiedName - 1)) + | (1 << (CodeCompletionContext::CCC_ParenthesizedExpression - 1)); if (isa<NamespaceDecl>(Results[I].Declaration) || isa<NamespaceAliasDecl>(Results[I].Declaration)) @@ -279,7 +282,9 @@ void ASTUnit::CacheCodeCompletionResults() { | (1 << (CodeCompletionContext::CCC_Expression - 1)) | (1 << (CodeCompletionContext::CCC_ObjCMessageReceiver - 1)) | (1 << (CodeCompletionContext::CCC_MacroNameUse - 1)) - | (1 << (CodeCompletionContext::CCC_PreprocessorExpression - 1)); + | (1 << (CodeCompletionContext::CCC_PreprocessorExpression - 1)) + | (1 << (CodeCompletionContext::CCC_ParenthesizedExpression - 1)); + CachedResult.Priority = Results[I].Priority; CachedResult.Kind = Results[I].CursorKind; @@ -1517,8 +1522,9 @@ namespace { | (1 << (CodeCompletionContext::CCC_Expression - 1)) | (1 << (CodeCompletionContext::CCC_ObjCMessageReceiver - 1)) | (1 << (CodeCompletionContext::CCC_MemberAccess - 1)) - | (1 << (CodeCompletionContext::CCC_ObjCProtocolName - 1)); - + | (1 << (CodeCompletionContext::CCC_ObjCProtocolName - 1)) + | (1 << (CodeCompletionContext::CCC_ParenthesizedExpression - 1)); + if (AST.getASTContext().getLangOptions().CPlusPlus) NormalContexts |= (1 << (CodeCompletionContext::CCC_EnumTag - 1)) | (1 << (CodeCompletionContext::CCC_UnionTag - 1)) @@ -1561,6 +1567,7 @@ void CalculateHiddenNames(const CodeCompletionContext &Context, case CodeCompletionContext::CCC_Type: case CodeCompletionContext::CCC_Name: case CodeCompletionContext::CCC_PotentiallyQualifiedName: + case CodeCompletionContext::CCC_ParenthesizedExpression: break; case CodeCompletionContext::CCC_EnumTag: |