Skip to content

Commit e4c2a3f

Browse files
authored
Merge pull request #1002 from krzyzanowskim/marcin/missing-initializers-2
More public initializers
2 parents 25a1b45 + 11d6e55 commit e4c2a3f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Sources/LanguageServerProtocol/Requests/FormattingRequests.swift

Lines changed: 32 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,18 @@ 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(
129+
tabSize: Int,
130+
insertSpaces: Bool,
131+
trimTrailingWhitespace: Bool? = nil,
132+
insertFinalNewline: Bool? = nil,
133+
trimFinalNewlines: Bool? = nil
134+
) {
135+
self.tabSize = tabSize
136+
self.insertSpaces = insertSpaces
137+
self.trimTrailingWhitespace = trimTrailingWhitespace
138+
self.insertFinalNewline = insertFinalNewline
139+
self.trimFinalNewlines = trimFinalNewlines
140+
}
109141
}

0 commit comments

Comments
 (0)