Skip to content

Merge main into release/6.0 #1177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Sources/Diagnose/SourcekitdRequestCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ public struct SourceKitdRequestCommand: AsyncParsableCommand {
let requestInfo = try RequestInfo(request: requestString)

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

let request = try requestString.cString(using: .utf8)!.withUnsafeBufferPointer { buffer in
Expand Down
4 changes: 2 additions & 2 deletions Sources/LSPLogging/OrLog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import os
#endif

public func logError(prefix: String, error: Error, level: LogLevel = .error) {
private func logError(prefix: String, error: Error, level: LogLevel = .error) {
logger.log(
level: level,
"\(prefix, privacy: .public)\(prefix.isEmpty ? "" : ": ", privacy: .public)\(error.forLogging)"
Expand All @@ -41,7 +41,7 @@ public func orLog<R>(
public func orLog<R>(
_ prefix: String,
level: LogLevel = .error,
_ block: () async throws -> R?
@_inheritActorContext _ block: @Sendable () async throws -> R?
) async -> R? {
do {
return try await block()
Expand Down
1 change: 1 addition & 0 deletions Sources/LanguageServerProtocol/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ add_library(LanguageServerProtocol STATIC
SupportTypes/SKCompletionOptions.swift
SupportTypes/StringOrMarkupContent.swift
SupportTypes/SymbolKind.swift
SupportTypes/TestItem.swift
SupportTypes/TextDocumentContentChangeEvent.swift
SupportTypes/TextDocumentEdit.swift
SupportTypes/TextDocumentIdentifier.swift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/// **(LSP Extension)**
public struct DocumentTestsRequest: TextDocumentRequest, Hashable {
public static let method: String = "textDocument/tests"
public typealias Response = [WorkspaceSymbolItem]?
public typealias Response = [TestItem]

public var textDocument: TextDocumentIdentifier

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/// **(LSP Extension)**
public struct WorkspaceTestsRequest: RequestType, Hashable {
public static let method: String = "workspace/tests"
public typealias Response = [WorkspaceSymbolItem]?
public typealias Response = [TestItem]

public init() {}
}
70 changes: 70 additions & 0 deletions Sources/LanguageServerProtocol/SupportTypes/TestItem.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2023 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
//
//===----------------------------------------------------------------------===//

public struct TestTag: Codable, Equatable, Sendable {
/// ID of the test tag. `TestTag` instances with the same ID are considered to be identical.
public let id: String

public init(id: String) {
self.id = id
}
}

/// A test item that can be shown an a client's test explorer or used to identify tests alongside a source file.
///
/// A `TestItem` can represent either a test suite or a test itself, since they both have similar capabilities.
public struct TestItem: ResponseType, Equatable {
/// Identifier for the `TestItem`.
///
/// This identifier uniquely identifies the test case or test suite. It can be used to run an individual test (suite).
public let id: String

/// Display name describing the test.
public let label: String

/// Optional description that appears next to the label.
public let description: String?

/// A string that should be used when comparing this item with other items.
///
/// When `nil` the `label` is used.
public let sortText: String?

/// The location of the test item in the source code.
public let location: Location

/// The children of this test item.
///
/// For a test suite, this may contain the individual test cases or nested suites.
public let children: [TestItem]

/// Tags associated with this test item.
public let tags: [TestTag]

public init(
id: String,
label: String,
description: String? = nil,
sortText: String? = nil,
location: Location,
children: [TestItem],
tags: [TestTag]
) {
self.id = id
self.label = label
self.description = description
self.sortText = sortText
self.location = location
self.children = children
self.tags = tags
}
}
Loading