diff --git a/Sources/LanguageServerProtocol/SupportTypes/TestItem.swift b/Sources/LanguageServerProtocol/SupportTypes/TestItem.swift index b91ccba97..640ae7807 100644 --- a/Sources/LanguageServerProtocol/SupportTypes/TestItem.swift +++ b/Sources/LanguageServerProtocol/SupportTypes/TestItem.swift @@ -39,6 +39,12 @@ public struct TestItem: ResponseType, Equatable { /// When `nil` the `label` is used. public let sortText: String? + /// Whether the test is disabled. + public let disabled: Bool + + /// The type of test, eg. the testing framework that was used to declare the test. + public let style: String + /// The location of the test item in the source code. public let location: Location @@ -55,6 +61,8 @@ public struct TestItem: ResponseType, Equatable { label: String, description: String? = nil, sortText: String? = nil, + disabled: Bool, + style: String, location: Location, children: [TestItem], tags: [TestTag] @@ -63,6 +71,8 @@ public struct TestItem: ResponseType, Equatable { self.label = label self.description = description self.sortText = sortText + self.disabled = disabled + self.style = style self.location = location self.children = children self.tags = tags diff --git a/Sources/SourceKitLSP/CMakeLists.txt b/Sources/SourceKitLSP/CMakeLists.txt index 270baa908..b405b9eee 100644 --- a/Sources/SourceKitLSP/CMakeLists.txt +++ b/Sources/SourceKitLSP/CMakeLists.txt @@ -38,6 +38,7 @@ target_sources(SourceKitLSP PRIVATE Swift/SourceKitD+ResponseError.swift Swift/SwiftCommand.swift Swift/SwiftLanguageService.swift + Swift/SwiftTestingScanner.swift Swift/SymbolInfo.swift Swift/SyntaxHighlightingToken.swift Swift/SyntaxHighlightingTokens.swift diff --git a/Sources/SourceKitLSP/Swift/SwiftTestingScanner.swift b/Sources/SourceKitLSP/Swift/SwiftTestingScanner.swift new file mode 100644 index 000000000..3e65a74d1 --- /dev/null +++ b/Sources/SourceKitLSP/Swift/SwiftTestingScanner.swift @@ -0,0 +1,378 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2024 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// + +import LSPLogging +import LanguageServerProtocol +import SwiftSyntax + +// MARK: - Attribute parsing + +/// Get the traits applied to a testing attribute. +/// +/// - Parameters: +/// - testAttribute: The attribute to inspect. +/// +/// - Returns: An array of `ExprSyntax` instances representing the traits +/// applied to `testAttribute`. If the attribute has no traits, the empty +/// array is returned. +private func traits(ofTestAttribute testAttribute: AttributeSyntax) -> [ExprSyntax] { + guard let argument = testAttribute.arguments, case let .argumentList(argumentList) = argument else { + return [] + } + + // Skip the display name if present. + var traitArgumentsRange = argumentList.startIndex..