Skip to content

Commit 6313416

Browse files
author
Richard Howell
committed
add requests for file watching in the bsp
1 parent e003e54 commit 6313416

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

Sources/BuildServerProtocol/Messages.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ import LanguageServerProtocol
1313

1414
fileprivate let requestTypes: [_RequestType.Type] = [
1515
InitializeBuild.self,
16+
RegisterForChanges.self,
1617
ShutdownBuild.self,
1718
SourceKitOptions.self,
1819
]
1920

2021
fileprivate let notificationTypes: [NotificationType.Type] = [
2122
ExitBuildNotification.self,
23+
FileOptionsChangedNotification.self,
2224
InitializedBuildNotification.self,
2325
]
2426

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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+
import LanguageServerProtocol
13+
14+
15+
/// The register for changes request is sent from the language
16+
/// server to the build server to register or unregister for
17+
/// changes in file options or dependencies. On changes a
18+
/// FileOptionsChangedNotification is sent.
19+
public struct RegisterForChanges: RequestType {
20+
public static let method: String = "textDocument/registerForChanges"
21+
public typealias Response = VoidResponse
22+
23+
/// The URL of the document to get options for.
24+
public var uri: URL
25+
26+
/// Whether to register or unregister for the file.
27+
public var action: RegisterAction
28+
29+
public init(uri: URL, action: RegisterAction) {
30+
self.uri = uri
31+
self.action = action
32+
}
33+
}
34+
35+
public enum RegisterAction: String, Hashable, Codable {
36+
case register = "register"
37+
case unregister = "unregister"
38+
}
39+
40+
/// The FileOptionsChangedNotification is sent from the
41+
/// build server to the language server when it detects
42+
/// changes to a registered files build settings.
43+
public struct FileOptionsChangedNotification: NotificationType {
44+
public static let method: String = "build/sourceKitOptionsChanged"
45+
46+
/// The URL of the document that has changed settings.
47+
public var uri: URL
48+
49+
/// The updated options for the registered file.
50+
public var options: [String]
51+
52+
/// The working directory for the compile command.
53+
public var workingDirectory: String?
54+
}

0 commit comments

Comments
 (0)