complete-objc-message.m revision ff5ce6eefc7c253ef6edf4d4bfc996fdd82d09aa
1// Note: the run lines follow their respective tests, since line/column 2// matter in this test. 3 4@protocol FooTestProtocol 5+ protocolClassMethod; 6- protocolInstanceMethod : (int)value; 7@end 8@interface Foo <FooTestProtocol> { 9 void *isa; 10} 11+ (int)classMethod1:a withKeyword:(int)b; 12+ (void)classMethod2; 13+ new; 14- instanceMethod1; 15@end 16 17@interface Foo (FooTestCategory) 18+ categoryClassMethod; 19- categoryInstanceMethod; 20@end 21 22void func() { 23 Foo *obj = [Foo new]; 24 [obj xx]; 25} 26 27@interface MyClass { } 28+ (int)MyClassMethod:(id)obj; 29- (int)MyInstMethod:(id)x second:(id)y; 30@end 31 32@interface MySubClass : MyClass { } 33+ (int)MySubClassMethod; 34- (int)MySubInstMethod; 35@end 36 37@implementation MyClass 38+ (int)MyClassMethod:(id)obj { 39 return 0; 40} 41 42+ (int)MyPrivateMethod { 43 return 1; 44} 45 46- (int)MyInstMethod:(id)x second:(id)y { 47 return 2; 48} 49 50- (int)MyPrivateInstMethod { 51 return 3; 52} 53@end 54 55@implementation MySubClass 56+ (int)MySubClassMethod { 57 return 2; 58} 59 60+ (int)MySubPrivateMethod { 61 return [super MyPrivateMethod]; 62} 63 64- (int)MySubInstMethod:(id)obj { 65 return [super MyInstMethod: obj second:obj]; 66} 67 68- (int)MyInstMethod:(id)x second:(id)y { 69 return 3; 70} 71@end 72 73void test_super_var(MySubClass *super) { 74 [super MyInstMethod: super second:super]; 75} 76 77@protocol FooTestProtocol2 78- (int)secondProtocolInstanceMethod; 79@end 80 81void test_qual_id(id<FooTestProtocol,FooTestProtocol2> ptr) { 82 [ptr protocolInstanceMethod:1]; 83} 84 85@interface Overload 86- (int)Method:(int)i; 87- (int)Method; 88- (int)Method:(float)f Arg1:(int)i1 Arg2:(int)i2; 89- (int)Method:(float)f Arg1:(int)i1 OtherArg:(id)obj; 90- (int)Method:(float)f SomeArg:(int)i1 OtherArg:(id)obj; 91- (int)OtherMethod:(float)f Arg1:(int)i1 Arg2:(int)i2; 92@end 93 94void test_overload(Overload *ovl) { 95 [ovl Method:1 Arg1:1 OtherArg:ovl]; 96} 97 98// RUN: c-index-test -code-completion-at=%s:23:19 %s | FileCheck -check-prefix=CHECK-CC1 %s 99// CHECK-CC1: {TypedText categoryClassMethod} 100// CHECK-CC1: {TypedText classMethod1:}{Placeholder (id)a}{Text withKeyword:}{Placeholder (int)b} 101// CHECK-CC1: {TypedText classMethod2} 102// CHECK-CC1: {TypedText new} 103// CHECK-CC1: {TypedText protocolClassMethod} 104// RUN: c-index-test -code-completion-at=%s:24:8 %s | FileCheck -check-prefix=CHECK-CC2 %s 105// CHECK-CC2: {TypedText categoryInstanceMethod} 106// CHECK-CC2: {TypedText instanceMethod1} 107// CHECK-CC2: {TypedText protocolInstanceMethod:}{Placeholder (int)value} 108// RUN: c-index-test -code-completion-at=%s:61:16 %s | FileCheck -check-prefix=CHECK-CC3 %s 109// CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)obj} 110// CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyPrivateMethod} 111// RUN: c-index-test -code-completion-at=%s:65:16 %s | FileCheck -check-prefix=CHECK-CC4 %s 112// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)x}{Text second:}{Placeholder (id)y} 113// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyPrivateInstMethod} 114// RUN: c-index-test -code-completion-at=%s:74:9 %s | FileCheck -check-prefix=CHECK-CC5 %s 115// CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)x}{Text second:}{Placeholder (id)y} 116// CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod} 117// RUN: c-index-test -code-completion-at=%s:82:8 %s | FileCheck -check-prefix=CHECK-CC6 %s 118// CHECK-CC6: ObjCInstanceMethodDecl:{ResultType id}{TypedText protocolInstanceMethod:}{Placeholder (int)value} 119// CHECK-CC6: ObjCInstanceMethodDecl:{ResultType int}{TypedText secondProtocolInstanceMethod} 120// RUN: c-index-test -code-completion-at=%s:95:8 %s | FileCheck -check-prefix=CHECK-CC7 %s 121// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method} 122// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i} 123// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{Text Arg1:}{Placeholder (int)i1}{Text Arg2:}{Placeholder (int)i2} 124// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{Text Arg1:}{Placeholder (int)i1}{Text OtherArg:}{Placeholder (id)obj} 125// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{Text SomeArg:}{Placeholder (int)i1}{Text OtherArg:}{Placeholder (id)obj} 126// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{Text Arg1:}{Placeholder (int)i1}{Text Arg2:}{Placeholder (int)i2} 127// RUN: c-index-test -code-completion-at=%s:95:17 %s | FileCheck -check-prefix=CHECK-CC8 %s 128// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText } 129// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{Text Arg2:}{Placeholder (int)i2} 130// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{Text OtherArg:}{Placeholder (id)obj} 131// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText SomeArg:}{Placeholder (int)i1}{Text OtherArg:}{Placeholder (id)obj} 132// RUN: c-index-test -code-completion-at=%s:95:24 %s | FileCheck -check-prefix=CHECK-CC9 %s 133// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText Arg2:}{Placeholder (int)i2} 134// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText OtherArg:}{Placeholder (id)obj} 135// RUN: c-index-test -code-completion-at=%s:61:11 %s | FileCheck -check-prefix=CHECK-CCA %s 136// CHECK-CCA: {ResultType SEL}{TypedText _cmd} 137// CHECK-CCA: {ResultType Class}{TypedText self} 138// CHECK-CCA: TypedefDecl:{TypedText Class} 139// CHECK-CCA: ObjCInterfaceDecl:{TypedText Foo} 140// CHECK-CCA: FunctionDecl:{ResultType void}{TypedText func}{LeftParen (}{RightParen )} 141// CHECK-CCA: TypedefDecl:{TypedText id} 142// CHECK-CCA: ObjCInterfaceDecl:{TypedText MyClass} 143// CHECK-CCA: ObjCInterfaceDecl:{TypedText MySubClass} 144// CHECK-CCA: TypedefDecl:{TypedText SEL} 145// CHECK-CCA: {TypedText super} 146