|
| 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