-
Notifications
You must be signed in to change notification settings - Fork 10.4k
/
Copy pathcomment_attach.swift
315 lines (252 loc) · 12.4 KB
/
comment_attach.swift
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
// NOTE: This file is sensitive to line numbers. Thus RUN and CHECK lines come
// below the code.
//
// NOTE: Please don't change this file to use FileCheck's feature to match
// relative line numbers: those lines are comments and we don't want to see
// anything extra in a test for documentation comments.
//===--- Check that we attach comments to all kinds of declarations.
/// decl_func_1 Aaa.
func decl_func_1() {}
/// decl_func_2 Aaa.
func decl_func_2<T>(t: T) {}
/// decl_func_3 Aaa.
@unknown_attribute
func decl_func_3() {}
@unknown_attribute
/// decl_func_4 Aaa. IS_DOC_NOT_ATTACHED
func decl_func_4() {}
@unknown_attribute
func
/// decl_func_5 Aaa. IS_DOC_NOT_ATTACHED
decl_func_5() {}
/// decl_var_1 Aaa.
var decl_var_1: Int
/// decl_var_2 decl_var_3 Aaa.
var (decl_var_2, decl_var_3): (Int, Float)
/// decl_var_4 Aaa.
@unknown_attribute
var decl_var_4: Int
/// decl_var_5 Aaa.
var decl_var_5: Int {
get {}
set {}
}
var decl_var_6: Int {
/// decl_var_6_get Aaa.
get {}
/// decl_var_6_set Aaa.
set {}
}
/// decl_var_7 Aaa.
var decl_var_7: Int = 0 {
willSet {}
didSet {}
}
var decl_var_8: Int = 0 {
/// decl_var_8_get Aaa.
willSet {}
/// decl_var_8_set Aaa.
didSet {}
}
/// decl_val_1 Aaa.
let decl_val_1: Int = 0
/// decl_val_2 decl_val_3 Aaa.
let (decl_val_2, decl_val_3): (Int, Float) = (0, 0.0)
/// decl_val_4 Aaa.
@unknown_attribute
let decl_val_4: Int = 0
/// decl_typealias_1 Aaa.
typealias decl_typealias_1 = Int
/// decl_struct_1 Aaa.
struct decl_struct_1 {
/// instanceVar1 Aaa.
var instanceVar1: Int
/// instanceVar2 instanceVar3 Aaa.
var (instanceVar2, instanceVar3): (Int, Float)
/// instanceVar4 Aaa.
@unknown_attribute
var instanceVar4: Int
/// instanceVar5 Aaa.
var instanceVar5: Int {
get {}
set {}
}
var instanceVar6: Int {
/// instanceVar6_get Aaa.
get {}
/// instanceVar6_set Aaa.
set {}
}
/// instanceVar7 Aaa.
var instanceVar7: Int = 0 {
willSet {}
didSet {}
}
var instanceVar8: Int = 0 {
/// instanceVar8_get Aaa.
willSet {}
/// instanceVar8_set Aaa.
didSet {}
}
/// instanceFunc1 Aaa.
func instanceFunc1() {}
/// instanceFunc2 Aaa.
@mutable
func instanceFunc2() {}
/// instanceFunc3 Aaa.
func instanceFunc3<T>(t: T) {}
/// instanceFunc4 Aaa.
@unknown_attribute
func instanceFunc4() {}
/// init(). Aaa.
init() {}
/// subscript Aaa.
subscript(i: Int) -> Double { return 0.0 }
/// NestedStruct Aaa.
struct NestedStruct {}
/// NestedClass Aaa.
class NestedClass {}
/// NestedEnum Aaa.
enum NestedEnum {}
// Cannot declare a nested protocol.
// protocol NestedProtocol {}
/// NestedTypealias Aaa.
typealias NestedTypealias = Int
/// staticVar Aaa.
static var staticVar: Int = 4
/// staticFunc1 Aaa.
static func staticFunc1() {}
}
/// decl_enum_1 Aaa.
enum decl_enum_1 {
/// Case1 Aaa.
case Case1
/// Case2 Aaa.
case Case2(Int)
/// Case3 Aaa.
case Case3(Int, Float)
/// Case4 Case5 Aaa.
case Case4, Case5
}
/// decl_class_1 Aaa.
class decl_class_1 {
}
/// decl_protocol_1 Aaa.
protocol decl_protocol_1 {
/// NestedTypealias Aaa.
associatedtype NestedTypealias
/// instanceFunc1 Aaa.
func instanceFunc1()
/// propertyWithGet Aaa.
var propertyWithGet: Int { get }
/// propertyWithGetSet Aaa.
var propertyWithGetSet: Int { get set }
}
// FIXME: While there is nothing stopping us from attaching comments to
// extensions, how would we use those comments?
/// decl_extension_1 Aaa.
extension decl_extension_1 {
}
/***/
func emptyBlockDocComment() {}
/**/
func weirdBlockDocComment() {}
/// docCommentWithGybLineNumber Aaa.
/// Bbb.
// ###line 1010
/// Ccc.
// ###line 1010
func docCommentWithGybLineNumber() {}
#sourceLocation(file: "custom.swuft", line: 2000)
/// Oooh, custom!
func customSourceLocation() {}
#sourceLocation() // reset
/**
func unterminatedBlockDocComment() {}
// RUN: %target-swift-ide-test -print-comments -source-filename %s > %t.txt
// RUN: %FileCheck %s -check-prefix=WRONG < %t.txt
// RUN: %FileCheck %s < %t.txt
// Some comments are not attached to anything.
// WRONG-NOT: IS_DOC_NOT_ATTACHED
// CHECK: comment_attach.swift:14:6: Func/decl_func_1 RawComment=[/// decl_func_1 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:17:6: Func/decl_func_2 RawComment=[/// decl_func_2 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:17:21: Param/t RawComment=none
// CHECK-NEXT: comment_attach.swift:21:6: Func/decl_func_3 RawComment=[/// decl_func_3 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:25:6: Func/decl_func_4 RawComment=none
// CHECK-NEXT: comment_attach.swift:30:3: Func/decl_func_5 RawComment=none
// CHECK-NEXT: comment_attach.swift:34:5: Var/decl_var_1 RawComment=[/// decl_var_1 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:37:6: Var/decl_var_2 RawComment=[/// decl_var_2 decl_var_3 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:37:18: Var/decl_var_3 RawComment=[/// decl_var_2 decl_var_3 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:41:5: Var/decl_var_4 RawComment=[/// decl_var_4 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:44:5: Var/decl_var_5 RawComment=[/// decl_var_5 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:45:3: Accessor/<getter for decl_var_5> RawComment=none
// CHECK-NEXT: comment_attach.swift:46:3: Accessor/<setter for decl_var_5> RawComment=none
// CHECK-NEXT: comment_attach.swift:49:5: Var/decl_var_6 RawComment=none
// CHECK-NEXT: comment_attach.swift:51:3: Accessor/<getter for decl_var_6> RawComment=none
// CHECK-NEXT: comment_attach.swift:53:3: Accessor/<setter for decl_var_6> RawComment=none
// CHECK-NEXT: comment_attach.swift:57:5: Var/decl_var_7 RawComment=[/// decl_var_7 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:58:3: Accessor/<willSet for decl_var_7> RawComment=none
// CHECK-NEXT: comment_attach.swift:59:3: Accessor/<didSet for decl_var_7> RawComment=none
// CHECK-NEXT: comment_attach.swift:62:5: Var/decl_var_8 RawComment=none
// CHECK-NEXT: comment_attach.swift:64:3: Accessor/<willSet for decl_var_8> RawComment=none
// CHECK-NEXT: comment_attach.swift:66:3: Accessor/<didSet for decl_var_8> RawComment=none
// CHECK-NEXT: comment_attach.swift:71:5: Var/decl_val_1 RawComment=[/// decl_val_1 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:74:6: Var/decl_val_2 RawComment=[/// decl_val_2 decl_val_3 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:74:18: Var/decl_val_3 RawComment=[/// decl_val_2 decl_val_3 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:78:5: Var/decl_val_4 RawComment=[/// decl_val_4 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:82:11: TypeAlias/decl_typealias_1 RawComment=[/// decl_typealias_1 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:85:8: Struct/decl_struct_1 RawComment=[/// decl_struct_1 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:87:7: Var/decl_struct_1.instanceVar1 RawComment=[/// instanceVar1 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:90:8: Var/decl_struct_1.instanceVar2 RawComment=[/// instanceVar2 instanceVar3 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:90:22: Var/decl_struct_1.instanceVar3 RawComment=[/// instanceVar2 instanceVar3 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:94:7: Var/decl_struct_1.instanceVar4 RawComment=[/// instanceVar4 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:97:7: Var/decl_struct_1.instanceVar5 RawComment=[/// instanceVar5 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:98:5: Accessor/decl_struct_1.<getter for decl_struct_1.instanceVar5> RawComment=none
// CHECK-NEXT: comment_attach.swift:99:5: Accessor/decl_struct_1.<setter for decl_struct_1.instanceVar5> RawComment=none
// CHECK-NEXT: comment_attach.swift:102:7: Var/decl_struct_1.instanceVar6 RawComment=none
// CHECK-NEXT: comment_attach.swift:104:5: Accessor/decl_struct_1.<getter for decl_struct_1.instanceVar6> RawComment=none
// CHECK-NEXT: comment_attach.swift:106:5: Accessor/decl_struct_1.<setter for decl_struct_1.instanceVar6> RawComment=none
// CHECK-NEXT: comment_attach.swift:110:7: Var/decl_struct_1.instanceVar7 RawComment=[/// instanceVar7 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:111:5: Accessor/decl_struct_1.<willSet for decl_struct_1.instanceVar7> RawComment=none
// CHECK-NEXT: comment_attach.swift:112:5: Accessor/decl_struct_1.<didSet for decl_struct_1.instanceVar7> RawComment=none
// CHECK-NEXT: comment_attach.swift:115:7: Var/decl_struct_1.instanceVar8 RawComment=none
// CHECK-NEXT: comment_attach.swift:117:5: Accessor/decl_struct_1.<willSet for decl_struct_1.instanceVar8> RawComment=none
// CHECK-NEXT: comment_attach.swift:119:5: Accessor/decl_struct_1.<didSet for decl_struct_1.instanceVar8> RawComment=none
// CHECK-NEXT: comment_attach.swift:124:8: Func/decl_struct_1.instanceFunc1 RawComment=[/// instanceFunc1 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:128:8: Func/decl_struct_1.instanceFunc2 RawComment=[/// instanceFunc2 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:131:8: Func/decl_struct_1.instanceFunc3 RawComment=[/// instanceFunc3 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:131:25: Param/t RawComment=none
// CHECK-NEXT: comment_attach.swift:135:8: Func/decl_struct_1.instanceFunc4 RawComment=[/// instanceFunc4 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:138:3: Constructor/decl_struct_1.init RawComment=[/// init(). Aaa.\n] BriefComment=[init(). Aaa.]
// CHECK-NEXT: comment_attach.swift:141:3: Subscript/decl_struct_1.subscript RawComment=[/// subscript Aaa.\n]
// CHECK-NEXT: comment_attach.swift:141:13: Param/i RawComment=none
// CHECK-NEXT: comment_attach.swift:141:31: Accessor/decl_struct_1.<getter for decl_struct_1.subscript> RawComment=none
// CHECK-NEXT: comment_attach.swift:144:10: Struct/decl_struct_1.NestedStruct RawComment=[/// NestedStruct Aaa.\n]
// CHECK-NEXT: comment_attach.swift:147:9: Class/decl_struct_1.NestedClass RawComment=[/// NestedClass Aaa.\n]
// CHECK-NEXT: comment_attach.swift:150:8: Enum/decl_struct_1.NestedEnum RawComment=[/// NestedEnum Aaa.\n]
// CHECK-NEXT: comment_attach.swift:156:13: TypeAlias/decl_struct_1.NestedTypealias RawComment=[/// NestedTypealias Aaa.\n]
// CHECK-NEXT: comment_attach.swift:159:14: Var/decl_struct_1.staticVar RawComment=[/// staticVar Aaa.\n]
// CHECK-NEXT: comment_attach.swift:162:15: Func/decl_struct_1.staticFunc1 RawComment=[/// staticFunc1 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:166:6: Enum/decl_enum_1 RawComment=[/// decl_enum_1 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:168:8: EnumElement/decl_enum_1.Case1 RawComment=[/// Case1 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:171:8: EnumElement/decl_enum_1.Case2 RawComment=[/// Case2 Aaa.\n]
// CHECK-NEXT: Param/<anonymous> RawComment=none BriefComment=none DocCommentAsXML=none
// CHECK-NEXT: comment_attach.swift:174:8: EnumElement/decl_enum_1.Case3 RawComment=[/// Case3 Aaa.\n]
// CHECK-NEXT: Param/<anonymous> RawComment=none BriefComment=none DocCommentAsXML=none
// CHECK-NEXT: Param/<anonymous> RawComment=none BriefComment=none DocCommentAsXML=none
// CHECK-NEXT: comment_attach.swift:177:8: EnumElement/decl_enum_1.Case4 RawComment=[/// Case4 Case5 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:177:15: EnumElement/decl_enum_1.Case5 RawComment=[/// Case4 Case5 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:181:7: Class/decl_class_1 RawComment=[/// decl_class_1 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:185:10: Protocol/decl_protocol_1 RawComment=[/// decl_protocol_1 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:187:18: AssociatedType/decl_protocol_1.NestedTypealias RawComment=[/// NestedTypealias Aaa.\n]
// CHECK-NEXT: comment_attach.swift:190:8: Func/decl_protocol_1.instanceFunc1 RawComment=[/// instanceFunc1 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:193:7: Var/decl_protocol_1.propertyWithGet RawComment=[/// propertyWithGet Aaa.\n]
// CHECK-NEXT: comment_attach.swift:193:30: Accessor/decl_protocol_1.<getter for decl_protocol_1.propertyWithGet> RawComment=none
// CHECK-NEXT: comment_attach.swift:196:7: Var/decl_protocol_1.propertyWithGetSet RawComment=[/// propertyWithGetSet Aaa.\n]
// CHECK-NEXT: comment_attach.swift:196:33: Accessor/decl_protocol_1.<getter for decl_protocol_1.propertyWithGetSet> RawComment=none
// CHECK-NEXT: comment_attach.swift:196:37: Accessor/decl_protocol_1.<setter for decl_protocol_1.propertyWithGetSet> RawComment=none
// CHECK-NEXT: comment_attach.swift:203:1: Extension/ RawComment=[/// decl_extension_1 Aaa.\n]
// CHECK-NEXT: comment_attach.swift:207:6: Func/emptyBlockDocComment RawComment=[/***/]
// CHECK-NEXT: comment_attach.swift:210:6: Func/weirdBlockDocComment RawComment=[/**/]
// CHECK-NEXT: comment_attach.swift:217:6: Func/docCommentWithGybLineNumber RawComment=[/// docCommentWithGybLineNumber Aaa.\n/// Bbb.\n/// Ccc.\n]
// CHECK-NEXT: custom.swuft:2001:6: Func/customSourceLocation RawComment=[/// Oooh, custom!\n]