Skip to content

Commit 32f3b9d

Browse files
authored
Merge pull request #1177 from ahoppen/6.0/merge-main-2024-04-16
Merge `main` into `release/6.0`
2 parents 3f866b7 + 70824ba commit 32f3b9d

32 files changed

+881
-750
lines changed

Sources/Diagnose/SourcekitdRequestCommand.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,9 @@ public struct SourceKitdRequestCommand: AsyncParsableCommand {
5656
let requestInfo = try RequestInfo(request: requestString)
5757

5858
let lineTable = LineTable(requestInfo.fileContents)
59-
if let offset = lineTable.utf8OffsetOf(line: line - 1, utf8Column: column - 1) {
60-
print("Adjusting request offset to \(offset)")
61-
requestString.replace(#/key.offset: [0-9]+/#, with: "key.offset: \(offset)")
62-
}
59+
let offset = lineTable.utf8OffsetOf(line: line - 1, utf8Column: column - 1)
60+
print("Adjusting request offset to \(offset)")
61+
requestString.replace(#/key.offset: [0-9]+/#, with: "key.offset: \(offset)")
6362
}
6463

6564
let request = try requestString.cString(using: .utf8)!.withUnsafeBufferPointer { buffer in

Sources/LSPLogging/OrLog.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import os
1515
#endif
1616

17-
public func logError(prefix: String, error: Error, level: LogLevel = .error) {
17+
private func logError(prefix: String, error: Error, level: LogLevel = .error) {
1818
logger.log(
1919
level: level,
2020
"\(prefix, privacy: .public)\(prefix.isEmpty ? "" : ": ", privacy: .public)\(error.forLogging)"
@@ -41,7 +41,7 @@ public func orLog<R>(
4141
public func orLog<R>(
4242
_ prefix: String,
4343
level: LogLevel = .error,
44-
_ block: () async throws -> R?
44+
@_inheritActorContext _ block: @Sendable () async throws -> R?
4545
) async -> R? {
4646
do {
4747
return try await block()

Sources/LanguageServerProtocol/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ add_library(LanguageServerProtocol STATIC
124124
SupportTypes/SKCompletionOptions.swift
125125
SupportTypes/StringOrMarkupContent.swift
126126
SupportTypes/SymbolKind.swift
127+
SupportTypes/TestItem.swift
127128
SupportTypes/TextDocumentContentChangeEvent.swift
128129
SupportTypes/TextDocumentEdit.swift
129130
SupportTypes/TextDocumentIdentifier.swift

Sources/LanguageServerProtocol/Requests/DocumentTestsRequest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/// **(LSP Extension)**
1616
public struct DocumentTestsRequest: TextDocumentRequest, Hashable {
1717
public static let method: String = "textDocument/tests"
18-
public typealias Response = [WorkspaceSymbolItem]?
18+
public typealias Response = [TestItem]
1919

2020
public var textDocument: TextDocumentIdentifier
2121

Sources/LanguageServerProtocol/Requests/WorkspaceTestsRequest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/// **(LSP Extension)**
1616
public struct WorkspaceTestsRequest: RequestType, Hashable {
1717
public static let method: String = "workspace/tests"
18-
public typealias Response = [WorkspaceSymbolItem]?
18+
public typealias Response = [TestItem]
1919

2020
public init() {}
2121
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2023 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
public struct TestTag: Codable, Equatable, Sendable {
14+
/// ID of the test tag. `TestTag` instances with the same ID are considered to be identical.
15+
public let id: String
16+
17+
public init(id: String) {
18+
self.id = id
19+
}
20+
}
21+
22+
/// A test item that can be shown an a client's test explorer or used to identify tests alongside a source file.
23+
///
24+
/// A `TestItem` can represent either a test suite or a test itself, since they both have similar capabilities.
25+
public struct TestItem: ResponseType, Equatable {
26+
/// Identifier for the `TestItem`.
27+
///
28+
/// This identifier uniquely identifies the test case or test suite. It can be used to run an individual test (suite).
29+
public let id: String
30+
31+
/// Display name describing the test.
32+
public let label: String
33+
34+
/// Optional description that appears next to the label.
35+
public let description: String?
36+
37+
/// A string that should be used when comparing this item with other items.
38+
///
39+
/// When `nil` the `label` is used.
40+
public let sortText: String?
41+
42+
/// The location of the test item in the source code.
43+
public let location: Location
44+
45+
/// The children of this test item.
46+
///
47+
/// For a test suite, this may contain the individual test cases or nested suites.
48+
public let children: [TestItem]
49+
50+
/// Tags associated with this test item.
51+
public let tags: [TestTag]
52+
53+
public init(
54+
id: String,
55+
label: String,
56+
description: String? = nil,
57+
sortText: String? = nil,
58+
location: Location,
59+
children: [TestItem],
60+
tags: [TestTag]
61+
) {
62+
self.id = id
63+
self.label = label
64+
self.description = description
65+
self.sortText = sortText
66+
self.location = location
67+
self.children = children
68+
self.tags = tags
69+
}
70+
}

0 commit comments

Comments
 (0)