| 1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
| 2 | // |
| 3 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | |
| 5 | #include "languagefeatures.h" |
| 6 | |
| 7 | namespace newlsp{ |
| 8 | |
| 9 | std::string toJsonValueStr(const newlsp::DeclarationParams &val) |
| 10 | { |
| 11 | std::string ret = json::mergeObjs( |
| 12 | {toJsonValueStr(TextDocumentPositionParams(val)), |
| 13 | toJsonValueStr(WorkDoneProgressParams(val)), |
| 14 | toJsonValueStr(PartialResultParams(val)) }); |
| 15 | return ret; |
| 16 | } |
| 17 | |
| 18 | std::string toJsonValueStr(const DefinitionParams &val) |
| 19 | { |
| 20 | std::string ret = json::mergeObjs( |
| 21 | {toJsonValueStr(TextDocumentPositionParams(val)), |
| 22 | toJsonValueStr(WorkDoneProgressParams(val)), |
| 23 | toJsonValueStr(PartialResultParams(val))}); |
| 24 | return ret; |
| 25 | } |
| 26 | |
| 27 | std::string toJsonValueStr(const TypeDefinitionParams &val) |
| 28 | { |
| 29 | std::string ret = json::mergeObjs( |
| 30 | {toJsonValueStr(TextDocumentPositionParams(val)), |
| 31 | toJsonValueStr(WorkDoneProgressParams(val)), |
| 32 | toJsonValueStr(PartialResultParams(val))}); |
| 33 | return ret; |
| 34 | } |
| 35 | |
| 36 | std::string toJsonValueStr(const ImplementationParams &val) |
| 37 | { |
| 38 | std::string ret = json::mergeObjs( |
| 39 | {toJsonValueStr(TextDocumentPositionParams(val)), |
| 40 | toJsonValueStr(WorkDoneProgressParams(val)), |
| 41 | toJsonValueStr(PartialResultParams(val))}); |
| 42 | return ret; |
| 43 | } |
| 44 | |
| 45 | std::string toJsonValueStr(const ReferenceParams &val) |
| 46 | { |
| 47 | std::string ret = json::delScope(json::mergeObjs( |
| 48 | {toJsonValueStr(TextDocumentPositionParams(val)), |
| 49 | toJsonValueStr(WorkDoneProgressParams(val)), |
| 50 | toJsonValueStr(PartialResultParams(val))})); |
| 51 | ret = json::addValue(ret, json::KV{"context" , val.context}); |
| 52 | return json::addScope(ret); |
| 53 | } |
| 54 | |
| 55 | std::string toJsonValueStr(const CallHierarchyPrepareParams &val) |
| 56 | { |
| 57 | std::string ret = json::mergeObjs( |
| 58 | {toJsonValueStr(TextDocumentPositionParams(val)), |
| 59 | toJsonValueStr(WorkDoneProgressParams(val))}); |
| 60 | return ret; |
| 61 | } |
| 62 | |
| 63 | std::string toJsonValueStr(const CallHierarchyIncomingCallsParams &val) |
| 64 | { |
| 65 | std::string ret = json::delScope(json::mergeObjs( |
| 66 | {toJsonValueStr(WorkDoneProgressParams(val)), |
| 67 | toJsonValueStr(PartialResultParams(val))})); |
| 68 | ret = json::addValue(ret, json::KV{"item" , val.item}); |
| 69 | return json::addScope(ret); |
| 70 | } |
| 71 | |
| 72 | std::string toJsonValueStr(const CallHierarchyOutgoingCallsParams &val) |
| 73 | { |
| 74 | std::string ret = json::delScope(json::mergeObjs( |
| 75 | {toJsonValueStr(WorkDoneProgressParams(val)), |
| 76 | toJsonValueStr(PartialResultParams(val))})); |
| 77 | ret = json::addValue(ret, json::KV{"item" , val.item}); |
| 78 | return json::addScope(ret); |
| 79 | } |
| 80 | |
| 81 | std::string toJsonValueStr(const CallHierarchyItem &val) |
| 82 | { |
| 83 | std::string ret; |
| 84 | ret = json::addValue(ret, json::KV{"name" , val.name}); |
| 85 | ret = json::addValue(ret, json::KV{"kind" , val.kind}); |
| 86 | ret = json::addValue(ret, json::KV{"tags" , val.tags}); |
| 87 | ret = json::addValue(ret, json::KV{"detail" , val.detail}); |
| 88 | ret = json::addValue(ret, json::KV{"uri" , val.uri}); |
| 89 | ret = json::addValue(ret, json::KV{"range" , val.range}); |
| 90 | ret = json::addValue(ret, json::KV{"selectionRange" , val.selectionRange}); |
| 91 | ret = json::addValue(ret, json::KV{"data" , val.data}); |
| 92 | return json::addScope(ret); |
| 93 | } |
| 94 | |
| 95 | std::string toJsonValueStr(const ReferenceParams::ReferenceContext &val) |
| 96 | { |
| 97 | std::string ret; |
| 98 | ret = json::addValue(ret, json::KV{"includeDeclaration" , val.includeDeclaration}); |
| 99 | return json::addScope(ret); |
| 100 | } |
| 101 | |
| 102 | std::string toJsonValueStr(const TypeHierarchyPrepareParams &val) |
| 103 | { |
| 104 | std::string ret = json::mergeObjs( |
| 105 | {toJsonValueStr(TextDocumentPositionParams(val)), |
| 106 | toJsonValueStr(WorkDoneProgressParams(val))}); |
| 107 | return ret; |
| 108 | } |
| 109 | |
| 110 | std::string toJsonValueStr(const TypeHierarchySupertypesParams &val) |
| 111 | { |
| 112 | std::string ret = json::delScope(json::mergeObjs( |
| 113 | {toJsonValueStr(WorkDoneProgressParams(val)), |
| 114 | toJsonValueStr(PartialResultParams(val))})); |
| 115 | ret = json::addValue(ret, json::KV{"item" , val.item}); |
| 116 | return json::addScope(ret); |
| 117 | } |
| 118 | |
| 119 | std::string toJsonValueStr(const TypeHierarchyItem &val) |
| 120 | { |
| 121 | std::string ret; |
| 122 | ret = json::addValue(ret, json::KV{"name" , val.name}); |
| 123 | ret = json::addValue(ret, json::KV{"kind" , val.kind}); |
| 124 | ret = json::addValue(ret, json::KV{"tags" , val.tags}); |
| 125 | ret = json::addValue(ret, json::KV{"detail" , val.detail}); |
| 126 | ret = json::addValue(ret, json::KV{"uri" , val.uri}); |
| 127 | ret = json::addValue(ret, json::KV{"range" , val.range}); |
| 128 | ret = json::addValue(ret, json::KV{"selectionRange" , val.selectionRange}); |
| 129 | ret = json::addValue(ret, json::KV{"data" , val.data}); |
| 130 | return json::addScope(ret); |
| 131 | } |
| 132 | |
| 133 | std::string toJsonValueStr(const TypeHierarchySubtypesParams &val) |
| 134 | { |
| 135 | std::string ret = json::delScope(json::mergeObjs( |
| 136 | {toJsonValueStr(WorkDoneProgressParams(val)), |
| 137 | toJsonValueStr(PartialResultParams(val))})); |
| 138 | ret = json::addValue(ret, json::KV{"item" , val.item}); |
| 139 | return json::addScope(ret); |
| 140 | } |
| 141 | |
| 142 | std::string toJsonValueStr(const DocumentHighlightParams &val) |
| 143 | { |
| 144 | std::string ret = json::mergeObjs( |
| 145 | {toJsonValueStr(TextDocumentPositionParams(val)), |
| 146 | toJsonValueStr(WorkDoneProgressParams(val)), |
| 147 | toJsonValueStr(PartialResultParams(val))}); |
| 148 | return ret; |
| 149 | } |
| 150 | |
| 151 | std::string toJsonValueStr(const DocumentLinkParams &val) |
| 152 | { |
| 153 | std::string ret = json::delScope(json::mergeObjs( |
| 154 | {toJsonValueStr(WorkDoneProgressParams(val)), |
| 155 | toJsonValueStr(PartialResultParams(val))})); |
| 156 | ret = json::addValue(ret, json::KV{"textDocument" , val.textDocument}); |
| 157 | return json::addScope(ret); |
| 158 | } |
| 159 | |
| 160 | std::string toJsonValueStr(const DocumentLink &val) |
| 161 | { |
| 162 | std::string ret; |
| 163 | ret = json::addValue(ret, json::KV{"range" , val.range}); |
| 164 | ret = json::addValue(ret, json::KV{"target" , val.target}); |
| 165 | ret = json::addValue(ret, json::KV{"tooltip" , val.tooltip}); |
| 166 | ret = json::addValue(ret, json::KV{"data" , val.data}); |
| 167 | return json::addScope(ret); |
| 168 | } |
| 169 | |
| 170 | std::string toJsonValueStr(const HoverParams &val) |
| 171 | { |
| 172 | std::string ret = json::mergeObjs( |
| 173 | {toJsonValueStr(TextDocumentPositionParams(val)), |
| 174 | toJsonValueStr(WorkDoneProgressParams(val))}); |
| 175 | return ret; |
| 176 | } |
| 177 | |
| 178 | std::string toJsonValueStr(const CodeLensParams &val) |
| 179 | { |
| 180 | std::string ret = json::delScope(json::mergeObjs( |
| 181 | {toJsonValueStr(WorkDoneProgressParams(val)), |
| 182 | toJsonValueStr(PartialResultParams(val))})); |
| 183 | ret = json::addValue(ret, json::KV{"textDocument" , val.textDocument}); |
| 184 | return json::addScope(ret); |
| 185 | } |
| 186 | |
| 187 | std::string toJsonValueStr(const CodeLens &val) |
| 188 | { |
| 189 | std::string ret; |
| 190 | ret = json::addValue(ret, json::KV{"range" , val.range}); |
| 191 | ret = json::addValue(ret, json::KV{"command" , val.command}); |
| 192 | ret = json::addValue(ret, json::KV{"data" , val.data}); |
| 193 | return json::addScope(ret); |
| 194 | } |
| 195 | |
| 196 | std::string toJsonValueStr(const FoldingRangeParams &val) |
| 197 | { |
| 198 | std::string ret = json::delScope(json::mergeObjs( |
| 199 | {toJsonValueStr(WorkDoneProgressParams(val)), |
| 200 | toJsonValueStr(PartialResultParams(val))})); |
| 201 | ret = json::addValue(ret, json::KV{"textDocument" , val.textDocument}); |
| 202 | return json::addScope(ret); |
| 203 | } |
| 204 | |
| 205 | std::string toJsonValueStr(const SelectionRangeParams &val) |
| 206 | { |
| 207 | std::string ret = json::delScope(json::mergeObjs( |
| 208 | {toJsonValueStr(WorkDoneProgressParams(val)), |
| 209 | toJsonValueStr(PartialResultParams(val))})); |
| 210 | ret = json::addValue(ret, json::KV{"textDocument" , val.textDocument}); |
| 211 | ret = json::addValue(ret, json::KV{"positions" , val.positions}); |
| 212 | return json::addScope(ret); |
| 213 | } |
| 214 | |
| 215 | std::string toJsonValueStr(const DocumentSymbolParams &val) |
| 216 | { |
| 217 | std::string ret = json::delScope(json::mergeObjs( |
| 218 | {toJsonValueStr(WorkDoneProgressParams(val)), |
| 219 | toJsonValueStr(PartialResultParams(val))})); |
| 220 | ret = json::addValue(ret, json::KV{"textDocument" , val.textDocument}); |
| 221 | return json::addScope(ret); |
| 222 | } |
| 223 | |
| 224 | std::string toJsonValueStr(const SemanticTokensParams &val) |
| 225 | { |
| 226 | std::string ret = json::delScope(json::mergeObjs( |
| 227 | {toJsonValueStr(WorkDoneProgressParams(val)), |
| 228 | toJsonValueStr(PartialResultParams(val))})); |
| 229 | ret = json::addValue(ret, json::KV{"textDocument" , val.textDocument}); |
| 230 | return json::addScope(ret); |
| 231 | } |
| 232 | |
| 233 | std::string toJsonValueStr(const SemanticTokensDeltaParams &val) |
| 234 | { |
| 235 | std::string ret = json::delScope(json::mergeObjs( |
| 236 | {toJsonValueStr(WorkDoneProgressParams(val)), |
| 237 | toJsonValueStr(PartialResultParams(val))})); |
| 238 | ret = json::addValue(ret, json::KV{"textDocument" , val.textDocument}); |
| 239 | ret = json::addValue(ret, json::KV{"previousResultId" , val.previousResultId}); |
| 240 | return json::addScope(ret); |
| 241 | } |
| 242 | |
| 243 | std::string toJsonValueStr(const SemanticTokensRangeParams &val) |
| 244 | { |
| 245 | std::string ret = json::delScope(json::mergeObjs( |
| 246 | {toJsonValueStr(WorkDoneProgressParams(val)), |
| 247 | toJsonValueStr(PartialResultParams(val))})); |
| 248 | ret = json::addValue(ret, json::KV{"textDocument" , val.textDocument}); |
| 249 | ret = json::addValue(ret, json::KV{"range" , val.range}); |
| 250 | return json::addScope(ret); |
| 251 | } |
| 252 | |
| 253 | std::string toJsonValueStr(const InlayHintParams &val) |
| 254 | { |
| 255 | std::string ret = json::delScope(toJsonValueStr(WorkDoneProgressParams(val))); |
| 256 | ret = json::addValue(ret, json::KV{"textDocument" , val.textDocument}); |
| 257 | ret = json::addValue(ret, json::KV{"range" , val.range}); |
| 258 | return json::addScope(ret); |
| 259 | } |
| 260 | |
| 261 | std::string toJsonValueStr(const InlineValueParams &val) |
| 262 | { |
| 263 | std::string ret = json::delScope(toJsonValueStr(WorkDoneProgressParams(val))); |
| 264 | ret = json::addValue(ret, json::KV{"textDocument" , val.textDocument}); |
| 265 | ret = json::addValue(ret, json::KV{"range" , val.range}); |
| 266 | ret = json::addValue(ret, json::KV{"context" , val.context}); |
| 267 | return json::addScope(ret); |
| 268 | } |
| 269 | |
| 270 | std::string toJsonValueStr(const InlineValueContext &val) |
| 271 | { |
| 272 | std::string ret; |
| 273 | ret = json::addValue(ret, json::KV{"frameId" , val.frameId}); |
| 274 | ret = json::addValue(ret, json::KV{"stoppedLocation" , val.stoppedLocation}); |
| 275 | return json::addScope(ret); |
| 276 | } |
| 277 | |
| 278 | std::string toJsonValueStr(const MonikerParams &val) |
| 279 | { |
| 280 | std::string ret = json::mergeObjs( |
| 281 | {toJsonValueStr(TextDocumentPositionParams(val)), |
| 282 | toJsonValueStr(WorkDoneProgressParams(val)), |
| 283 | toJsonValueStr(PartialResultParams(val)) }); |
| 284 | return ret; |
| 285 | } |
| 286 | |
| 287 | std::string toJsonValueStr(const CompletionContext &val) |
| 288 | { |
| 289 | std::string ret; |
| 290 | ret = json::addValue(ret, json::KV{"triggerKind" , val.triggerKind}); |
| 291 | ret = json::addValue(ret, json::KV{"triggerCharacter" , val.triggerCharacter}); |
| 292 | return json::addScope(ret); |
| 293 | } |
| 294 | |
| 295 | std::string toJsonValueStr(const CompletionParams &val) |
| 296 | { |
| 297 | std::string ret = json::delScope(json::mergeObjs( |
| 298 | {toJsonValueStr(TextDocumentPositionParams(val)), |
| 299 | toJsonValueStr(WorkDoneProgressParams(val)), |
| 300 | toJsonValueStr(PartialResultParams(val))})); |
| 301 | ret = json::addValue(ret, json::KV{"context" , val.context}); |
| 302 | return json::addScope(ret); |
| 303 | } |
| 304 | |
| 305 | std::string toJsonValueStr(const DocumentDiagnosticParams &val) |
| 306 | { |
| 307 | std::string ret = json::delScope(json::mergeObjs( |
| 308 | {toJsonValueStr(WorkDoneProgressParams(val)), |
| 309 | toJsonValueStr(PartialResultParams(val))})); |
| 310 | ret = json::addValue(ret, json::KV{"textDocument" , val.textDocument}); |
| 311 | ret = json::addValue(ret, json::KV{"identifier" , val.identifier}); |
| 312 | ret = json::addValue(ret, json::KV{"previousResultId" , val.previousResultId}); |
| 313 | return json::addScope(ret); |
| 314 | } |
| 315 | |
| 316 | std::string toJsonValueStr(const PreviousResultId &val) |
| 317 | { |
| 318 | std::string ret; |
| 319 | ret = json::addValue(ret, json::KV{"uri" , val.uri}); |
| 320 | ret = json::addValue(ret, json::KV{"value" , val.value}); |
| 321 | return json::addScope(ret); |
| 322 | } |
| 323 | |
| 324 | std::string toJsonValueStr(const WorkspaceDiagnosticParams &val) |
| 325 | { |
| 326 | std::string ret = json::delScope(json::mergeObjs( |
| 327 | {toJsonValueStr(WorkDoneProgressParams(val)), |
| 328 | toJsonValueStr(PartialResultParams(val))})); |
| 329 | ret = json::addValue(ret, json::KV{"identifier" , val.identifier}); |
| 330 | ret = json::addValue(ret, json::KV{"previousResultIds" , val.previousResultIds}); |
| 331 | return json::addScope(ret); |
| 332 | } |
| 333 | |
| 334 | std::string toJsonValueStr(const SignatureHelpParams::SignatureHelpContext::SignatureHelp::SignatureInformation::ParameterInformation &val) |
| 335 | { |
| 336 | std::string ret; |
| 337 | ret = json::addValue(ret, json::KV{"label" , val.label}); |
| 338 | ret = json::addValue(ret, json::KV{"documentation" , val.documentation}); |
| 339 | return json::addScope(ret); |
| 340 | } |
| 341 | |
| 342 | std::string toJsonValueStr(const SignatureHelpParams::SignatureHelpContext::SignatureHelp::SignatureInformation &val) |
| 343 | { |
| 344 | std::string ret; |
| 345 | ret = json::addValue(ret, json::KV{"label" , val.label}); |
| 346 | ret = json::addValue(ret, json::KV{"parameters" , val.parameters}); |
| 347 | ret = json::addValue(ret, json::KV{"documentation" , val.documentation}); |
| 348 | ret = json::addValue(ret, json::KV{"activeParameter" , val.activeParameter}); |
| 349 | return json::addScope(ret); |
| 350 | } |
| 351 | |
| 352 | std::string toJsonValueStr(const SignatureHelpParams::SignatureHelpContext::SignatureHelp &val) |
| 353 | { |
| 354 | std::string ret; |
| 355 | ret = json::addValue(ret, json::KV{"signatures" , val.signatures}); |
| 356 | ret = json::addValue(ret, json::KV{"activeParameter" , val.activeParameter}); |
| 357 | ret = json::addValue(ret, json::KV{"activeSignature" , val.activeSignature}); |
| 358 | return json::addScope(ret); |
| 359 | } |
| 360 | |
| 361 | std::string toJsonValueStr(const SignatureHelpParams::SignatureHelpContext &val) |
| 362 | { |
| 363 | std::string ret; |
| 364 | ret = json::addValue(ret, json::KV{"isRetrigger" , val.isRetrigger}); |
| 365 | ret = json::addValue(ret, json::KV{"triggerKind" , val.triggerKind}); |
| 366 | ret = json::addValue(ret, json::KV{"triggerCharacter" , val.triggerCharacter}); |
| 367 | ret = json::addValue(ret, json::KV{"activeSignatureHelp" , val.activeSignatureHelp}); |
| 368 | return json::addScope(ret); |
| 369 | } |
| 370 | |
| 371 | std::string toJsonValueStr(const SignatureHelpParams &val) |
| 372 | { |
| 373 | std::string ret = json::delScope(json::mergeObjs( |
| 374 | {toJsonValueStr(TextDocumentPositionParams(val)), |
| 375 | toJsonValueStr(WorkDoneProgressParams(val))})); |
| 376 | ret = json::addValue(ret, json::KV{"isRetrigger" , val.context}); |
| 377 | return json::addScope(ret); |
| 378 | } |
| 379 | |
| 380 | std::string toJsonValueStr(const CodeActionParams &val) |
| 381 | { |
| 382 | std::string ret = json::delScope(json::mergeObjs( |
| 383 | {toJsonValueStr(WorkDoneProgressParams(val)), |
| 384 | toJsonValueStr(PartialResultParams(val))})); |
| 385 | ret = json::addValue(ret, json::KV{"textDocument" , val.textDocument}); |
| 386 | ret = json::addValue(ret, json::KV{"range" , val.range}); |
| 387 | ret = json::addValue(ret, json::KV{"context" , val.context}); |
| 388 | return json::addScope(ret); |
| 389 | } |
| 390 | |
| 391 | std::string toJsonValueStr(const CodeAction::Disabled &val) |
| 392 | { |
| 393 | std::string ret; |
| 394 | ret = json::addValue(ret, json::KV{"reason" , val.reason}); |
| 395 | return json::addScope(ret); |
| 396 | } |
| 397 | |
| 398 | std::string toJsonValueStr(const CodeAction &val) |
| 399 | { |
| 400 | std::string ret; |
| 401 | ret = json::addValue(ret, json::KV{"title" , val.title}); |
| 402 | ret = json::addValue(ret, json::KV{"kind" , val.kind}); |
| 403 | ret = json::addValue(ret, json::KV{"diagnostics" , val.diagnostics}); |
| 404 | ret = json::addValue(ret, json::KV{"isPreferred" , val.isPreferred}); |
| 405 | ret = json::addValue(ret, json::KV{"disabled" , val.disabled}); |
| 406 | ret = json::addValue(ret, json::KV{"edit" , val.edit}); |
| 407 | ret = json::addValue(ret, json::KV{"command" , val.command}); |
| 408 | ret = json::addValue(ret, json::KV{"data" , val.data}); |
| 409 | return json::addScope(ret); |
| 410 | } |
| 411 | |
| 412 | std::string toJsonValueStr(const CodeActionContext &val) |
| 413 | { |
| 414 | std::string ret; |
| 415 | ret = json::addValue(ret, json::KV{"only" , val.only}); |
| 416 | ret = json::addValue(ret, json::KV{"diagnostics" , val.diagnostics}); |
| 417 | ret = json::addValue(ret, json::KV{"triggerKind" , val.triggerKind}); |
| 418 | return json::addScope(ret); |
| 419 | } |
| 420 | |
| 421 | std::string toJsonValueStr(const DocumentColorParams &val) |
| 422 | { |
| 423 | std::string ret = json::delScope(json::mergeObjs( |
| 424 | {toJsonValueStr(WorkDoneProgressParams(val)), |
| 425 | toJsonValueStr(PartialResultParams(val))})); |
| 426 | ret = json::addValue(ret, json::KV{"textDocument" , val.textDocument}); |
| 427 | return json::addScope(ret); |
| 428 | } |
| 429 | |
| 430 | std::string toJsonValueStr(const Color &val) |
| 431 | { |
| 432 | std::string ret; |
| 433 | ret = json::addValue(ret, json::KV{"red" , val.red}); |
| 434 | ret = json::addValue(ret, json::KV{"blue" , val.blue}); |
| 435 | ret = json::addValue(ret, json::KV{"green" , val.green}); |
| 436 | ret = json::addValue(ret, json::KV{"alpha" , val.alpha}); |
| 437 | return json::addScope(ret); |
| 438 | } |
| 439 | |
| 440 | std::string toJsonValueStr(const ColorPresentationParams &val) |
| 441 | { |
| 442 | std::string ret = json::delScope(json::mergeObjs( |
| 443 | {toJsonValueStr(WorkDoneProgressParams(val)), |
| 444 | toJsonValueStr(PartialResultParams(val))})); |
| 445 | ret = json::addValue(ret, json::KV{"textDocument" , val.textDocument}); |
| 446 | ret = json::addValue(ret, json::KV{"color" , val.color}); |
| 447 | ret = json::addValue(ret, json::KV{"range" , val.range}); |
| 448 | return json::addScope(ret); |
| 449 | } |
| 450 | |
| 451 | std::string toJsonValueStr(const FormattingOptions &val) |
| 452 | { |
| 453 | std::string ret; |
| 454 | ret = json::addValue(ret, json::KV{"tabSize" , val.tabSize}); |
| 455 | ret = json::addValue(ret, json::KV{"insertSpaces" , val.insertSpaces}); |
| 456 | ret = json::addValue(ret, json::KV{"trimTrailingWhitespace" , val.trimTrailingWhitespace}); |
| 457 | ret = json::addValue(ret, json::KV{"insertFinalNewline" , val.insertFinalNewline}); |
| 458 | ret = json::addValue(ret, json::KV{"trimFinalNewlines" , val.trimFinalNewlines}); |
| 459 | for (auto &&pairVal : val) { |
| 460 | if (any_contrast<bool>(pairVal.second)) { |
| 461 | ret = json::addValue(ret, json::KV{pairVal.first, std::any_cast<bool>(pairVal.second)}); |
| 462 | } else if(any_contrast<int>(pairVal.second)) { |
| 463 | ret = json::addValue(ret, json::KV{pairVal.first, std::any_cast<int>(pairVal.second)}); |
| 464 | } else if(any_contrast<std::string>(pairVal.second)) { |
| 465 | ret = json::addValue(ret, json::KV{pairVal.first, std::any_cast<std::string>(pairVal.second)}); |
| 466 | } |
| 467 | } |
| 468 | return json::addScope(ret); |
| 469 | } |
| 470 | |
| 471 | std::string toJsonValueStr(const DocumentFormattingParams &val) |
| 472 | { |
| 473 | std::string ret = json::delScope(toJsonValueStr(WorkDoneProgressParams(val))); |
| 474 | ret = json::addValue(ret, json::KV{"options" , val.options}); |
| 475 | ret = json::addValue(ret, json::KV{"textDocument" , val.textDocument}); |
| 476 | return json::addScope(ret); |
| 477 | } |
| 478 | |
| 479 | std::string toJsonValueStr(const DocumentRangeFormattingParams &val) |
| 480 | { |
| 481 | std::string ret = json::delScope(toJsonValueStr(WorkDoneProgressParams(val))); |
| 482 | ret = json::addValue(ret, json::KV{"options" , val.options}); |
| 483 | ret = json::addValue(ret, json::KV{"range" , val.range}); |
| 484 | ret = json::addValue(ret, json::KV{"textDocument" , val.textDocument}); |
| 485 | return json::addScope(ret); |
| 486 | } |
| 487 | |
| 488 | std::string toJsonValueStr(const DocumentOnTypeFormattingParams &val) |
| 489 | { |
| 490 | std::string ret; |
| 491 | ret = json::addValue(ret, json::KV{"textDocument" , val.textDocument}); |
| 492 | ret = json::addValue(ret, json::KV{"options" , val.options}); |
| 493 | ret = json::addValue(ret, json::KV{"ch" , val.ch}); |
| 494 | ret = json::addValue(ret, json::KV{"position" , val.position}); |
| 495 | return json::addScope(ret); |
| 496 | } |
| 497 | |
| 498 | std::string toJsonValueStr(const RenameParams &val) |
| 499 | { |
| 500 | std::string ret = json::delScope(json::mergeObjs( |
| 501 | {toJsonValueStr(TextDocumentPositionParams(val)), |
| 502 | toJsonValueStr(WorkDoneProgressParams(val))})); |
| 503 | ret = json::addValue(ret, json::KV{"newName" , val.newName}); |
| 504 | return json::addScope(ret); |
| 505 | } |
| 506 | |
| 507 | std::string toJsonValueStr(const PrepareRenameParams &val) |
| 508 | { |
| 509 | std::string ret = json::delScope(json::mergeObjs( |
| 510 | {toJsonValueStr(TextDocumentPositionParams(val)), |
| 511 | toJsonValueStr(WorkDoneProgressParams(val))})); |
| 512 | return json::addScope(ret); |
| 513 | } |
| 514 | |
| 515 | std::string toJsonValueStr(const LinkedEditingRangeParams &val) |
| 516 | { |
| 517 | std::string ret = json::delScope(json::mergeObjs( |
| 518 | {toJsonValueStr(TextDocumentPositionParams(val)), |
| 519 | toJsonValueStr(WorkDoneProgressParams(val))})); |
| 520 | return json::addScope(ret); |
| 521 | } |
| 522 | |
| 523 | } // namespace newlsp |
| 524 | |