diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-06-02 04:02:27 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-06-02 04:02:27 +0000 |
commit | 857bcdaf03f19fb79feced2721ef3e6efed11b39 (patch) | |
tree | ec36cae0c331eb77fe47415a610ded5df74af3ca | |
parent | d6860522b21dd8f7e2c9b224b04bc01d6c4c523a (diff) | |
download | bcm5719-llvm-857bcdaf03f19fb79feced2721ef3e6efed11b39.tar.gz bcm5719-llvm-857bcdaf03f19fb79feced2721ef3e6efed11b39.zip |
Tweak code completions for Objective-C Key-Value Observing. The
+keyPathsForValuesAffecting<Key> completion was mislabeled as an
instance method, and +automaticallyNotifiesObserversOf<Key> was
missing entirely. Fixes <rdar://problem/9516762>.
llvm-svn: 132452
-rw-r--r-- | clang/lib/Sema/SemaCodeComplete.cpp | 23 | ||||
-rw-r--r-- | clang/test/Index/complete-kvc.m | 4 |
2 files changed, 25 insertions, 2 deletions
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index 4989b2b4143..294c7934f8d 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -6188,7 +6188,28 @@ static void AddObjCKeyValueCompletions(ObjCPropertyDecl *Property, Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName)); Results.AddResult(Result(Builder.TakeString(), CCP_CodePattern, - CXCursor_ObjCInstanceMethodDecl)); + CXCursor_ObjCClassMethodDecl)); + } + } + + // + (BOOL)automaticallyNotifiesObserversForKey + if (!IsInstanceMethod && + (ReturnType.isNull() || + ReturnType->isIntegerType() || + ReturnType->isBooleanType())) { + std::string SelectorName + = (llvm::Twine("automaticallyNotifiesObserversOf") + UpperKey).str(); + IdentifierInfo *SelectorId = &Context.Idents.get(SelectorName); + if (KnownSelectors.insert(Selectors.getNullarySelector(SelectorId))) { + if (ReturnType.isNull()) { + Builder.AddChunk(CodeCompletionString::CK_LeftParen); + Builder.AddTextChunk("BOOL"); + Builder.AddChunk(CodeCompletionString::CK_RightParen); + } + + Builder.AddTypedTextChunk(Allocator.CopyString(SelectorName)); + Results.AddResult(Result(Builder.TakeString(), CCP_CodePattern, + CXCursor_ObjCClassMethodDecl)); } } } diff --git a/clang/test/Index/complete-kvc.m b/clang/test/Index/complete-kvc.m index 5ff36487e18..62d98a9b207 100644 --- a/clang/test/Index/complete-kvc.m +++ b/clang/test/Index/complete-kvc.m @@ -95,7 +95,9 @@ typedef signed char BOOL; // CHECK-CC1: ObjCInstanceMethodDecl:{LeftParen (}{Text void}{RightParen )}{TypedText replaceObjectInMySetPropertyAtIndex:}{LeftParen (}{Placeholder NSUInteger}{RightParen )}{Text index}{HorizontalSpace }{TypedText withObject:}{LeftParen (}{Text id}{RightParen )}{Text object} (55) // RUN: c-index-test -code-completion-at=%s:41:3 %s | FileCheck -check-prefix=CHECK-CC2 %s -// CHECK-CC2: ObjCInstanceMethodDecl:{LeftParen (}{Text NSSet *}{RightParen )}{TypedText keyPathsForValuesAffectingMutableArrayProperty} (40) +// CHECK-CC2: ObjCClassMethodDecl:{LeftParen (}{Text BOOL}{RightParen )}{TypedText automaticallyNotifiesObserversOfArrayProperty} (40) +// CHECK-CC2: ObjCClassMethodDecl:{LeftParen (}{Text BOOL}{RightParen )}{TypedText automaticallyNotifiesObserversOfMutableArrayProperty} (40) +// CHECK-CC2: ObjCClassMethodDecl:{LeftParen (}{Text NSSet *}{RightParen )}{TypedText keyPathsForValuesAffectingMutableArrayProperty} (40) // RUN: c-index-test -code-completion-at=%s:52:8 %s | FileCheck -check-prefix=CHECK-CC3 %s // CHECK-CC3: ObjCInstanceMethodDecl:{TypedText countOfIntProperty} (55) |