[cfe-commits] r89168 - in /cfe/trunk: lib/Sema/SemaCodeComplete.cpp test/Index/complete-objc-message.m
Douglas Gregor
dgregor at apple.com
Tue Nov 17 16:06:18 PST 2009
Author: dgregor
Date: Tue Nov 17 18:06:18 2009
New Revision: 89168
URL: http://llvm.org/viewvc/llvm-project?rev=89168&view=rev
Log:
Finish code completion for Objective-C message sends
Modified:
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/Index/complete-objc-message.m
Modified: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCodeComplete.cpp?rev=89168&r1=89167&r2=89168&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp Tue Nov 17 18:06:18 2009
@@ -1704,24 +1704,42 @@
return;
}
- const ObjCObjectPointerType* OCOPT
- = ReceiverType->getAs<ObjCObjectPointerType>();
- if (!OCOPT)
- return;
-
- // FIXME: handle 'id', 'Class', and qualified types.
-
// Build the set of methods we can see.
ResultBuilder Results(*this);
Results.EnterNewScope();
-
- ObjCInterfaceDecl *CDecl = OCOPT->getInterfaceDecl();
- if (!CDecl)
- return;
- AddObjCMethods(CDecl, true, CurContext, Results);
- Results.ExitScope();
+ // Handle messages to Class. This really isn't a message to an instance
+ // method, so we treat it the same way we would treat a message send to a
+ // class method.
+ if (ReceiverType->isObjCClassType() ||
+ ReceiverType->isObjCQualifiedClassType()) {
+ if (ObjCMethodDecl *CurMethod = getCurMethodDecl()) {
+ if (ObjCInterfaceDecl *ClassDecl = CurMethod->getClassInterface())
+ AddObjCMethods(ClassDecl, false, CurContext, Results);
+ }
+ }
+ // Handle messages to a qualified ID ("id<foo>").
+ else if (const ObjCObjectPointerType *QualID
+ = ReceiverType->getAsObjCQualifiedIdType()) {
+ // Search protocols for instance methods.
+ for (ObjCObjectPointerType::qual_iterator I = QualID->qual_begin(),
+ E = QualID->qual_end();
+ I != E; ++I)
+ AddObjCMethods(*I, true, CurContext, Results);
+ }
+ // Handle messages to a pointer to interface type.
+ else if (const ObjCObjectPointerType *IFacePtr
+ = ReceiverType->getAsObjCInterfacePointerType()) {
+ // Search the class, its superclasses, etc., for instance methods.
+ AddObjCMethods(IFacePtr->getInterfaceDecl(), true, CurContext, Results);
+
+ // Search protocols for instance methods.
+ for (ObjCObjectPointerType::qual_iterator I = IFacePtr->qual_begin(),
+ E = IFacePtr->qual_end();
+ I != E; ++I)
+ AddObjCMethods(*I, true, CurContext, Results);
+ }
- // This also suppresses remaining diagnostics.
+ Results.ExitScope();
HandleCodeCompleteResults(this, CodeCompleter, Results.data(),Results.size());
}
Modified: cfe/trunk/test/Index/complete-objc-message.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/complete-objc-message.m?rev=89168&r1=89167&r2=89168&view=diff
==============================================================================
--- cfe/trunk/test/Index/complete-objc-message.m (original)
+++ cfe/trunk/test/Index/complete-objc-message.m Tue Nov 17 18:06:18 2009
@@ -74,6 +74,14 @@
[super MyInstMethod: super second:super];
}
+ at protocol FooTestProtocol2
+- (int)secondProtocolInstanceMethod;
+ at end
+
+void test_qual_id(id<FooTestProtocol,FooTestProtocol2> ptr) {
+ [ptr protocolInstanceMethod:1];
+}
+
// RUN: c-index-test -code-completion-at=%s:23:19 %s | FileCheck -check-prefix=CHECK-CC1 %s
// CHECK-CC1: {TypedText categoryClassMethod}
// CHECK-CC1: {TypedText classMethod1:}{Placeholder (id)a}{Text withKeyword:}{Placeholder (int)b}
@@ -93,4 +101,7 @@
// RUN: c-index-test -code-completion-at=%s:74:9 %s | FileCheck -check-prefix=CHECK-CC5 %s
// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText MyInstMethod:}{Placeholder (id)x}{Text second:}{Placeholder (id)y}
// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText MySubInstMethod}
+// RUN: c-index-test -code-completion-at=%s:82:8 %s | FileCheck -check-prefix=CHECK-CC6 %s
+// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText protocolInstanceMethod:}{Placeholder (int)value}
+// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText secondProtocolInstanceMethod}
More information about the cfe-commits
mailing list