complete-objc-message.m revision 8e254cfe5a6ab4202c7fcc4b64bdd1ca0fe071ac
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 54MyClass *getMyClass(); 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@interface Ellipsis 99- (int)Method:(int)i, ...; 100@end 101 102void f(Ellipsis *e) { 103 [e Method:1, 2, 3]; 104} 105 106@interface Overload2 107+ (int)Method:(int)i; 108+ (int)Method; 109+ (int)Method:(float)f Arg1:(int)i1 Arg2:(int)i2; 110+ (int)Method:(float)f Arg1:(int)i1 OtherArg:(id)obj; 111+ (int)Method:(float)f SomeArg:(int)i1 OtherArg:(id)obj; 112+ (int)OtherMethod:(float)f Arg1:(int)i1 Arg2:(int)i2; 113@end 114 115void test_overload2(void) { 116 [Overload2 Method:1 Arg1:1 OtherArg:ovl]; 117} 118 119void msg_id(id x) { 120 [x Method:1 Arg1:1 OtherArg:ovl]; 121 [[x blarg] Method:1 Arg1:1 OtherArg:ovl]; 122 [id Method:1 Arg1:1 OtherArg:ovl]; 123} 124 125// RUN: c-index-test -code-completion-at=%s:23:19 %s | FileCheck -check-prefix=CHECK-CC1 %s 126// CHECK-CC1: {TypedText categoryClassMethod} 127// CHECK-CC1: {TypedText classMethod1:}{Placeholder (id)a}{HorizontalSpace }{Text withKeyword:}{Placeholder (int)b} 128// CHECK-CC1: {TypedText classMethod2} 129// CHECK-CC1: {TypedText new} 130// CHECK-CC1: {TypedText protocolClassMethod} 131// RUN: c-index-test -code-completion-at=%s:24:8 %s | FileCheck -check-prefix=CHECK-CC2 %s 132// CHECK-CC2: {TypedText categoryInstanceMethod} 133// CHECK-CC2: {TypedText instanceMethod1} 134// CHECK-CC2: {TypedText protocolInstanceMethod:}{Placeholder (int)value} 135// RUN: c-index-test -code-completion-at=%s:61:16 %s | FileCheck -check-prefix=CHECK-CC3 %s 136// CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)obj} 137// CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyPrivateMethod} 138// RUN: c-index-test -code-completion-at=%s:65:16 %s | FileCheck -check-prefix=CHECK-CC4 %s 139// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)x}{HorizontalSpace }{Text second:}{Placeholder (id)y} 140// CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyPrivateInstMethod} 141// RUN: c-index-test -code-completion-at=%s:74:9 %s | FileCheck -check-prefix=CHECK-CC5 %s 142// CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)x}{HorizontalSpace }{Text second:}{Placeholder (id)y} 143// CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod} 144// RUN: c-index-test -code-completion-at=%s:82:8 %s | FileCheck -check-prefix=CHECK-CC6 %s 145// CHECK-CC6: ObjCInstanceMethodDecl:{ResultType id}{TypedText protocolInstanceMethod:}{Placeholder (int)value} 146// CHECK-CC6: ObjCInstanceMethodDecl:{ResultType int}{TypedText secondProtocolInstanceMethod} 147// RUN: c-index-test -code-completion-at=%s:95:8 %s | FileCheck -check-prefix=CHECK-CC7 %s 148// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method} 149// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i} 150// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} 151// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} 152// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} 153// CHECK-CC7: ObjCInstanceMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} 154// RUN: c-index-test -code-completion-at=%s:95:17 %s | FileCheck -check-prefix=CHECK-CC8 %s 155// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText } 156// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} 157// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} 158// CHECK-CC8: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{TypedText SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} 159// RUN: c-index-test -code-completion-at=%s:95:24 %s | FileCheck -check-prefix=CHECK-CC9 %s 160// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText Arg2:}{Placeholder (int)i2} 161// CHECK-CC9: ObjCInstanceMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText OtherArg:}{Placeholder (id)obj} 162// RUN: c-index-test -code-completion-at=%s:61:11 %s | FileCheck -check-prefix=CHECK-CCA %s 163// CHECK-CCA: TypedefDecl:{TypedText Class} 164// CHECK-CCA-NEXT: ObjCInterfaceDecl:{TypedText Foo} 165// CHECK-CCA-NOT: FunctionDecl:{ResultType void}{TypedText func}{LeftParen (}{RightParen )} 166// CHECK-CCA:FunctionDecl:{ResultType MyClass *}{TypedText getMyClass}{LeftParen (}{RightParen )} 167// CHECK-CCA: TypedefDecl:{TypedText id} 168// CHECK-CCA: ObjCInterfaceDecl:{TypedText MyClass} 169// CHECK-CCA: ObjCInterfaceDecl:{TypedText MySubClass} 170// CHECK-CCA: {ResultType Class}{TypedText self} 171// CHECK-CCA: {TypedText super} 172// RUN: c-index-test -code-completion-at=%s:103:6 %s | FileCheck -check-prefix=CHECK-CCB %s 173// CHECK-CCB: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i}{Placeholder , ...} 174// RUN: c-index-test -code-completion-at=%s:116:14 %s | FileCheck -check-prefix=CHECK-CCC %s 175// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method} 176// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i} 177// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} 178// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} 179// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} 180// CHECK-CCC: ObjCClassMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} 181// RUN: c-index-test -code-completion-at=%s:116:23 %s | FileCheck -check-prefix=CHECK-CCD %s 182// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText } 183// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} 184// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} 185// CHECK-CCD: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{TypedText SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} 186// RUN: c-index-test -code-completion-at=%s:116:30 %s | FileCheck -check-prefix=CHECK-CCE %s 187// CHECK-CCE: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText Arg2:}{Placeholder (int)i2} 188// CHECK-CCE: ObjCClassMethodDecl:{ResultType int}{Informative Method:}{Informative Arg1:}{TypedText OtherArg:}{Placeholder (id)obj} 189// RUN: c-index-test -code-completion-at=%s:61:11 %s | FileCheck -check-prefix=CHECK-CCF %s 190// CHECK-CCF: TypedefDecl:{TypedText Class} 191// CHECK-CCF: ObjCInterfaceDecl:{TypedText Foo} 192// CHECK-CCF-NOT: FunctionDecl:{ResultType void}{TypedText func}{LeftParen (}{RightParen )} 193// CHECK-CCF: TypedefDecl:{TypedText id} 194// CHECK-CCF: ObjCInterfaceDecl:{TypedText MyClass} 195// CHECK-CCF: ObjCInterfaceDecl:{TypedText MySubClass} 196// CHECK-CCF: {ResultType Class}{TypedText self} 197// CHECK-CCF: {TypedText super} 198// RUN: c-index-test -code-completion-at=%s:120:6 %s | FileCheck -check-prefix=CHECK-CCG %s 199// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText categoryInstanceMethod} 200// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText instanceMethod1} 201// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method} 202// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i} 203// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} 204// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} 205// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} 206// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)x}{HorizontalSpace }{Text second:}{Placeholder (id)y} 207// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyPrivateInstMethod} 208// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod} 209// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod:}{Placeholder (id)obj} 210// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} 211// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType id}{TypedText protocolInstanceMethod:}{Placeholder (int)value} 212// CHECK-CCG: ObjCInstanceMethodDecl:{ResultType int}{TypedText secondProtocolInstanceMethod} 213// RUN: c-index-test -code-completion-at=%s:121:14 %s | FileCheck -check-prefix=CHECK-CCG %s 214// RUN: c-index-test -code-completion-at=%s:122:7 %s | FileCheck -check-prefix=CHECK-CCH %s 215// CHECK-CCH: ObjCClassMethodDecl:{ResultType id}{TypedText categoryClassMethod} 216// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText classMethod1:}{Placeholder (id)a}{HorizontalSpace }{Text withKeyword:}{Placeholder (int)b} 217// CHECK-CCH: ObjCClassMethodDecl:{ResultType void}{TypedText classMethod2} 218// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method} 219// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (int)i} 220// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} 221// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} 222// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText Method:}{Placeholder (float)f}{HorizontalSpace }{Text SomeArg:}{Placeholder (int)i1}{HorizontalSpace }{Text OtherArg:}{Placeholder (id)obj} 223// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)obj} 224// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MyPrivateMethod} 225// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MySubClassMethod} 226// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText MySubPrivateMethod} 227// CHECK-CCH: ObjCClassMethodDecl:{ResultType id}{TypedText new} 228// CHECK-CCH: ObjCClassMethodDecl:{ResultType int}{TypedText OtherMethod:}{Placeholder (float)f}{HorizontalSpace }{Text Arg1:}{Placeholder (int)i1}{HorizontalSpace }{Text Arg2:}{Placeholder (int)i2} 229// CHECK-CCH: ObjCClassMethodDecl:{ResultType id}{TypedText protocolClassMethod} 230