File: fill-in-protocol-stubs-perform.m

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (196 lines) | stat: -rw-r--r-- 6,586 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
@protocol Proto1

- (void)requiredInstanceMethod:(int)y;

+ (void)aRequiredInstanceMethod:(int (*)(void))function with:(Proto *)p;

@optional;
- (void)anOptionalMethod;

@end

@protocol Proto2

- (void)a;

+ (void)b;

@end

@protocol Proto3

- (void)otherProtocolMethod:(int (^)(id<Proto2>))takesBlock;

@end

@interface Base
@end

@interface I1 : Base<Proto3>

@end
// CHECK1: "- (void)otherProtocolMethod:(int (^)(id<Proto2>))takesBlock;\n\n" [[@LINE-1]]:1 -> [[@LINE-1]]:1
// RUN: clang-refactor-test perform -action fill-in-missing-protocol-stubs -at=%s:29:1 %s | FileCheck --check-prefix=CHECK1 %s

@implementation I1

@end
// CHECK2: "- (void)otherProtocolMethod:(int (^)(id<Proto2>))takesBlock { \n  <#code#>\n}\n\n" [[@LINE-1]]:1 -> [[@LINE-1]]:1
// RUN: clang-refactor-test perform -action fill-in-missing-protocol-stubs -at=%s:35:1 %s | FileCheck --check-prefix=CHECK2 %s

@interface I2 : I1<Proto1, Proto2>

@end
// CHECK3: "+ (void)aRequiredInstanceMethod:(int (*)(void))function with:(id)p;\n\n- (void)requiredInstanceMethod:(int)y;\n\n- (void)a;\n\n+ (void)b;\n\n- (void)otherProtocolMethod:(int (^)(id<Proto2>))takesBlock;\n\n" [[@LINE-1]]:1 -> [[@LINE-1]]:1
// RUN: clang-refactor-test perform -action fill-in-missing-protocol-stubs -at=%s:41:1 %s | FileCheck --check-prefix=CHECK3 %s

@implementation I2

@end
// CHECK4: "+ (void)aRequiredInstanceMethod:(int (*)(void))function with:(id)p { \n  <#code#>\n}\n\n- (void)requiredInstanceMethod:(int)y { \n  <#code#>\n}\n\n- (void)a { \n  <#code#>\n}\n\n+ (void)b { \n  <#code#>\n}\n\n- (void)otherProtocolMethod:(int (^)(id<Proto2>))takesBlock { \n  <#code#>\n}\n\n" [[@LINE-1]]:1 -> [[@LINE-1]]:1
// RUN: clang-refactor-test perform -action fill-in-missing-protocol-stubs -at=%s:47:1 %s | FileCheck --check-prefix=CHECK4 %s

@interface I1(Category) <Proto2>
@end
// CHECK5: "- (void)a;\n\n+ (void)b;\n\n" [[@LINE-1]]:1 -> [[@LINE-1]]:1

@implementation I1(Category)
@end
// CHECK5-NEXT: "- (void)a { \n  <#code#>\n}\n\n+ (void)b { \n  <#code#>\n}\n\n" [[@LINE-1]]:1 -> [[@LINE-1]]:1
// RUN: clang-refactor-test perform -action fill-in-missing-protocol-stubs -at=%s:53:1 -at=%s:57:1 %s | FileCheck --check-prefix=CHECK5 %s

@interface I3 : I1<Proto1, Proto2>

- (void)requiredInstanceMethod:(int)y;

+ (void)b;

#ifdef HAS_OTHER
- (void) otherProtocolMethod:(int (^)(id<Proto2>))takesBlock;
#endif

@end
// CHECK6: "\n\n+ (void)aRequiredInstanceMethod:(int (*)(void))function with:(id)p;\n" [[@LINE-9]]:39 -> [[@LINE-9]]:39
// CHECK6-NEXT: "\n\n- (void)a;\n" [[@LINE-8]]:11 -> [[@LINE-8]]:11
// CHECK6-NEXT: "- (void)otherProtocolMethod:(int (^)(id<Proto2>))takesBlock;\n\n" [[@LINE-3]]:1 -> [[@LINE-3]]:1
// CHECK7: "\n\n+ (void)aRequiredInstanceMethod:(int (*)(void))function with:(id)p;\n" [[@LINE-12]]:39 -> [[@LINE-12]]:39
// CHECK7-NEXT: "\n\n- (void)a;\n" [[@LINE-11]]:11 -> [[@LINE-11]]:11

@implementation I3

- (void)requiredInstanceMethod:(int)y {
}

+ (void)b {
}

#ifdef HAS_OTHER
- (void) otherProtocolMethod:(int (^)(id<Proto2>))takesBlock { }
#endif

