Skip to content
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
1 change: 1 addition & 0 deletions Sources/BuildServerProtocol/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ add_library(BuildServerProtocol
Messages/BuildShutdownRequest.swift
Messages/BuildTargetPrepareRequest.swift
Messages/BuildTargetSourcesRequest.swift
Messages/CancelRequestNotification.swift
Messages/InitializeBuildRequest.swift
Messages/OnBuildExitNotification.swift
Messages/OnBuildInitializedNotification.swift
Expand Down
3 changes: 3 additions & 0 deletions Sources/BuildServerProtocol/Messages.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

public import LanguageServerProtocol

public protocol BSPRequest: RequestType {}
public protocol BSPNotification: NotificationType {}

private let requestTypes: [_RequestType.Type] = [
BuildShutdownRequest.self,
BuildTargetPrepareRequest.self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public import LanguageServerProtocol
/// but to not exit (otherwise the response might not be delivered
/// correctly to the client). There is a separate exit notification
/// that asks the server to exit.
public struct BuildShutdownRequest: RequestType {
public struct BuildShutdownRequest: BSPRequest {
public static let method: String = "build/shutdown"
public typealias Response = VoidResponse

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public typealias OriginId = String
///
/// The server communicates during the initialize handshake whether this method is supported or not by setting
/// `prepareProvider: true` in `SourceKitInitializeBuildResponseData`.
public struct BuildTargetPrepareRequest: RequestType, Hashable {
public struct BuildTargetPrepareRequest: BSPRequest, Hashable {
public static let method: String = "buildTarget/prepare"
public typealias Response = VoidResponse

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public import LanguageServerProtocol
/// query for the list of text documents and directories that belong to a
/// build target. The sources response must not include sources that are
/// external to the workspace.
public struct BuildTargetSourcesRequest: RequestType, Hashable {
public struct BuildTargetSourcesRequest: BSPRequest, Hashable {
public static let method: String = "buildTarget/sources"
public typealias Response = BuildTargetSourcesResponse

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//===----------------------------------------------------------------------===//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this file is missing from the CMake build

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thank you! updated.

//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2019 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 import LanguageServerProtocol

extension CancelRequestNotification: BSPNotification {}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public import LanguageServerProtocol
/// Until the server has responded to the initialize request with an
/// InitializeBuildResult, the client must not send any additional
/// requests or notifications to the server.
public struct InitializeBuildRequest: RequestType, Hashable {
public struct InitializeBuildRequest: BSPRequest, Hashable {
public static let method: String = "build/initialize"
public typealias Response = InitializeBuildResponse

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
//
//===----------------------------------------------------------------------===//

public import LanguageServerProtocol

/// Like the language server protocol, a notification to ask the
/// server to exit its process. The server should exit with success
/// code 0 if the shutdown request has been received before;
/// otherwise with error code 1.
public struct OnBuildExitNotification: NotificationType {
public struct OnBuildExitNotification: BSPNotification {
public static let method: String = "build/exit"

public init() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
//
//===----------------------------------------------------------------------===//

public import LanguageServerProtocol

/// Like the language server protocol, the initialized notification is sent from the client to the server after the client received the result of the initialize request but before the client is sending any other request or notification to the server. The server can use the initialized notification for example to initialize intensive computation such as dependency resolution or compilation. The initialized notification may only be sent once.
public struct OnBuildInitializedNotification: NotificationType {
public struct OnBuildInitializedNotification: BSPNotification {
public static let method: String = "build/initialized"

public init() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@
//
//===----------------------------------------------------------------------===//

public import LanguageServerProtocol

/// The log message notification is sent from a server to a client to ask the client to log a particular message in its console.
///
/// A `build/logMessage`` notification is similar to LSP's `window/logMessage``, except for a few additions like id and originId.
public struct OnBuildLogMessageNotification: NotificationType {
public struct OnBuildLogMessageNotification: BSPNotification {
public static let method: String = "build/logMessage"

/// The message type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public import LanguageServerProtocol
/// The build target changed notification is sent from the server to the client
/// to signal a change in a build target. The server communicates during the
/// initialize handshake whether this method is supported or not.
public struct OnBuildTargetDidChangeNotification: NotificationType, Equatable {
public struct OnBuildTargetDidChangeNotification: BSPNotification, Equatable {
public static let method: String = "buildTarget/didChange"

/// **(BSP Extension)**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ public import LanguageServerProtocol

/// Notification sent from SourceKit-LSP to the build server to indicate that files within the project have been modified.
public typealias OnWatchedFilesDidChangeNotification = LanguageServerProtocol.DidChangeWatchedFilesNotification

extension OnWatchedFilesDidChangeNotification: BSPNotification {}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public import LanguageServerProtocol
/// - Important: This request has been deprecated. Build servers should instead implement the
/// `textDocument/sourceKitOptions` request.
/// See https://forums.swift.org/t/extending-functionality-of-build-server-protocol-with-sourcekit-lsp/74400
public struct RegisterForChanges: RequestType {
public struct RegisterForChanges: BSPRequest {
public static let method: String = "textDocument/registerForChanges"
public typealias Response = VoidResponse

Expand Down Expand Up @@ -48,7 +48,7 @@ public enum RegisterAction: String, Hashable, Codable, Sendable {
/// - Important: This request has been deprecated. Build servers should instead implement the
/// `textDocument/sourceKitOptions` request.
/// See https://forums.swift.org/t/extending-functionality-of-build-server-protocol-with-sourcekit-lsp/74400
public struct FileOptionsChangedNotification: NotificationType {
public struct FileOptionsChangedNotification: BSPNotification {
public struct Options: ResponseType, Hashable {
/// The compiler options required for the requested file.
public var options: [String]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public import Foundation
public import LanguageServerProtocol

/// A `build/taskFinish` notification must always be sent after a `build/taskStart`` with the same `taskId` was sent.
public struct TaskFinishNotification: NotificationType {
public struct TaskFinishNotification: BSPNotification {
public static let method: String = "build/taskFinish"

/// Unique id of the task with optional reference to parent task id.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public import LanguageServerProtocol

/// After a `taskStart` and before `taskFinish` for a `taskId`, the server may send any number of progress
/// notifications.
public struct TaskProgressNotification: NotificationType {
public struct TaskProgressNotification: BSPNotification {
public static let method: String = "build/taskProgress"

/// Unique id of the task with optional reference to parent task id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public import LanguageServerProtocol
///
/// Tasks that are spawned by another task should reference the originating task's `taskId` in their own `taskId`'s
/// `parent` field. Tasks spawned directly by a request should reference the request's `originId` parent.
public struct TaskStartNotification: NotificationType {
public struct TaskStartNotification: BSPNotification {
public static let method: String = "build/taskStart"

/// Unique id of the task with optional reference to parent task id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public import LanguageServerProtocol
/// `DidChangeBuildTargetNotification` is sent for the requested target.
///
/// The request may return `nil` if it doesn't have any build settings for this file in the given target.
public struct TextDocumentSourceKitOptionsRequest: RequestType, Hashable {
public struct TextDocumentSourceKitOptionsRequest: BSPRequest, Hashable {
public static let method: String = "textDocument/sourceKitOptions"
public typealias Response = TextDocumentSourceKitOptionsResponse?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public import LanguageServerProtocol

/// The workspace build targets request is sent from the client to the server to
/// ask for the list of all available build targets in the workspace.
public struct WorkspaceBuildTargetsRequest: RequestType, Hashable {
public struct WorkspaceBuildTargetsRequest: BSPRequest, Hashable {
public static let method: String = "workspace/buildTargets"
public typealias Response = WorkspaceBuildTargetsResponse

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public import LanguageServerProtocol
///
/// If the build server is currently updating the build graph, this request should return after those updates have
/// finished processing.
public struct WorkspaceWaitForBuildSystemUpdatesRequest: RequestType, Hashable {
public struct WorkspaceWaitForBuildSystemUpdatesRequest: BSPRequest, Hashable {
public typealias Response = VoidResponse

public static let method: String = "workspace/waitForBuildSystemUpdates"
Expand Down
7 changes: 5 additions & 2 deletions Sources/LanguageServerProtocol/Message.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,17 @@ extension NotificationType {
}
}

public protocol LSPRequest: RequestType {}
public protocol LSPNotification: NotificationType {}

/// A `textDocument/*` notification, which takes a text document identifier
/// indicating which document it operates in or on.
public protocol TextDocumentNotification: NotificationType {
public protocol TextDocumentNotification: LSPNotification {
var textDocument: TextDocumentIdentifier { get }
}

/// A `textDocument/*` request, which takes a text document identifier
/// indicating which document it operates in or on.
public protocol TextDocumentRequest: RequestType {
public protocol TextDocumentRequest: LSPRequest {
var textDocument: TextDocumentIdentifier { get }
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/// As with any `$` requests, the server is free to ignore this notification.
///
/// - Parameter id: The request to cancel.
public struct CancelRequestNotification: NotificationType, Hashable {
public struct CancelRequestNotification: LSPNotification, Hashable {
public static let method: String = "$/cancelRequest"

/// The request to cancel.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

public struct CancelWorkDoneProgressNotification: NotificationType {
public struct CancelWorkDoneProgressNotification: LSPNotification {
public static let method: String = "window/workDoneProgress/cancel"

public var token: ProgressToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/// - Note: the format of the settings is implementation-defined.
///
/// - Parameter settings: The changed workspace settings.
public struct DidChangeConfigurationNotification: NotificationType {
public struct DidChangeConfigurationNotification: LSPNotification {
public static let method: String = "workspace/didChangeConfiguration"

/// The changed workspace settings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

public struct DidChangeActiveDocumentNotification: NotificationType {
public struct DidChangeActiveDocumentNotification: LSPNotification {
public static let method: String = "window/didChangeActiveDocument"

/// The document that is being displayed in the active editor or `null` to indicate that either no document is active
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//
//===----------------------------------------------------------------------===//

public struct DidCreateFilesNotification: NotificationType {
public struct DidCreateFilesNotification: LSPNotification {
public static let method: String = "workspace/didCreateFiles"

/// An array of all files/folders created in this operation.
Expand All @@ -21,7 +21,7 @@ public struct DidCreateFilesNotification: NotificationType {
}
}

public struct DidRenameFilesNotification: NotificationType {
public struct DidRenameFilesNotification: LSPNotification {
public static let method: String = "workspace/didRenameFiles"

/// An array of all files/folders renamed in this operation. When a folder
Expand All @@ -33,7 +33,7 @@ public struct DidRenameFilesNotification: NotificationType {
}
}

public struct DidDeleteFilesNotification: NotificationType {
public struct DidDeleteFilesNotification: LSPNotification {
public static let method: String = "workspace/didDeleteFiles"

/// An array of all files/folders created in this operation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/// Notification from the client when changes to watched files are detected.
///
/// - Parameter changes: The set of file changes.
public struct DidChangeWatchedFilesNotification: NotificationType {
public struct DidChangeWatchedFilesNotification: LSPNotification {
public static let method: String = "workspace/didChangeWatchedFiles"

/// The file changes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/// - Parameter event: The set of changes.
///
/// Requires the `workspaceFolders` capability on both the client and server.
public struct DidChangeWorkspaceFoldersNotification: NotificationType {
public struct DidChangeWorkspaceFoldersNotification: LSPNotification {
public static let method: String = "workspace/didChangeWorkspaceFolders"

/// The set of changes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/// Notification that the server process should exit.
///
/// This notification will come after the shutdown request finishes.
public struct ExitNotification: NotificationType, Hashable {
public struct ExitNotification: LSPNotification, Hashable {
public static let method: String = "exit"
public init() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//

/// Notification from the client that its own initialization of the language server has finished.
public struct InitializedNotification: NotificationType, Hashable {
public struct InitializedNotification: LSPNotification, Hashable {
public static let method: String = "initialized"

public init() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/// - Parameters:
/// - type: The kind of log message.
/// - message: The contents of the message.
public struct LogMessageNotification: NotificationType, Hashable {
public struct LogMessageNotification: LSPNotification, Hashable {
public static let method: String = "window/logMessage"

/// The kind of log message.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/// A notification to log the trace of the server’s execution. The amount and content of these notifications depends on the current trace configuration. If trace is 'off', the server should not send any logTrace notification. If trace is 'messages', the server should not add the 'verbose' field in the LogTraceParams.
///
/// $/logTrace should be used for systematic trace reporting. For single debugging messages, the server should send window/logMessage notifications.
public struct LogTraceNotification: NotificationType, Hashable, Codable {
public struct LogTraceNotification: LSPNotification, Hashable, Codable {
public static let method: String = "$/logTrace"

/// The message to be logged.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/// - Parameters:
/// - uri: The document in which the diagnostics should be shown.
/// - diagnostics: The complete list of diagnostics in the document, if any.
public struct PublishDiagnosticsNotification: NotificationType, Hashable, Codable {
public struct PublishDiagnosticsNotification: LSPNotification, Hashable, Codable {
public static let method: String = "textDocument/publishDiagnostics"

/// The document in which the diagnostics should be shown.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/// request for this document is executing at the same time.
///
/// **(LSP Extension)**
public struct ReopenTextDocumentNotification: NotificationType, Hashable {
public struct ReopenTextDocumentNotification: LSPNotification, Hashable {
public static let method: String = "textDocument/reopen"

/// The document identifier and initial contents.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
//===----------------------------------------------------------------------===//

/// A notification that should be used by the client to modify the trace setting of the server.
public struct SetTraceNotification: NotificationType, Hashable, Codable {
public struct SetTraceNotification: LSPNotification, Hashable, Codable {
public static let method: String = "$/setTrace"

/// The new value that should be assigned to the trace setting.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/// - Parameters:
/// - type: The kind of message.
/// - message: The contents of the message.
public struct ShowMessageNotification: NotificationType, Hashable {
public struct ShowMessageNotification: LSPNotification, Hashable {
public static let method: String = "window/showMessage"

/// The kind of message.
Expand Down
Loading