| 1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
| 2 | // |
| 3 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | |
| 5 | #ifndef BASICJSONSTRUCTURES_H |
| 6 | #define BASICJSONSTRUCTURES_H |
| 7 | |
| 8 | #include "common/type/menuext.h" |
| 9 | |
| 10 | #include <any> |
| 11 | #include <map> |
| 12 | #include <optional> |
| 13 | |
| 14 | // std::optional has default set empty is ( 'value' | null ) |
| 15 | |
| 16 | namespace newlsp { |
| 17 | |
| 18 | extern const QString K_ID; |
| 19 | extern const QString K_JSON_RPC; |
| 20 | extern const QString V_2_0; |
| 21 | extern const QString K_METHOD; |
| 22 | extern const QString K_RESULT; |
| 23 | extern const QString K_PARAMS; |
| 24 | extern const QString H_CONTENT_LENGTH; |
| 25 | extern const QString H_CONTENT_TYPE; |
| 26 | extern const QString H_CHARSET; |
| 27 | extern const QString RK_CONTENT_LENGTH; // RegExp Key |
| 28 | extern const QString RK_CONTENT_TYPE; |
| 29 | extern const QString RK_CHARSET; |
| 30 | |
| 31 | QString methodData(int id, const QString &method, const QJsonObject ¶ms); |
| 32 | QString notificationData(const QString &method, const QJsonObject ¶ms); |
| 33 | |
| 34 | template<class T> |
| 35 | static bool any_contrast(const std::any &any) |
| 36 | { |
| 37 | if (any.type() == std::any(T()).type()) { |
| 38 | return true; |
| 39 | } |
| 40 | return false; |
| 41 | } |
| 42 | |
| 43 | std::string toJsonValueStr(unsigned int value); |
| 44 | std::string toJsonValueStr(int value); |
| 45 | std::string toJsonValueStr(bool value); |
| 46 | std::string toJsonValueStr(float value); |
| 47 | std::string toJsonValueStr(double value); |
| 48 | std::string toJsonValueStr(const std::string &value); |
| 49 | std::string toJsonValueStr(const std::vector<int> &vecInt); |
| 50 | std::string toJsonValueStr(const std::vector<std::string> &vecString); |
| 51 | |
| 52 | namespace json |
| 53 | { |
| 54 | std::string addScope(const std::string &src); |
| 55 | std::string delScope(const std::string &obj); |
| 56 | std::string mergeObjs(const std::vector<std::string> &objs); |
| 57 | std::string formatKey(const std::string &key); |
| 58 | |
| 59 | template<class T> |
| 60 | struct KV |
| 61 | { |
| 62 | std::string key; |
| 63 | T value; |
| 64 | typedef std::string type_first; |
| 65 | typedef T type_second; |
| 66 | KV() = delete; |
| 67 | KV(const std::string &key, const T &value) |
| 68 | : key(key), value(value){} |
| 69 | }; |
| 70 | |
| 71 | template <class T> |
| 72 | std::string addValue(const std::string &src, const KV<T> &kv) |
| 73 | { |
| 74 | std::string temp; |
| 75 | if (kv.key.empty()) |
| 76 | return temp; |
| 77 | |
| 78 | temp = formatKey(kv.key) + ":" + toJsonValueStr(kv.value); |
| 79 | |
| 80 | if (!src.empty()) |
| 81 | return src + "," + temp; |
| 82 | else |
| 83 | return temp; |
| 84 | } |
| 85 | |
| 86 | template <class T> |
| 87 | std::string addValue(const std::string &src, const KV<std::optional<T>> &kv) |
| 88 | { |
| 89 | std::string ret; |
| 90 | if (kv.value) { |
| 91 | ret = addValue(src, json::KV{kv.key, kv.value.value()}); |
| 92 | } |
| 93 | return ret; |
| 94 | } |
| 95 | |
| 96 | template <class T> |
| 97 | std::string addValue(const std::string &src, const KV<std::vector<T>> &kv) |
| 98 | { |
| 99 | std::string temp; |
| 100 | if (kv.key.empty()) |
| 101 | return temp; |
| 102 | |
| 103 | if (kv.value.size() < 0) |
| 104 | return temp; |
| 105 | |
| 106 | temp += "[" ; |
| 107 | int n = kv.value.size(); |
| 108 | for (int i = 0; i < n; i++) { |
| 109 | temp += toJsonValueStr(kv.value[i]); |
| 110 | if (i < n - 1) |
| 111 | temp += "," ; |
| 112 | } |
| 113 | temp += "]" ; |
| 114 | temp = formatKey(kv.key) + ":" + temp; |
| 115 | if (!src.empty()) |
| 116 | return src + "," + temp; |
| 117 | else |
| 118 | return temp; |
| 119 | } |
| 120 | |
| 121 | template <class T> |
| 122 | std::string addValue(const std::string &src, const KV<std::optional<std::vector<T>>> &kv) |
| 123 | { |
| 124 | std::string ret; |
| 125 | if (kv.value) { |
| 126 | ret = addValue(src, json::KV{kv.key, kv.value.value()}); |
| 127 | } |
| 128 | return ret; |
| 129 | } |
| 130 | |
| 131 | }; |
| 132 | |
| 133 | namespace Enum { |
| 134 | |
| 135 | enum_def(ResourceOperationKind, std::string) |
| 136 | { |
| 137 | enum_exp Create = "create" ; |
| 138 | enum_exp Rename = "rename" ; |
| 139 | enum_exp Delete = "delete" ; |
| 140 | }; |
| 141 | |
| 142 | enum_def(FailureHandlingKind, std::string) |
| 143 | { |
| 144 | enum_exp Abort = "abort" ; |
| 145 | enum_exp Transactional = "transactional" ; |
| 146 | enum_exp Undo = "undo" ; |
| 147 | enum_exp TextOnlyTransactional = "textOnlyTransactional" ; |
| 148 | }; |
| 149 | |
| 150 | enum_def(SymbolKind, int) |
| 151 | { |
| 152 | enum_exp File = 1; |
| 153 | enum_exp Module = 2; |
| 154 | enum_exp Namespace = 3; |
| 155 | enum_exp Package = 4; |
| 156 | enum_exp Class = 5; |
| 157 | enum_exp Method = 6; |
| 158 | enum_exp Property = 7; |
| 159 | enum_exp Field = 8; |
| 160 | enum_exp Constructor = 9; |
| 161 | enum_exp Enum = 10; |
| 162 | enum_exp Interface = 11; |
| 163 | enum_exp Function = 12; |
| 164 | enum_exp Variable = 13; |
| 165 | enum_exp Constant = 14; |
| 166 | enum_exp String = 15; |
| 167 | enum_exp Number = 16; |
| 168 | enum_exp Boolean = 17; |
| 169 | enum_exp Array = 18; |
| 170 | enum_exp Object = 19; |
| 171 | enum_exp Key = 20; |
| 172 | enum_exp Null = 21; |
| 173 | enum_exp EnumMember = 22; |
| 174 | enum_exp Struct = 23; |
| 175 | enum_exp Event = 24; |
| 176 | enum_exp Operator = 25; |
| 177 | enum_exp TypeParameter = 26; |
| 178 | }; |
| 179 | |
| 180 | enum_def(SymbolTag, int) |
| 181 | { |
| 182 | enum_exp Deprecated = 1; |
| 183 | }; |
| 184 | |
| 185 | enum_def(MarkupKind, std::string) |
| 186 | { |
| 187 | enum_exp Markdown = "markdown" ; |
| 188 | enum_exp PlainText = "plaintext" ; |
| 189 | }; |
| 190 | |
| 191 | enum_def(CompletionItemTag, int) |
| 192 | { |
| 193 | enum_exp Deprecated = 1; |
| 194 | }; |
| 195 | |
| 196 | enum_def(InsertTextMode, int) |
| 197 | { |
| 198 | enum_exp asIs = 1; |
| 199 | enum_exp adjustIndentation = 2; |
| 200 | }; |
| 201 | |
| 202 | enum_def(CompletionItemKind, int) |
| 203 | { |
| 204 | enum_exp Text = 1; |
| 205 | enum_exp Method = 2; |
| 206 | enum_exp Function = 3; |
| 207 | enum_exp Constructor = 4; |
| 208 | enum_exp Field = 5; |
| 209 | enum_exp Variable = 6; |
| 210 | enum_exp Class = 7; |
| 211 | enum_exp Interface = 8; |
| 212 | enum_exp Module = 9; |
| 213 | enum_exp Property = 10; |
| 214 | enum_exp Unit = 11; |
| 215 | enum_exp Value = 12; |
| 216 | enum_exp Enum = 13; |
| 217 | enum_exp Keyword = 14; |
| 218 | enum_exp Snippet = 15; |
| 219 | enum_exp Color = 16; |
| 220 | enum_exp File = 17; |
| 221 | enum_exp Reference = 18; |
| 222 | enum_exp Folder = 19; |
| 223 | enum_exp EnumMember = 20; |
| 224 | enum_exp Constant = 21; |
| 225 | enum_exp Struct = 22; |
| 226 | enum_exp Event = 23; |
| 227 | enum_exp Operator = 24; |
| 228 | enum_exp TypeParameter = 25; |
| 229 | }; |
| 230 | |
| 231 | enum_def(CodeActionKind, std::string) |
| 232 | { |
| 233 | enum_exp Empty = "" ; |
| 234 | enum_exp QuickFix = "quickfix" ; |
| 235 | enum_exp Refactor = "refactor" ; |
| 236 | enum_exp = "refactor.extract" ; |
| 237 | enum_exp RefactorInline = "refactor.inline" ; |
| 238 | enum_exp RefactorRewrite = "refactor.rewrite" ; |
| 239 | enum_exp Source = "source" ; |
| 240 | enum_exp SourceOrganizeImports = "source.organizeImports" ; |
| 241 | enum_exp SourceFixAll = "source.fixAll" ; |
| 242 | }; |
| 243 | |
| 244 | enum_def(PrepareSupportDefaultBehavior, int) |
| 245 | { |
| 246 | enum_exp Identifier = 1; |
| 247 | }; |
| 248 | |
| 249 | enum_def(DiagnosticTag, int) |
| 250 | { |
| 251 | enum_exp Unnecessary = 1; |
| 252 | enum_exp Deprecated = 2; |
| 253 | }; |
| 254 | |
| 255 | enum_def(FoldingRangeKind, std::string) |
| 256 | { |
| 257 | enum_exp = "comment" ; |
| 258 | enum_exp Imports = "imports" ; |
| 259 | enum_exp Region = "region" ; |
| 260 | }; |
| 261 | |
| 262 | enum_def(TokenFormat, std::string) |
| 263 | { |
| 264 | enum_exp Relative = "relative" ; |
| 265 | }; |
| 266 | |
| 267 | enum_def(PositionEncodingKind, std::string) |
| 268 | { |
| 269 | enum_exp UTF8 = "utf-8" ; |
| 270 | enum_exp UTF16 = "utf-16" ; |
| 271 | enum_exp UTF32 = "utf-32" ; |
| 272 | }; |
| 273 | |
| 274 | enum_def(TraceValue, std::string) |
| 275 | { |
| 276 | enum_exp Off = "off" ; |
| 277 | enum_exp Message = "messages" ; |
| 278 | enum_exp Verbose = "verbose" ; |
| 279 | }; |
| 280 | |
| 281 | enum_def(SemanticTokenTypes, std::string) |
| 282 | { |
| 283 | enum_exp Namespace = "namespace" ; |
| 284 | /** |
| 285 | * Represents a generic type. Acts as a fallback for types which |
| 286 | * can"t be mapped to a specific type like class or enum. |
| 287 | */ |
| 288 | enum_exp Type = "type" ; |
| 289 | enum_exp Class = "class" ; |
| 290 | enum_exp Enum = "enum" ; |
| 291 | enum_exp Interface = "interface" ; |
| 292 | enum_exp Struct = "struct" ; |
| 293 | enum_exp TypeParameter = "typeParameter" ; |
| 294 | enum_exp Parameter = "parameter" ; |
| 295 | enum_exp Variable = "variable" ; |
| 296 | enum_exp Property = "property" ; |
| 297 | enum_exp EnumMember = "enumMember" ; |
| 298 | enum_exp Event = "event" ; |
| 299 | enum_exp Function = "function" ; |
| 300 | enum_exp Method = "method" ; |
| 301 | enum_exp Macro = "macro" ; |
| 302 | enum_exp Keyword = "keyword" ; |
| 303 | enum_exp Modifier = "modifier" ; |
| 304 | enum_exp = "comment" ; |
| 305 | enum_exp String = "string" ; |
| 306 | enum_exp Number = "number" ; |
| 307 | enum_exp Regexp = "regexp" ; |
| 308 | enum_exp Operator = "operator" ; |
| 309 | /** |
| 310 | * @since 3.17.0 |
| 311 | */ |
| 312 | enum_exp Decorator = "decorator" ; |
| 313 | }; |
| 314 | |
| 315 | |
| 316 | enum_def(SemanticTokenModifiers, std::string) |
| 317 | { |
| 318 | enum_exp Declaration = "declaration" ; |
| 319 | enum_exp Definition = "definition" ; |
| 320 | enum_exp Readonly = "readonly" ; |
| 321 | enum_exp Static = "static" ; |
| 322 | enum_exp Deprecated = "deprecated" ; |
| 323 | enum_exp Abstract = "abstract" ; |
| 324 | enum_exp Async = "async" ; |
| 325 | enum_exp Modification = "modification" ; |
| 326 | enum_exp Documentation = "documentation" ; |
| 327 | enum_exp DefaultLibrary = "defaultLibrary" ; |
| 328 | }; |
| 329 | |
| 330 | enum_def(Properties, std::string) |
| 331 | { |
| 332 | enum_exp label_location = "label.location" ; |
| 333 | enum_exp edit = "edit" ; |
| 334 | }; |
| 335 | |
| 336 | enum_def(DiagnosticSeverity, int) |
| 337 | { |
| 338 | enum_exp Error = 1; |
| 339 | enum_exp Warning = 2; |
| 340 | enum_exp Information = 3; |
| 341 | enum_exp Hint = 4; |
| 342 | }; |
| 343 | |
| 344 | enum_def(CompletionTriggerKind, int) { |
| 345 | enum_exp Invoked = 1; |
| 346 | enum_exp TriggerCharacter = 2; |
| 347 | enum_exp TriggerForIncompleteCompletions = 3; |
| 348 | }; |
| 349 | |
| 350 | enum_def(InsertTextFormat, int) { |
| 351 | enum_exp PlainText = 1; |
| 352 | enum_exp Snippet = 2; |
| 353 | }; |
| 354 | |
| 355 | enum_def(InlayHintKind, int) |
| 356 | { |
| 357 | enum_exp Type = 1; |
| 358 | enum_exp Parameter = 2; |
| 359 | }; |
| 360 | |
| 361 | enum_def(MonikerKind, std::string){ |
| 362 | enum_exp Import = "import" ; |
| 363 | enum_exp Export = "export" ; // source export, conflict with native grammar |
| 364 | enum_exp Local = "local" ; |
| 365 | }; |
| 366 | |
| 367 | enum_def(UniquenessLevel, std::string) { |
| 368 | enum_exp document = "document" ; |
| 369 | enum_exp project = "project" ; |
| 370 | enum_exp group = "group" ; |
| 371 | enum_exp scheme = "scheme" ; |
| 372 | enum_exp global = "global" ; |
| 373 | }; |
| 374 | |
| 375 | enum_def(SignatureHelpTriggerKind, int) |
| 376 | { |
| 377 | enum_exp Invoked = 1; |
| 378 | enum_exp TriggerCharacter = 2; |
| 379 | enum_exp ContentChange = 3; |
| 380 | }; |
| 381 | |
| 382 | enum_def(TextDocumentSaveReason, int) |
| 383 | { |
| 384 | enum_exp Manual = 1; |
| 385 | enum_exp AfterDelay = 2; |
| 386 | enum_exp FocusOut = 3; |
| 387 | }; |
| 388 | |
| 389 | enum_def(TextDocumentSyncKind, int) |
| 390 | { |
| 391 | enum_exp None = 0; |
| 392 | enum_exp Full = 1; |
| 393 | enum_exp Incremental = 2; |
| 394 | }; |
| 395 | |
| 396 | enum_def(NotebookCellKind, int) |
| 397 | { |
| 398 | enum_exp Markup = 1; |
| 399 | enum_exp Code = 2; |
| 400 | }; |
| 401 | |
| 402 | enum_def(DocumentHighlightKind, int){ |
| 403 | enum_exp Text = 1; |
| 404 | enum_exp Read = 2; |
| 405 | enum_exp Write = 3; |
| 406 | }; |
| 407 | |
| 408 | enum_def(CodeActionTriggerKind, int) |
| 409 | { |
| 410 | enum_exp Invoked = 1; |
| 411 | enum_exp Automatic = 2; |
| 412 | }; |
| 413 | |
| 414 | } // BasicEnum |
| 415 | |
| 416 | typedef std::string DocumentUri; |
| 417 | typedef std::string URI ; |
| 418 | |
| 419 | struct ProgressToken : std::any |
| 420 | { |
| 421 | ProgressToken(int val) : std::any(val){} |
| 422 | ProgressToken(const std::string &val) : std::any(val){} |
| 423 | }; |
| 424 | std::string toJsonValueStr(const ProgressToken &val); |
| 425 | |
| 426 | struct Position |
| 427 | { |
| 428 | int line; |
| 429 | int character; |
| 430 | Position() = default; |
| 431 | Position(int line, int character) |
| 432 | : line(line), character(character){} |
| 433 | }; |
| 434 | std::string toJsonValueStr(const Position &val); |
| 435 | |
| 436 | struct Range |
| 437 | { |
| 438 | Position start; |
| 439 | Position end; |
| 440 | Range() = default; |
| 441 | Range(const Position &start, const Position &end) |
| 442 | : start(start), end(end){} |
| 443 | }; |
| 444 | |
| 445 | std::string toJsonValueStr(const Range &val); |
| 446 | |
| 447 | struct TextDocumentItem |
| 448 | { |
| 449 | DocumentUri uri; |
| 450 | std::string languageId; |
| 451 | int version; |
| 452 | std::string text; |
| 453 | }; |
| 454 | |
| 455 | struct TextDocumentIdentifier |
| 456 | { |
| 457 | DocumentUri uri; |
| 458 | }; |
| 459 | std::string toJsonValueStr(const TextDocumentIdentifier &val); |
| 460 | |
| 461 | struct VersionedTextDocumentIdentifier : TextDocumentIdentifier |
| 462 | { |
| 463 | int version; |
| 464 | }; |
| 465 | std::string toJsonValueStr(const VersionedTextDocumentIdentifier &val); |
| 466 | |
| 467 | struct OptionalVersionedTextDocumentIdentifier : TextDocumentIdentifier |
| 468 | { |
| 469 | std::optional<int> version; |
| 470 | }; |
| 471 | std::string toJsonValueStr(const OptionalVersionedTextDocumentIdentifier &val); |
| 472 | |
| 473 | struct TextDocumentPositionParams |
| 474 | { |
| 475 | TextDocumentIdentifier textDocument; |
| 476 | Position position; |
| 477 | }; |
| 478 | std::string toJsonValueStr(const TextDocumentPositionParams &val); |
| 479 | |
| 480 | struct DocumentFilter |
| 481 | { |
| 482 | std::optional<std::string> language; |
| 483 | std::optional<std::string> scheme; |
| 484 | std::optional<std::string> pattern; |
| 485 | }; |
| 486 | std::string toJsonValueStr(const DocumentFilter &val); |
| 487 | |
| 488 | struct DocumentSelector: std::vector<DocumentFilter> |
| 489 | { |
| 490 | }; |
| 491 | std::string toJsonValueStr(const DocumentSelector &val); |
| 492 | |
| 493 | struct TextEdit |
| 494 | { |
| 495 | Range range; |
| 496 | std::string newText; |
| 497 | }; |
| 498 | std::string toJsonValueStr(const TextEdit &val); |
| 499 | |
| 500 | struct ChangeAnnotation |
| 501 | { |
| 502 | std::string label; |
| 503 | std::optional<bool> needsConfirmation; |
| 504 | std::optional<std::string> description; |
| 505 | }; |
| 506 | std::string toJsonValueStr(const ChangeAnnotation &val); |
| 507 | |
| 508 | typedef std::string ChangeAnnotationIdentifier; |
| 509 | |
| 510 | struct AnnotatedTextEdit : TextEdit |
| 511 | { |
| 512 | ChangeAnnotationIdentifier annotationId; |
| 513 | }; |
| 514 | std::string toJsonValueStr(const AnnotatedTextEdit &val); |
| 515 | |
| 516 | struct TextDocumentEdit |
| 517 | { |
| 518 | struct Edits : std::vector<AnnotatedTextEdit>, std::vector<TextEdit> { |
| 519 | Edits() = default; |
| 520 | Edits(const std::vector<AnnotatedTextEdit> &val) : std::vector<AnnotatedTextEdit>(val){} |
| 521 | Edits(const std::vector<TextEdit> &val) : std::vector<TextEdit>(val){} |
| 522 | }; |
| 523 | OptionalVersionedTextDocumentIdentifier textDocument; |
| 524 | Edits edits; |
| 525 | }; |
| 526 | std::string toJsonValueStr(const TextDocumentEdit::Edits &val); |
| 527 | std::string toJsonValueStr(const TextDocumentEdit &val); |
| 528 | |
| 529 | struct Location |
| 530 | { |
| 531 | DocumentUri uri; |
| 532 | Range range; |
| 533 | }; |
| 534 | std::string toJsonValueStr(const Location &val); |
| 535 | |
| 536 | struct LocationLink |
| 537 | { |
| 538 | Range originSelectionRange; |
| 539 | DocumentUri targetUri; |
| 540 | Range targetRange; |
| 541 | Range targetSelectionRange; |
| 542 | }; |
| 543 | |
| 544 | struct CodeDescription |
| 545 | { |
| 546 | URI href; |
| 547 | }; |
| 548 | std::string toJsonValueStr(const CodeDescription &val); |
| 549 | |
| 550 | struct DiagnosticRelatedInformation |
| 551 | { |
| 552 | Location location; |
| 553 | std::string message; |
| 554 | }; |
| 555 | std::string toJsonValueStr(const DiagnosticRelatedInformation &val); |
| 556 | |
| 557 | struct Diagnostic |
| 558 | { |
| 559 | Range range; |
| 560 | std::optional<Enum::DiagnosticSeverity::type_value> severity; |
| 561 | std::optional<std::any> code; // int or string |
| 562 | std::optional<CodeDescription> codeDescription; |
| 563 | std::optional<std::string> source; |
| 564 | std::optional<std::string> message; |
| 565 | std::optional<std::vector<Enum::DiagnosticTag::type_value>> tags; |
| 566 | std::optional<std::vector<DiagnosticRelatedInformation>> relatedInformation; |
| 567 | std::optional<std::string> data; // unknown; |
| 568 | }; |
| 569 | std::string toJsonValueStr(const Diagnostic &val); |
| 570 | |
| 571 | struct Command |
| 572 | { |
| 573 | std::string title; |
| 574 | std::string command; |
| 575 | std::optional<std::vector<std::string>> arguments; |
| 576 | }; |
| 577 | std::string toJsonValueStr(const Command &val); |
| 578 | |
| 579 | struct MarkupContent |
| 580 | { |
| 581 | Enum::MarkupKind::type_value kind; |
| 582 | std::string value; |
| 583 | }; |
| 584 | |
| 585 | struct CreateFileOptions |
| 586 | { |
| 587 | std::optional<bool> overwrite; |
| 588 | std::optional<bool> ignoreIfExists; |
| 589 | }; |
| 590 | std::string toJsonValueStr(const CreateFileOptions &val); |
| 591 | |
| 592 | struct CreateFile |
| 593 | { |
| 594 | const std::string kind{"create" }; |
| 595 | DocumentUri uri; |
| 596 | std::optional<CreateFileOptions> options; |
| 597 | std::optional<ChangeAnnotationIdentifier> annotationId; |
| 598 | }; |
| 599 | std::string toJsonValueStr(const CreateFile &val); |
| 600 | |
| 601 | struct RenameFileOptions |
| 602 | { |
| 603 | std::optional<bool> overwrite; |
| 604 | std::optional<bool> ignoreIfExists; |
| 605 | }; |
| 606 | std::string toJsonValueStr(const RenameFileOptions &val); |
| 607 | |
| 608 | struct RenameFile |
| 609 | { |
| 610 | const std::string kind{"rename" }; |
| 611 | DocumentUri oldUri; |
| 612 | DocumentUri newUri; |
| 613 | std::optional<RenameFileOptions> options; |
| 614 | std::optional<ChangeAnnotationIdentifier> annotationId; |
| 615 | }; |
| 616 | std::string toJsonValueStr(const RenameFile &val); |
| 617 | |
| 618 | struct DeleteFileOptions |
| 619 | { |
| 620 | std::optional<bool> recursive; |
| 621 | std::optional<bool> ignoreIfNotExists; |
| 622 | }; |
| 623 | std::string toJsonValueStr(const DeleteFileOptions &val); |
| 624 | |
| 625 | struct DeleteFile |
| 626 | { |
| 627 | const std::string kind{"delete" }; |
| 628 | DocumentUri uri; |
| 629 | std::optional<DeleteFileOptions> options; |
| 630 | std::optional<ChangeAnnotationIdentifier> annotationId; |
| 631 | }; |
| 632 | std::string toJsonValueStr(const DeleteFile &val);; |
| 633 | |
| 634 | struct WorkspaceEdit |
| 635 | { |
| 636 | // { [uri: DocumentUri]: TextEdit[]; }; |
| 637 | struct Changes : std::map<DocumentUri, std::vector<TextEdit>> {}; |
| 638 | struct ChangeAnnotations : std::map<std::string, ChangeAnnotation> {}; |
| 639 | struct DocumentChanges : std::any { |
| 640 | DocumentChanges() = default; |
| 641 | DocumentChanges(const std::vector<TextDocumentEdit> &val) : std::any(val){} |
| 642 | DocumentChanges(const std::vector<CreateFile> &val) : std::any(val){} |
| 643 | DocumentChanges(const std::vector<RenameFile> &val) : std::any(val){} |
| 644 | DocumentChanges(const std::vector<DeleteFile> &val) : std::any(val){} |
| 645 | }; |
| 646 | std::optional<Changes> changes; |
| 647 | // ( TextDocumentEdit[] | (TextDocumentEdit | CreateFile | RenameFile | DeleteFile)[]); |
| 648 | std::optional<DocumentChanges> documentChanges; |
| 649 | std::optional<ChangeAnnotations> changeAnnotations; |
| 650 | }; |
| 651 | std::string toJsonValueStr(const WorkspaceEdit::Changes &val); |
| 652 | std::string toJsonValueStr(const WorkspaceEdit::DocumentChanges &val); |
| 653 | std::string toJsonValueStr(const WorkspaceEdit::ChangeAnnotations &val); |
| 654 | std::string toJsonValueStr(const WorkspaceEdit &val); |
| 655 | |
| 656 | struct WorkDoneProgressBegin |
| 657 | { |
| 658 | const std::string kind {"begin" }; |
| 659 | std::string title; |
| 660 | std::optional<bool> boolean; |
| 661 | std::optional<std::string> message; |
| 662 | std::optional<unsigned int> percentage; |
| 663 | }; |
| 664 | |
| 665 | struct WorkDoneProgressReport |
| 666 | { |
| 667 | const std::string kind {"report" }; |
| 668 | std::optional<bool> cancellable; |
| 669 | std::optional<std::string> message; |
| 670 | std::optional<unsigned int> percentage; |
| 671 | }; |
| 672 | |
| 673 | struct WorkDoneProgressEnd |
| 674 | { |
| 675 | const std::string kind {"end" }; |
| 676 | std::optional<std::string> message; |
| 677 | }; |
| 678 | |
| 679 | struct WorkDoneProgressParams |
| 680 | { |
| 681 | std::optional<ProgressToken> workDoneToken; |
| 682 | }; |
| 683 | std::string toJsonValueStr(const WorkDoneProgressParams ¶ms); |
| 684 | |
| 685 | struct WorkDoneProgressOptions |
| 686 | { |
| 687 | std::optional<bool> workDoneProgress; |
| 688 | }; |
| 689 | std::string toJsonValueStr(const WorkDoneProgressOptions ¶ms); |
| 690 | |
| 691 | struct PartialResultParams |
| 692 | { |
| 693 | std::optional<ProgressToken> partialResultToken; |
| 694 | }; |
| 695 | std::string toJsonValueStr(const PartialResultParams ¶ms); |
| 696 | |
| 697 | } // lsp |
| 698 | |
| 699 | #endif // BASICJSONSTRUCTURES_H |
| 700 | |