@end
// CHECK6: "\n\n+ (void)aRequiredInstanceMethod:(int (*)(void))function with:(id)p { \n  <#code#>\n}\n" [[@LINE-10]]:2 -> [[@LINE-10]]:2
// CHECK6-NEXT: "\n\n- (void)a { \n  <#code#>\n}\n" [[@LINE-8]]:2 -> [[@LINE-8]]:2
// CHECK6-NEXT: "- (void)otherProtocolMethod:(int (^)(id<Proto2>))takesBlock { \n  <#code#>\n}\n\n" [[@LINE-3]]:1 -> [[@LINE-3]]:1
// CHECK7: "\n\n+ (void)aRequiredInstanceMethod:(int (*)(void))function with:(id)p { \n  <#code#>\n}\n" [[@LINE-13]]:2 -> [[@LINE-13]]:2
// CHECK7-NEXT: "\n\n- (void)a { \n  <#code#>\n}\n" [[@LINE-11]]:2 -> [[@LINE-11]]:2

// RUN: clang-refactor-test perform -action fill-in-missing-protocol-stubs -at=%s:62:1 -at=%s:79:1 %s | FileCheck --check-prefix=CHECK6 %s
// RUN: clang-refactor-test perform -action fill-in-missing-protocol-stubs -at=%s:62:1 -at=%s:79:1 %s -DHAS_OTHER | FileCheck --check-prefix=CHECK7 %s

@protocol ProtoWith3Methods

- (void)a;
- (void)b;
- (void)c;

@end

@interface I4 : Base<ProtoWith3Methods>

#ifndef USE_MACRO
- (void)b;

- (void)a; // comment

#else

#define METHOD(name) -(void)name;

METHOD(b)
METHOD(c) - (void)d;

#endif

@end
// CHECK8: "\n\n- (void)c;\n" [[@LINE-12]]:22 ->  [[@LINE-12]]:22
// CHECK9: "\n\n- (void)a;\n" [[@LINE-6]]:10 -> [[@LINE-6]]:10

// RUN: clang-refactor-test perform -action fill-in-missing-protocol-stubs -at=%s:109:1 %s | FileCheck --check-prefix=CHECK8 %s
// RUN: clang-refactor-test perform -action fill-in-missing-protocol-stubs -at=%s:109:1 %s -D USE_MACRO | FileCheck --check-prefix=CHECK9 %s

@protocol NSObject

- (void)nsObjectMethod;

@end

@protocol SubProto

- (void)sub1;
- (id<SubProto>)sub2;

@end

@protocol SubProto2 <NSObject>

- (void)sub11;

@end

@protocol SuperProto <SubProto, NSObject, SubProto2>

@optional
- (void)mySub;

@end

@interface HasSubProtocolMethods: Base <SuperProto, NSObject>

@end
// CHECK10: "- (void)sub1;\n\n- (id<SubProto>)sub2;\n\n- (void)sub11;\n\n" [[@LINE-1]]:1 -> [[@LINE-1]]:1
// RUN: clang-refactor-test perform -action fill-in-missing-protocol-stubs -at=%s:158:1 %s | FileCheck --check-prefix=CHECK10 %s



@interface SuperClassWithSomeDecls : Base<SuperProto>

- (void)sub1;

@end

@interface SubClassOfSuperClassWithSomeDecls : SuperClassWithSomeDecls

#ifdef HAS_SUB1_OVERRIDE
- (void)sub1;
#endif
#ifdef HAS_SUB11
- (void)sub11;
#endif

@end
// CHECK11: "- (id<SubProto>)sub2;\n\n- (void)sub11;\n\n" [[@LINE-1]]:1
// CHECK12: "\n\n- (id<SubProto>)sub2;\n" [[@LINE-8]]:14
// CHECK12-NEXT: "- (void)sub11;\n\n" [[@LINE-3]]:1
// CHECK13: "- (id<SubProto>)sub2;\n\n" [[@LINE-4]]:1
// RUN: clang-refactor-test perform -action fill-in-missing-protocol-stubs -at=%s:172:1 %s | FileCheck --check-prefix=CHECK11 %s
// RUN: clang-refactor-test perform -action fill-in-missing-protocol-stubs -at=%s:172:1 %s -DHAS_SUB1_OVERRIDE | FileCheck --check-prefix=CHECK12 %s
// RUN: clang-refactor-test perform -action fill-in-missing-protocol-stubs -at=%s:172:1 %s -DHAS_SUB11 | FileCheck --check-prefix=CHECK13 %s

@implementation SubClassOfSuperClassWithSomeDecls

@end
// CHECK14: "- (id<SubProto>)sub2 { \n  <#code#>\n}\n\n- (void)sub11 { \n  <#code#>\n}\n\n" [[@LINE-1]]:1
// RUN: clang-refactor-test perform -action fill-in-missing-protocol-stubs -at=%s:190:1 %s | FileCheck --check-prefix=CHECK14 %s
// RUN: clang-refactor-test perform -action fill-in-missing-protocol-stubs -at=%s:190:1 %s -DHAS_SUB1_OVERRIDE | FileCheck --check-prefix=CHECK14 %s
// RUN: clang-refactor-test perform -action fill-in-missing-protocol-stubs -at=%s:190:1 %s -DHAS_SUB11 | FileCheck --check-prefix=CHECK14 %s