blob: 8f235d39bec2fa524cae907f56ce7d1754dca170 [file] [log] [blame]
Douglas Gregor9630eb62009-11-17 16:44:22 +00001// 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}
Douglas Gregor24a069f2009-11-17 17:59:40 +000026
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
Douglas Gregorf74a4192009-11-18 00:06:18 +000077@protocol FooTestProtocol2
78- (int)secondProtocolInstanceMethod;
79@end
80
81void test_qual_id(id<FooTestProtocol,FooTestProtocol2> ptr) {
82 [ptr protocolInstanceMethod:1];
83}
84
Douglas Gregor9630eb62009-11-17 16:44:22 +000085// RUN: c-index-test -code-completion-at=%s:23:19 %s | FileCheck -check-prefix=CHECK-CC1 %s
86// CHECK-CC1: {TypedText categoryClassMethod}
Douglas Gregor36ecb042009-11-17 23:22:23 +000087// CHECK-CC1: {TypedText classMethod1:}{Placeholder (id)a}{Text withKeyword:}{Placeholder (int)b}
Douglas Gregor9630eb62009-11-17 16:44:22 +000088// CHECK-CC1: {TypedText classMethod2}
89// CHECK-CC1: {TypedText new}
90// CHECK-CC1: {TypedText protocolClassMethod}
Douglas Gregor9630eb62009-11-17 16:44:22 +000091// RUN: c-index-test -code-completion-at=%s:24:8 %s | FileCheck -check-prefix=CHECK-CC2 %s
92// CHECK-CC2: {TypedText categoryInstanceMethod}
93// CHECK-CC2: {TypedText instanceMethod1}
94// CHECK-CC2: {TypedText protocolInstanceMethod:}{Placeholder (int)value}
Douglas Gregor24a069f2009-11-17 17:59:40 +000095// RUN: c-index-test -code-completion-at=%s:61:16 %s | FileCheck -check-prefix=CHECK-CC3 %s
96// CHECK-CC3: ObjCClassMethodDecl:{TypedText MyClassMethod:}{Placeholder (id)obj}
Douglas Gregor36ecb042009-11-17 23:22:23 +000097// CHECK-CC3: ObjCClassMethodDecl:{TypedText MyPrivateMethod}
Douglas Gregor24a069f2009-11-17 17:59:40 +000098// RUN: c-index-test -code-completion-at=%s:65:16 %s | FileCheck -check-prefix=CHECK-CC4 %s
99// CHECK-CC4: ObjCInstanceMethodDecl:{TypedText MyInstMethod:}{Placeholder (id)x}{Text second:}{Placeholder (id)y}
Douglas Gregor36ecb042009-11-17 23:22:23 +0000100// CHECK-CC4: ObjCInstanceMethodDecl:{TypedText MyPrivateInstMethod}
Douglas Gregor24a069f2009-11-17 17:59:40 +0000101// RUN: c-index-test -code-completion-at=%s:74:9 %s | FileCheck -check-prefix=CHECK-CC5 %s
Douglas Gregor24a069f2009-11-17 17:59:40 +0000102// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText MyInstMethod:}{Placeholder (id)x}{Text second:}{Placeholder (id)y}
Douglas Gregor36ecb042009-11-17 23:22:23 +0000103// CHECK-CC5: ObjCInstanceMethodDecl:{TypedText MySubInstMethod}
Douglas Gregorf74a4192009-11-18 00:06:18 +0000104// RUN: c-index-test -code-completion-at=%s:82:8 %s | FileCheck -check-prefix=CHECK-CC6 %s
105// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText protocolInstanceMethod:}{Placeholder (int)value}
106// CHECK-CC6: ObjCInstanceMethodDecl:{TypedText secondProtocolInstanceMethod}
Douglas Gregor24a069f2009-11-17 17:59:40 +0000107