Skip to content

Commit a8cd9bf

Browse files
committed
More public initializers
1 parent c614d6b commit a8cd9bf

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Sources/LanguageServerProtocol/Requests/FormattingRequests.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ public struct DocumentFormattingRequest: TextDocumentRequest, Hashable {
2828

2929
/// Options to customize the formatting.
3030
public var options: FormattingOptions
31+
32+
public init(textDocument: TextDocumentIdentifier, options: FormattingOptions) {
33+
self.textDocument = textDocument
34+
self.options = options
35+
}
3136
}
3237

3338
/// Request to format a specified range within a document.
@@ -54,6 +59,12 @@ public struct DocumentRangeFormattingRequest: TextDocumentRequest, Hashable {
5459

5560
/// Options to customize the formatting.
5661
public var options: FormattingOptions
62+
63+
public init(textDocument: TextDocumentIdentifier, range: Range<Position>, options: FormattingOptions) {
64+
self.textDocument = textDocument
65+
self.range = range
66+
self.options = options
67+
}
5768
}
5869

5970
/// Request to format part of a document during typing.
@@ -87,6 +98,13 @@ public struct DocumentOnTypeFormattingRequest: TextDocumentRequest, Hashable {
8798

8899
/// Options to customize the formatting.
89100
public var options: FormattingOptions
101+
102+
public init(textDocument: TextDocumentIdentifier, position: Position, ch: String, options: FormattingOptions) {
103+
self.textDocument = textDocument
104+
self.position = position
105+
self.ch = ch
106+
self.options = options
107+
}
90108
}
91109

92110
/// Options to customize how document formatting requests are performed.
@@ -106,4 +124,12 @@ public struct FormattingOptions: Codable, Hashable {
106124

107125
/// Trim all newlines after the final newline at the end of the file.
108126
public var trimFinalNewlines: Bool?
127+
128+
public init(tabSize: Int, insertSpaces: Bool, trimTrailingWhitespace: Bool? = nil, insertFinalNewline: Bool? = nil, trimFinalNewlines: Bool? = nil) {
129+
self.tabSize = tabSize
130+
self.insertSpaces = insertSpaces
131+
self.trimTrailingWhitespace = trimTrailingWhitespace
132+
self.insertFinalNewline = insertFinalNewline
133+
self.trimFinalNewlines = trimFinalNewlines
134+
}
109135
}

0 commit comments

Comments
 (0)