Skip to content

Commit e5547e9

Browse files
committed
Create ShowDocumentRequest and ShowDocumentResponse
1 parent ed4eea3 commit e5547e9

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed

Sources/LanguageServerProtocol/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ add_library(LanguageServerProtocol STATIC
7373
Requests/RegisterCapabilityRequest.swift
7474
Requests/RenameRequest.swift
7575
Requests/SelectionRangeRequest.swift
76+
Requests/ShowDocumentRequest.swift
7677
Requests/ShowMessageRequest.swift
7778
Requests/ShutdownRequest.swift
7879
Requests/SignatureHelpRequest.swift

Sources/LanguageServerProtocol/Messages.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public let builtinRequests: [_RequestType.Type] = [
6565
RegisterCapabilityRequest.self,
6666
RenameRequest.self,
6767
SelectionRangeRequest.self,
68+
ShowDocumentRequest.self,
6869
ShowMessageRequest.self,
6970
ShutdownRequest.self,
7071
SignatureHelpRequest.self,
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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

Comments
 (0)