Skip to content

Commit 76c0860

Browse files
committed
Support member access in tags
Currently tags are only recognized when the tag is specified by string literal, i.e: @tag("foo"). Support Tags added via the staticMember Tag.Kind.
1 parent ec5c614 commit 76c0860

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Sources/SourceKitLSP/Swift/SwiftTestingScanner.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ struct TestingAttributeData {
9595
return false
9696
}
9797
}.flatMap(\.arguments)
98-
.compactMap { $0.expression.as(StringLiteralExprSyntax.self)?.representedLiteralValue }
98+
.compactMap {
99+
$0.expression.as(StringLiteralExprSyntax.self)?.representedLiteralValue ??
100+
$0.expression.as(MemberAccessExprSyntax.self)?.declName.baseName.text
101+
}
99102

100103
self.isDisabled = traitArguments.lazy
101104
.compactMap { $0.as(FunctionCallExprSyntax.self) }

Tests/SourceKitLSPTests/DocumentTestDiscoveryTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ final class DocumentTestDiscoveryTests: XCTestCase {
595595
596596
1️⃣@Suite(.tags("Suites"))
597597
struct MyTests {
598-
2️⃣@Test(.tags("one", "two"))
598+
2️⃣@Test(.tags("one", "two", .red, .blue))
599599
func oneIsTwo() {
600600
#expect(1 == 2)
601601
}3️⃣
@@ -622,7 +622,7 @@ final class DocumentTestDiscoveryTests: XCTestCase {
622622
style: TestStyle.swiftTesting,
623623
location: Location(uri: uri, range: positions["2️⃣"]..<positions["3️⃣"]),
624624
children: [],
625-
tags: [TestTag(id: "one"), TestTag(id: "two")]
625+
tags: [TestTag(id: "one"), TestTag(id: "two"), TestTag(id: "red"), TestTag(id: "blue")]
626626
)
627627
],
628628
tags: [TestTag(id: "Suites")]

0 commit comments

Comments
 (0)