@@ -97,10 +97,15 @@ struct TestingAttributeData {
97
97
} . flatMap ( \. arguments)
98
98
. compactMap {
99
99
if let stringLiteral = $0. expression. as ( StringLiteralExprSyntax . self) {
100
- return stringLiteral. representedLiteralValue
100
+ return stringLiteral. representedLiteralValue
101
101
} else if let memberAccess = $0. expression. as ( MemberAccessExprSyntax . self) {
102
- let baseName = ( memberAccess. baseName. map { " \( $0) . " } ?? " " ) . replacing ( #/Tag\./# , with: " " )
103
- return " \( baseName) \( memberAccess. declName. baseName. text) "
102
+ var components = memberAccess. components [ ... ]
103
+ if components. starts ( with: [ " Testing " , " Tag " ] ) {
104
+ components = components. dropFirst ( 2 )
105
+ } else if components. starts ( with: [ " Tag " ] ) {
106
+ components = components. dropFirst ( 1 )
107
+ }
108
+ return components. joined ( separator: " . " )
104
109
}
105
110
return nil
106
111
}
@@ -336,36 +341,34 @@ fileprivate extension AttributeSyntax {
336
341
}
337
342
338
343
fileprivate extension MemberAccessExprSyntax {
339
- /// The base name of this instance, i.e. the string value of `base` joined
340
- /// with any preceding base names.
344
+ /// The fully-qualified name of this instance (subject to available
345
+ /// information.)
341
346
///
342
- /// For example, if this instance represents the expression `x.y.z(123)`,
343
- /// the value of this property is `"x.y"`. If the value of `base` is `nil`,
344
- /// the value of this property is also `nil`.
345
- var baseName : String ? {
346
- if let declReferenceExpr = base? . as ( DeclReferenceExprSyntax . self) {
347
- return declReferenceExpr. baseName. text
348
- } else if let baseMemberAccessExpr = base? . as ( MemberAccessExprSyntax . self) {
349
- if let baseBaseName = baseMemberAccessExpr. baseName {
350
- return " \( baseBaseName) . \( baseMemberAccessExpr. declName. baseName. text) "
351
- }
352
- return baseMemberAccessExpr. declName. baseName. text
353
- }
354
-
355
- return nil
347
+ /// The value of this property are all the components of the based name
348
+ /// name joined together with `.`.
349
+ var fullyQualifiedName : String {
350
+ components. joined ( separator: " . " )
356
351
}
357
352
358
- /// The fully-qualified name of this instance (subject to available
353
+ /// The name components of this instance (subject to available
359
354
/// information.)
360
355
///
361
- /// The value of this property is this instance's `baseName` property joined
362
- /// with its `name` property. For example, if this instance represents the
363
- /// expression `x.y.z(123)`, the value of this property is `"x.y.z"`.
364
- var fullyQualifiedName : String {
365
- if let baseName {
366
- return " \( baseName) . \( declName. baseName. text) "
356
+ /// The value of this property is this base name of this instance,
357
+ /// i.e. the string value of `base` preceeded with any preceding base names
358
+ /// and followed by its `name` property.
359
+ ///
360
+ /// For example, if this instance represents
361
+ /// the expression `x.y.z(123)`, the value of this property is
362
+ /// `["x", "y", "z"]`.
363
+ var components : [ String ] {
364
+ if let declReferenceExpr = base? . as ( DeclReferenceExprSyntax . self) {
365
+ return [ declReferenceExpr. baseName. text, declName. baseName. text]
366
+ } else if let baseMemberAccessExpr = base? . as ( MemberAccessExprSyntax . self) {
367
+ let baseBaseNames = baseMemberAccessExpr. components. dropLast ( )
368
+ return baseBaseNames + [ baseMemberAccessExpr. declName. baseName. text, declName. baseName. text]
367
369
}
368
- return declName. baseName. text
370
+
371
+ return [ declName. baseName. text]
369
372
}
370
373
}
371
374
0 commit comments