Skip to content

Commit c49d6a9

Browse files
committed
Revert TestStyle enum changes
1 parent 14b81cf commit c49d6a9

File tree

6 files changed

+67
-73
lines changed

6 files changed

+67
-73
lines changed

Sources/LanguageServerProtocol/SupportTypes/TestItem.swift

+2-11
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,6 @@ public struct TestTag: Codable, Equatable, Sendable {
1919
}
2020
}
2121

22-
/// An enum representing the different styles of tests that can be found in a document.
23-
public enum TestStyle: String, Codable, Sendable {
24-
/// XCTest: https://developer.apple.com/documentation/xctest
25-
case xcTest = "XCTest"
26-
27-
/// Swift Testing: https://swiftpackageindex.com/apple/swift-testing/main/documentation/testing
28-
case swiftTesting = "swift-testing"
29-
}
30-
3122
/// A test item that can be shown an a client's test explorer or used to identify tests alongside a source file.
3223
///
3324
/// A `TestItem` can represent either a test suite or a test itself, since they both have similar capabilities.
@@ -52,7 +43,7 @@ public struct TestItem: ResponseType, Equatable {
5243
public var disabled: Bool
5344

5445
/// The type of test, eg. the testing framework that was used to declare the test.
55-
public var style: TestStyle
46+
public var style: String
5647

5748
/// The location of the test item in the source code.
5849
public var location: Location
@@ -71,7 +62,7 @@ public struct TestItem: ResponseType, Equatable {
7162
description: String? = nil,
7263
sortText: String? = nil,
7364
disabled: Bool,
74-
style: TestStyle,
65+
style: String,
7566
location: Location,
7667
children: [TestItem],
7768
tags: [TestTag]

Sources/SourceKitLSP/Swift/SwiftTestingScanner.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ final class SyntacticSwiftTestingTestScanner: SyntaxVisitor {
257257
id: (parentTypeNames + typeNames).joined(separator: "/"),
258258
label: attributeData?.displayName ?? typeNames.last!,
259259
disabled: (attributeData?.isDisabled ?? false) || allTestsDisabled,
260-
style: .swiftTesting,
260+
style: TestStyle.swiftTesting,
261261
location: Location(uri: snapshot.uri, range: range),
262262
children: memberScanner.result.map(\.testItem),
263263
tags: attributeData?.tags.map(TestTag.init(id:)) ?? []
@@ -330,7 +330,7 @@ final class SyntacticSwiftTestingTestScanner: SyntaxVisitor {
330330
id: (parentTypeNames + [name]).joined(separator: "/"),
331331
label: attributeData.displayName ?? name,
332332
disabled: attributeData.isDisabled || allTestsDisabled,
333-
style: .swiftTesting,
333+
style: TestStyle.swiftTesting,
334334
location: Location(uri: snapshot.uri, range: range),
335335
children: [],
336336
tags: attributeData.tags.map(TestTag.init(id:))

Sources/SourceKitLSP/Swift/SyntacticSwiftXCTestScanner.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ final class SyntacticSwiftXCTestScanner: SyntaxVisitor {
7272
id: "\(containerName)/\(function.name.text)()",
7373
label: "\(function.name.text)()",
7474
disabled: false,
75-
style: .xcTest,
75+
style: TestStyle.xcTest,
7676
location: Location(uri: snapshot.uri, range: range),
7777
children: [],
7878
tags: []
@@ -106,7 +106,7 @@ final class SyntacticSwiftXCTestScanner: SyntaxVisitor {
106106
id: node.name.text,
107107
label: node.name.text,
108108
disabled: false,
109-
style: .xcTest,
109+
style: TestStyle.xcTest,
110110
location: Location(uri: snapshot.uri, range: range),
111111
children: testMethods,
112112
tags: []

Sources/SourceKitLSP/TestDiscovery.swift

+8-3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ import LanguageServerProtocol
1616
import SemanticIndex
1717
import SwiftSyntax
1818

19+
public enum TestStyle {
20+
public static let xcTest = "XCTest"
21+
public static let swiftTesting = "swift-testing"
22+
}
23+
1924
fileprivate extension SymbolOccurrence {
2025
/// Assuming that this is a symbol occurrence returned by the index, return whether it can constitute the definition
2126
/// of a test case.
@@ -150,7 +155,7 @@ extension SourceKitLSPServer {
150155
id: id,
151156
label: testSymbolOccurrence.symbol.name,
152157
disabled: false,
153-
style: .xcTest,
158+
style: TestStyle.xcTest,
154159
location: location,
155160
children: children.map(\.testItem),
156161
tags: []
@@ -216,7 +221,7 @@ extension SourceKitLSPServer {
216221
testsFromSyntacticIndex
217222
.compactMap { (item) -> AnnotatedTestItem? in
218223
let testItem = item.testItem
219-
if testItem.style == .swiftTesting {
224+
if testItem.style == TestStyle.swiftTesting {
220225
// Swift-testing tests aren't part of the semantic index. Always include them.
221226
return item
222227
}
@@ -292,7 +297,7 @@ extension SourceKitLSPServer {
292297

293298
if let index = workspace.index(checkedFor: indexCheckLevel) {
294299
var syntacticSwiftTestingTests: [AnnotatedTestItem] {
295-
syntacticTests?.filter { $0.testItem.style == .swiftTesting } ?? []
300+
syntacticTests?.filter { $0.testItem.style == TestStyle.swiftTesting } ?? []
296301
}
297302

298303
let testSymbols =

0 commit comments

Comments
 (0)