Skip to content

Commit 79e312b

Browse files
authored
Merge pull request #206 from ahoppen/match-spec-part-2
Part 2: Update the struct definitions to match version 3.14 of the LSP spec
2 parents c52b337 + 4c07ec7 commit 79e312b

File tree

11 files changed

+535
-101
lines changed

11 files changed

+535
-101
lines changed

Sources/LanguageServerProtocol/ClientCapabilities.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ public struct TextDocumentClientCapabilities: Hashable, Codable {
295295
/// The client supports additional metadata in the form of declaration links.
296296
public var linkSupport: Bool? = nil
297297

298-
public init(dynamicRegistration: Bool? = nil, linkSupport: Bool?) {
298+
public init(dynamicRegistration: Bool? = nil, linkSupport: Bool? = nil) {
299299
self.dynamicRegistration = dynamicRegistration
300300
self.linkSupport = linkSupport
301301
}

Sources/LanguageServerProtocol/Hover.swift

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public struct HoverResponse: ResponseType, Hashable {
5656
}
5757

5858
public enum HoverResponseContents: Hashable {
59-
case markedString(MarkedString)
6059
case markedStrings([MarkedString])
6160
case markupContent(MarkupContent)
6261
}
@@ -96,13 +95,11 @@ extension MarkedString: Codable {
9695
extension HoverResponseContents: Codable {
9796
public init(from decoder: Decoder) throws {
9897
if let value = try? MarkupContent(from: decoder) {
99-
self = .markupContent(value)
100-
} else if let value = try? MarkedString(from: decoder) {
101-
self = .markedString(value)
98+
self = .markupContent(value)
10299
} else if let value = try? [MarkedString](from: decoder) {
103-
self = .markedStrings(value)
104-
} else if let value = try? MarkupContent(from: decoder) {
105-
self = .markupContent(value)
100+
self = .markedStrings(value)
101+
} else if let value = try? MarkedString(from: decoder) {
102+
self = .markedStrings([value])
106103
} else {
107104
let context = DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Expected MarkedString, [MarkedString], or MarkupContent")
108105
throw DecodingError.dataCorrupted(context)
@@ -111,8 +108,6 @@ extension HoverResponseContents: Codable {
111108

112109
public func encode(to encoder: Encoder) throws {
113110
switch self {
114-
case .markedString(let value):
115-
try value.encode(to: encoder)
116111
case .markedStrings(let value):
117112
try value.encode(to: encoder)
118113
case .markupContent(let value):

0 commit comments

Comments
 (0)