Skip to content

Commit a0c6c6e

Browse files
authored
Merge pull request #2342 from rintaro/base-message-protocols
[LSP/BSP] Separate base message protocol for LSP and BSP message types
2 parents 79562eb + 651d4da commit a0c6c6e

File tree

74 files changed

+106
-88
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+106
-88
lines changed

Sources/BuildServerProtocol/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ add_library(BuildServerProtocol STATIC
44
Messages/BuildShutdownRequest.swift
55
Messages/BuildTargetPrepareRequest.swift
66
Messages/BuildTargetSourcesRequest.swift
7+
Messages/CancelRequestNotification.swift
78
Messages/InitializeBuildRequest.swift
89
Messages/OnBuildExitNotification.swift
910
Messages/OnBuildInitializedNotification.swift

Sources/BuildServerProtocol/Messages.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
public import LanguageServerProtocol
1414

15+
public protocol BSPRequest: RequestType {}
16+
public protocol BSPNotification: NotificationType {}
17+
1518
private let requestTypes: [_RequestType.Type] = [
1619
BuildShutdownRequest.self,
1720
BuildTargetPrepareRequest.self,

Sources/BuildServerProtocol/Messages/BuildShutdownRequest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public import LanguageServerProtocol
1717
/// but to not exit (otherwise the response might not be delivered
1818
/// correctly to the client). There is a separate exit notification
1919
/// that asks the server to exit.
20-
public struct BuildShutdownRequest: RequestType {
20+
public struct BuildShutdownRequest: BSPRequest {
2121
public static let method: String = "build/shutdown"
2222
public typealias Response = VoidResponse
2323

Sources/BuildServerProtocol/Messages/BuildTargetPrepareRequest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public typealias OriginId = String
2525
///
2626
/// The server communicates during the initialize handshake whether this method is supported or not by setting
2727
/// `prepareProvider: true` in `SourceKitInitializeBuildResponseData`.
28-
public struct BuildTargetPrepareRequest: RequestType, Hashable {
28+
public struct BuildTargetPrepareRequest: BSPRequest, Hashable {
2929
public static let method: String = "buildTarget/prepare"
3030
public typealias Response = VoidResponse
3131

Sources/BuildServerProtocol/Messages/BuildTargetSourcesRequest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public import LanguageServerProtocol
1616
/// query for the list of text documents and directories that belong to a
1717
/// build target. The sources response must not include sources that are
1818
/// external to the workspace.
19-
public struct BuildTargetSourcesRequest: RequestType, Hashable {
19+
public struct BuildTargetSourcesRequest: BSPRequest, Hashable {
2020
public static let method: String = "buildTarget/sources"
2121
public typealias Response = BuildTargetSourcesResponse
2222

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2019 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 import LanguageServerProtocol
14+
15+
extension CancelRequestNotification: BSPNotification {}

Sources/BuildServerProtocol/Messages/InitializeBuildRequest.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public import LanguageServerProtocol
2626
/// Until the server has responded to the initialize request with an
2727
/// InitializeBuildResult, the client must not send any additional
2828
/// requests or notifications to the server.
29-
public struct InitializeBuildRequest: RequestType, Hashable {
29+
public struct InitializeBuildRequest: BSPRequest, Hashable {
3030
public static let method: String = "build/initialize"
3131
public typealias Response = InitializeBuildResponse
3232

Sources/BuildServerProtocol/Messages/OnBuildExitNotification.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
public import LanguageServerProtocol
14-
1513
/// Like the language server protocol, a notification to ask the
1614
/// server to exit its process. The server should exit with success
1715
/// code 0 if the shutdown request has been received before;
1816
/// otherwise with error code 1.
19-
public struct OnBuildExitNotification: NotificationType {
17+
public struct OnBuildExitNotification: BSPNotification {
2018
public static let method: String = "build/exit"
2119

2220
public init() {}

Sources/BuildServerProtocol/Messages/OnBuildInitializedNotification.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
public import LanguageServerProtocol
14-
1513
/// 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.
16-
public struct OnBuildInitializedNotification: NotificationType {
14+
public struct OnBuildInitializedNotification: BSPNotification {
1715
public static let method: String = "build/initialized"
1816

1917
public init() {}

Sources/BuildServerProtocol/Messages/OnBuildLogMessageNotification.swift

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,10 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
public import LanguageServerProtocol
14-
1513
/// The log message notification is sent from a server to a client to ask the client to log a particular message in its console.
1614
///
1715
/// A `build/logMessage`` notification is similar to LSP's `window/logMessage``, except for a few additions like id and originId.
18-
public struct OnBuildLogMessageNotification: NotificationType {
16+
public struct OnBuildLogMessageNotification: BSPNotification {
1917
public static let method: String = "build/logMessage"
2018

2119
/// The message type.

0 commit comments

Comments
 (0)