@@ -35,7 +35,7 @@ std::shared_ptr<vscode::Serializable> vscode::MakeFromRequest(std::string_view m
3535 {
3636 return MakeRequestObject<DidCloseTextDocumentParams>(json);
3737 }
38- else if (method == " updateEditorConfig" )
38+ else if (method == " updateEditorConfig" )
3939 {
4040 return MakeRequestObject<EditorConfigUpdateParams>(json);
4141 }
@@ -150,7 +150,7 @@ nlohmann::json vscode::PublishDiagnosticsParams::Serialize()
150150
151151 auto array = nlohmann::json::array ();
152152
153- for (auto & diagnositc: diagnostics)
153+ for (auto & diagnositc : diagnostics)
154154 {
155155 array.push_back (diagnositc.Serialize ());
156156 }
@@ -178,54 +178,58 @@ nlohmann::json vscode::TextDocumentSyncOptions::Serialize()
178178
179179 object[" openClose" ] = openClose;
180180 object[" change" ] = change;
181+ object[" willSave" ] = willSave;
182+ object[" willSaveWaitUntil" ] = willSaveWaitUntil;
181183
182184 return object;
183185}
184186
185- void vscode::TextDocumentSyncOptions::Deserialize (nlohmann::json json)
186- {
187- openClose = json[" openClose" ];
188- change = static_cast <TextDocumentSyncKind>(json[" change" ].get <int >());
189- }
190-
191187nlohmann::json vscode::ServerCapabilities::Serialize ()
192188{
193189 auto object = nlohmann::json::object ();
194190 object[" textDocumentSync" ] = textDocumentSync.Serialize ();
195191 object[" documentFormattingProvider" ] = documentFormattingProvider;
196-
192+ // object["codeActionProvider"] = codeActionProvider;
197193 return object;
198194}
199195
200- void vscode::ServerCapabilities::Deserialize (nlohmann::json json)
201- {
202- documentFormattingProvider = json[" documentFormattingProvider" ];
203- textDocumentSync.Deserialize (json[" textDocumentSync" ]);
204- }
205-
206196void vscode::InitializationOptions::Deserialize (nlohmann::json json)
207197{
208- auto configFileArray = json[" configFiles" ];
209-
210- for (auto & configSource: configFileArray)
198+ if (json[" configFiles" ].is_array ())
211199 {
212- auto & source = configFiles.emplace_back ();
213- source.Deserialize (configSource);
214- }
200+ auto configFileArray = json[" configFiles" ];
215201
216- auto workspaceFolderArray = json[" workspaceFolders" ];
217-
218- for (auto & workspaceUri: workspaceFolderArray)
202+ for (auto & configSource : configFileArray)
203+ {
204+ auto & source = configFiles.emplace_back ();
205+ source.Deserialize (configSource);
206+ }
207+ }
208+ if (json[" workspaceFolders" ].is_array ())
219209 {
220- workspaceFolders.emplace_back (workspaceUri);
210+ auto workspaceFolderArray = json[" workspaceFolders" ];
211+
212+ for (auto & workspaceUri : workspaceFolderArray)
213+ {
214+ workspaceFolders.emplace_back (workspaceUri);
215+ }
221216 }
222217}
223218
224219void vscode::InitializeParams::Deserialize (nlohmann::json json)
225220{
226- rootPath = json[" rootPath" ];
227- rootUri = json[" rootUri" ];
228- locale = json[" locale" ];
221+ if (json[" rootPath" ].is_string ())
222+ {
223+ rootPath = json[" rootPath" ];
224+ }
225+ if (json[" rootUri" ].is_string ())
226+ {
227+ rootUri = json[" rootUri" ];
228+ }
229+ if (json[" locale" ].is_string ())
230+ {
231+ locale = json[" locale" ];
232+ }
229233
230234 initializationOptions.Deserialize (json[" initializationOptions" ]);
231235}
@@ -290,14 +294,14 @@ void vscode::DocumentFormattingParams::Deserialize(nlohmann::json json)
290294
291295nlohmann::json vscode::DocumentFormattingResult::Serialize ()
292296{
293- if (hasError)
297+ if (hasError)
294298 {
295299 return nullptr ;
296300 }
297301 else
298302 {
299303 auto array = nlohmann::json::array ();
300- for (auto & edit: edits)
304+ for (auto & edit : edits)
301305 {
302306 array.push_back (edit.Serialize ());
303307 }
0 commit comments