diff options
author | Douglas Gregor <dgregor@apple.com> | 2013-01-31 05:03:46 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2013-01-31 05:03:46 +0000 |
commit | 626799b2903a2ab7f58ed82f10153bad4e0f1b7f (patch) | |
tree | 2cecbc640ca4a4c4c2dd594e3e30b9c8b130faa2 /lib/Sema/SemaCodeComplete.cpp | |
parent | d1f09b482b3874be07dfe9dd24bfad98915989c3 (diff) |
When code completing in a statement, parenthesized expression, or
Objective-C message receiver, the user is as likely to want to write a
type name as any other declaration, so give types the same priority as
other declarations. Fixes <rdar://problem/12480600>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174038 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaCodeComplete.cpp')
-rw-r--r-- | lib/Sema/SemaCodeComplete.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 3f6393724e..04f6ba72fc 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -733,7 +733,15 @@ unsigned ResultBuilder::getBasePriority(const NamedDecl *ND) { if (isa<EnumConstantDecl>(ND)) return CCP_Constant; - if ((isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND))) + // Use CCP_Type for type declarations unless we're in a statement, Objective-C + // message receiver, or parenthesized expression context. There, it's as + // likely that the user will want to write a type as other declarations. + if ((isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) && + !(CompletionContext.getKind() == CodeCompletionContext::CCC_Statement || + CompletionContext.getKind() + == CodeCompletionContext::CCC_ObjCMessageReceiver || + CompletionContext.getKind() + == CodeCompletionContext::CCC_ParenthesizedExpression)) return CCP_Type; return CCP_Declaration; |