@@ -95,7 +95,18 @@ struct TestingAttributeData {
9595 return false
9696 }
9797 } . flatMap ( \. arguments)
98- . compactMap { $0. expression. as ( StringLiteralExprSyntax . self) ? . representedLiteralValue }
98+ . compactMap {
99+ if let memberAccess = $0. expression. as ( MemberAccessExprSyntax . self) {
100+ var components = memberAccess. components [ ... ]
101+ if components. starts ( with: [ " Testing " , " Tag " ] ) {
102+ components = components. dropFirst ( 2 )
103+ } else if components. starts ( with: [ " Tag " ] ) {
104+ components = components. dropFirst ( 1 )
105+ }
106+ return components. joined ( separator: " . " )
107+ }
108+ return nil
109+ }
99110
100111 self . isDisabled = traitArguments. lazy
101112 . compactMap { $0. as ( FunctionCallExprSyntax . self) }
@@ -328,36 +339,32 @@ fileprivate extension AttributeSyntax {
328339}
329340
330341fileprivate extension MemberAccessExprSyntax {
331- /// The base name of this instance, i.e. the string value of `base` joined
332- /// with any preceding base names.
342+ /// The fully-qualified name of this instance (subject to available
343+ /// information.)
333344 ///
334- /// For example, if this instance represents the expression `x.y.z(123)`,
335- /// the value of this property is `"x.y"`. If the value of `base` is `nil`,
336- /// the value of this property is also `nil`.
337- var baseName : String ? {
338- if let declReferenceExpr = base? . as ( DeclReferenceExprSyntax . self) {
339- return declReferenceExpr. baseName. text
340- } else if let baseMemberAccessExpr = base? . as ( MemberAccessExprSyntax . self) {
341- if let baseBaseName = baseMemberAccessExpr. baseName {
342- return " \( baseBaseName) . \( baseMemberAccessExpr. declName. baseName. text) "
343- }
344- return baseMemberAccessExpr. declName. baseName. text
345- }
346-
347- return nil
345+ /// The value of this property are all the components of the based name
346+ /// name joined together with `.`.
347+ var fullyQualifiedName : String {
348+ components. joined ( separator: " . " )
348349 }
349350
350- /// The fully-qualified name of this instance (subject to available
351+ /// The name components of this instance (subject to available
351352 /// information.)
352353 ///
353- /// The value of this property is this instance's `baseName` property joined
354- /// with its `name` property. For example, if this instance represents the
355- /// expression `x.y.z(123)`, the value of this property is `"x.y.z"`.
356- var fullyQualifiedName : String {
357- if let baseName {
358- return " \( baseName) . \( declName. baseName. text) "
354+ /// The value of this property is this base name of this instance,
355+ /// i.e. the string value of `base` preceeded with any preceding base names
356+ /// and followed by its `name` property.
357+ ///
358+ /// For example, if this instance represents
359+ /// the expression `x.y.z(123)`, the value of this property is
360+ /// `["x", "y", "z"]`.
361+ var components : [ String ] {
362+ if let declReferenceExpr = base? . as ( DeclReferenceExprSyntax . self) {
363+ return [ declReferenceExpr. baseName. text, declName. baseName. text]
364+ } else if let baseMemberAccessExpr = base? . as ( MemberAccessExprSyntax . self) {
365+ return baseMemberAccessExpr. components + [ declName. baseName. text]
359366 }
360- return declName. baseName. text
367+ return [ declName. baseName. text]
361368 }
362369}
363370
0 commit comments