|
| 1 | +//===----------------------------------------------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift.org open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2014 - 2024 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 | +/// Request from the server to the client to show a document on the client side. |
| 14 | +/// |
| 15 | +/// - Parameters: |
| 16 | +/// - uri: The uri to show. |
| 17 | +/// - external: An optional boolean indicates to show the resource in an external program. |
| 18 | +/// - takeFocus: An optional boolean to indicate whether the editor showing the document should take focus or not. |
| 19 | +/// - selection: An optional selection range if the document is a text document. |
| 20 | +public struct ShowDocumentRequest: RequestType { |
| 21 | + public static let method: String = "window/showDocument" |
| 22 | + public typealias Response = ShowDocumentResponse |
| 23 | + |
| 24 | + /// The uri to show. |
| 25 | + public var uri: DocumentURI |
| 26 | + |
| 27 | + /// An optional boolean indicates to show the resource in an external |
| 28 | + /// program. To show, for example, `https://www.swift.org/ in the default WEB |
| 29 | + /// browser set `external` to `true`. |
| 30 | + public var external: Bool? |
| 31 | + |
| 32 | + /// An optional boolean to indicate whether the editor showing the document |
| 33 | + /// should take focus or not. Clients might ignore this property if an |
| 34 | + /// external program is started. |
| 35 | + public var takeFocus: Bool? |
| 36 | + |
| 37 | + /// An optional selection range if the document is a text document. Clients |
| 38 | + /// might ignore the property if an external program is started or the file |
| 39 | + /// is not a text file. |
| 40 | + public var selection: Range<Position>? |
| 41 | + |
| 42 | + public init(uri: DocumentURI, external: Bool? = nil, takeFocus: Bool? = nil, selection: Range<Position>? = nil) { |
| 43 | + self.uri = uri |
| 44 | + self.external = external |
| 45 | + self.takeFocus = takeFocus |
| 46 | + self.selection = selection |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +public struct ShowDocumentResponse: Codable, Hashable, ResponseType { |
| 51 | + /// A boolean indicating if the show was successful. |
| 52 | + public var success: Bool |
| 53 | + |
| 54 | + public init(success: Bool) { |
| 55 | + self.success = success |
| 56 | + } |
| 57 | +} |
0 commit comments