Skip to content

Commit def5285

Browse files
committed
Account for nested structs on Tag declarations
When a tag is declared within a nested type on Tag include the types name in the tags string representation.
1 parent 76c0860 commit def5285

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Sources/SourceKitLSP/Swift/SwiftTestingScanner.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,13 @@ struct TestingAttributeData {
9696
}
9797
}.flatMap(\.arguments)
9898
.compactMap {
99-
$0.expression.as(StringLiteralExprSyntax.self)?.representedLiteralValue ??
100-
$0.expression.as(MemberAccessExprSyntax.self)?.declName.baseName.text
99+
if let stringLiteral = $0.expression.as(StringLiteralExprSyntax.self) {
100+
return stringLiteral.representedLiteralValue
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)"
104+
}
105+
return nil
101106
}
102107

103108
self.isDisabled = traitArguments.lazy

0 commit comments

Comments
 (0)