diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-09-18 15:16:27 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-09-18 15:16:27 +0000 |
commit | 97fe61ca1749110c28eb4570a710c8983711c7b3 (patch) | |
tree | d633ec7ae41ad70f3d18638d2c302e6595d2b1a1 | |
parent | 38c9b1765c56406e97510889b465b7885ccb59f3 (diff) |
Give the Objective-C _cmd an "unlikely" code completion priority; it's
very rarely used.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114286 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Sema/CodeCompleteConsumer.h | 5 | ||||
-rw-r--r-- | lib/Sema/CodeCompleteConsumer.cpp | 10 | ||||
-rw-r--r-- | test/Index/complete-exprs.m | 15 |
3 files changed, 28 insertions, 2 deletions
diff --git a/include/clang/Sema/CodeCompleteConsumer.h b/include/clang/Sema/CodeCompleteConsumer.h index 9a388a294b..c251cedaf3 100644 --- a/include/clang/Sema/CodeCompleteConsumer.h +++ b/include/clang/Sema/CodeCompleteConsumer.h @@ -59,7 +59,10 @@ enum { CCP_NestedNameSpecifier = 75, /// \brief Priority for a result that isn't likely to be what the user wants, /// but is included for completeness. - CCP_Unlikely = 80 + CCP_Unlikely = 80, + + /// \brief Priority for the Objective-C "_cmd" implicit parameter. + CCP_ObjC_cmd = CCP_Unlikely }; /// \brief Priority value deltas that are added to code-completion results diff --git a/lib/Sema/CodeCompleteConsumer.cpp b/lib/Sema/CodeCompleteConsumer.cpp index 58a1627b47..3322782d87 100644 --- a/lib/Sema/CodeCompleteConsumer.cpp +++ b/lib/Sema/CodeCompleteConsumer.cpp @@ -389,8 +389,15 @@ unsigned CodeCompletionResult::getPriorityFromDecl(NamedDecl *ND) { // Context-based decisions. DeclContext *DC = ND->getDeclContext()->getRedeclContext(); - if (DC->isFunctionOrMethod() || isa<BlockDecl>(DC)) + if (DC->isFunctionOrMethod() || isa<BlockDecl>(DC)) { + // _cmd is relatively rare + if (ImplicitParamDecl *ImplicitParam = dyn_cast<ImplicitParamDecl>(ND)) + if (ImplicitParam->getIdentifier() && + ImplicitParam->getIdentifier()->isStr("_cmd")) + return CCP_ObjC_cmd; + return CCP_LocalDeclaration; + } if (DC->isRecord() || isa<ObjCContainerDecl>(DC)) return CCP_MemberDeclaration; @@ -399,6 +406,7 @@ unsigned CodeCompletionResult::getPriorityFromDecl(NamedDecl *ND) { return CCP_Constant; if (isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND)) return CCP_Type; + return CCP_Declaration; } diff --git a/test/Index/complete-exprs.m b/test/Index/complete-exprs.m new file mode 100644 index 0000000000..0171803ffe --- /dev/null +++ b/test/Index/complete-exprs.m @@ -0,0 +1,15 @@ +@interface A +- (int)method:(id)param1; + +@property int prop1; +@end + +@implementation A +- (int)method:(id)param1 { + +} +@end + +// RUN: c-index-test -code-completion-at=%s:9:2 %s | FileCheck -check-prefix=CHECK-CC1 %s +// CHECK-CC1: NotImplemented:{ResultType SEL}{TypedText _cmd} (80) +// CHECK-CC1: NotImplemented:{ResultType A *}{TypedText self} (8) |