File tree Expand file tree Collapse file tree 2 files changed +56
-7
lines changed
Sources/LanguageServerProtocol/SupportTypes Expand file tree Collapse file tree 2 files changed +56
-7
lines changed Original file line number Diff line number Diff line change @@ -152,12 +152,50 @@ extension Array: LSPAnyCodable where Element: LSPAnyCodable {
152
152
guard case . array( let array) = array else {
153
153
return nil
154
154
}
155
+
155
156
var result = [ Element] ( )
156
- for case . dictionary( let editDict) in array {
157
- guard let element = Element . init ( fromLSPDictionary: editDict) else {
157
+ for element in array {
158
+ switch element {
159
+ case . dictionary( let dict) :
160
+ if let value = Element ( fromLSPDictionary: dict) {
161
+ result. append ( value)
162
+ } else {
163
+ return nil
164
+ }
165
+ case . array( let value) :
166
+ if let value = value as? [ Element ] {
167
+ result. append ( contentsOf: value)
168
+ } else {
169
+ return nil
170
+ }
171
+ case . string( let value) :
172
+ if let value = value as? Element {
173
+ result. append ( value)
174
+ } else {
175
+ return nil
176
+ }
177
+ case . int( let value) :
178
+ if let value = value as? Element {
179
+ result. append ( value)
180
+ } else {
181
+ return nil
182
+ }
183
+ case . double( let value) :
184
+ if let value = value as? Element {
185
+ result. append ( value)
186
+ } else {
187
+ return nil
188
+ }
189
+ case . bool( let value) :
190
+ if let value = value as? Element {
191
+ result. append ( value)
192
+ } else {
193
+ return nil
194
+ }
195
+ case . null:
196
+ // null is not expected for non-optional Element
158
197
return nil
159
198
}
160
- result. append ( element)
161
199
}
162
200
self = result
163
201
}
Original file line number Diff line number Diff line change @@ -71,11 +71,22 @@ final class SemanticTokensTests: XCTestCase {
71
71
72
72
let registerCapabilityExpectation = expectation ( description: " \( #function) - register semantic tokens capability " )
73
73
testClient. handleNextRequest { ( req: RegisterCapabilityRequest ) -> VoidResponse in
74
- XCTAssert (
75
- req. registrations. contains { reg in
76
- reg. method == SemanticTokensRegistrationOptions . method
77
- }
74
+ let capabilityRegistration = req. registrations. first { reg in
75
+ reg. method == SemanticTokensRegistrationOptions . method
76
+ }
77
+
78
+ guard case . dictionary( let registerOptionsDict) = capabilityRegistration? . registerOptions,
79
+ let registerOptions = SemanticTokensRegistrationOptions ( fromLSPDictionary: registerOptionsDict)
80
+ else {
81
+ XCTFail ( " Expected semantic tokens registration options dictionary " )
82
+ return VoidResponse ( )
83
+ }
84
+
85
+ XCTAssertFalse (
86
+ registerOptions. semanticTokenOptions. legend. tokenTypes. isEmpty,
87
+ " Expected semantic tokens legend "
78
88
)
89
+
79
90
registerCapabilityExpectation. fulfill ( )
80
91
return VoidResponse ( )
81
92
}
You can’t perform that action at this time.
0 commit comments