@@ -177,9 +177,13 @@ final class SyntacticSwiftTestingTestScanner: SyntaxVisitor {
177
177
private let parentTypeNames : [ String ]
178
178
179
179
/// The discovered test items.
180
- private var result : [ TestItem ] = [ ]
180
+ private var result : [ AnnotatedTestItem ] = [ ]
181
181
182
- private init ( snapshot: DocumentSnapshot , allTestsDisabled: Bool , parentTypeNames: [ String ] ) {
182
+ private init (
183
+ snapshot: DocumentSnapshot ,
184
+ allTestsDisabled: Bool ,
185
+ parentTypeNames: [ String ]
186
+ ) {
183
187
self . snapshot = snapshot
184
188
self . allTestsDisabled = allTestsDisabled
185
189
self . parentTypeNames = parentTypeNames
@@ -190,7 +194,7 @@ final class SyntacticSwiftTestingTestScanner: SyntaxVisitor {
190
194
public static func findTestSymbols(
191
195
in snapshot: DocumentSnapshot ,
192
196
syntaxTreeManager: SyntaxTreeManager
193
- ) async -> [ TestItem ] {
197
+ ) async -> [ AnnotatedTestItem ] {
194
198
guard snapshot. text. contains ( " Suite " ) || snapshot. text. contains ( " Test " ) else {
195
199
// If the file contains swift-testing tests, it must contain a `@Suite` or `@Test` attribute.
196
200
// Only check for the attribute name because the attribute may be module qualified and contain an arbitrary amount
@@ -199,7 +203,11 @@ final class SyntacticSwiftTestingTestScanner: SyntaxVisitor {
199
203
return [ ]
200
204
}
201
205
let syntaxTree = await syntaxTreeManager. syntaxTree ( for: snapshot)
202
- let visitor = SyntacticSwiftTestingTestScanner ( snapshot: snapshot, allTestsDisabled: false , parentTypeNames: [ ] )
206
+ let visitor = SyntacticSwiftTestingTestScanner (
207
+ snapshot: snapshot,
208
+ allTestsDisabled: false ,
209
+ parentTypeNames: [ ]
210
+ )
203
211
visitor. walk ( syntaxTree)
204
212
return visitor. result
205
213
}
@@ -241,14 +249,18 @@ final class SyntacticSwiftTestingTestScanner: SyntaxVisitor {
241
249
}
242
250
243
251
let range = snapshot. range ( of: node. positionAfterSkippingLeadingTrivia..< node. endPositionBeforeTrailingTrivia)
244
- let testItem = TestItem (
245
- id: ( parentTypeNames + typeNames) . joined ( separator: " / " ) ,
246
- label: attributeData? . displayName ?? typeNames. last!,
247
- disabled: ( attributeData? . isDisabled ?? false ) || allTestsDisabled,
248
- style: TestStyle . swiftTesting,
249
- location: Location ( uri: snapshot. uri, range: range) ,
250
- children: memberScanner. result,
251
- tags: attributeData? . tags. map ( TestTag . init ( id: ) ) ?? [ ]
252
+ // Members won't be extensions since extensions will only be at the top level.
253
+ let testItem = AnnotatedTestItem (
254
+ testItem: TestItem (
255
+ id: ( parentTypeNames + typeNames) . joined ( separator: " / " ) ,
256
+ label: attributeData? . displayName ?? typeNames. last!,
257
+ disabled: ( attributeData? . isDisabled ?? false ) || allTestsDisabled,
258
+ style: TestStyle . swiftTesting,
259
+ location: Location ( uri: snapshot. uri, range: range) ,
260
+ children: memberScanner. result. map ( \. testItem) ,
261
+ tags: attributeData? . tags. map ( TestTag . init ( id: ) ) ?? [ ]
262
+ ) ,
263
+ isExtension: node. is ( ExtensionDeclSyntax . self)
252
264
)
253
265
result. append ( testItem)
254
266
return . skipChildren
@@ -295,14 +307,17 @@ final class SyntacticSwiftTestingTestScanner: SyntaxVisitor {
295
307
node. name. text + " ( " + node. signature. parameterClause. parameters. map { " \( $0. firstName. text) : " } . joined ( ) + " ) "
296
308
297
309
let range = snapshot. range ( of: node. positionAfterSkippingLeadingTrivia..< node. endPositionBeforeTrailingTrivia)
298
- let testItem = TestItem (
299
- id: ( parentTypeNames + [ name] ) . joined ( separator: " / " ) ,
300
- label: attributeData. displayName ?? name,
301
- disabled: attributeData. isDisabled || allTestsDisabled,
302
- style: TestStyle . swiftTesting,
303
- location: Location ( uri: snapshot. uri, range: range) ,
304
- children: [ ] ,
305
- tags: attributeData. tags. map ( TestTag . init ( id: ) )
310
+ let testItem = AnnotatedTestItem (
311
+ testItem: TestItem (
312
+ id: ( parentTypeNames + [ name] ) . joined ( separator: " / " ) ,
313
+ label: attributeData. displayName ?? name,
314
+ disabled: attributeData. isDisabled || allTestsDisabled,
315
+ style: TestStyle . swiftTesting,
316
+ location: Location ( uri: snapshot. uri, range: range) ,
317
+ children: [ ] ,
318
+ tags: attributeData. tags. map ( TestTag . init ( id: ) )
319
+ ) ,
320
+ isExtension: false
306
321
)
307
322
result. append ( testItem)
308
323
return . visitChildren
0 commit comments