1 /* 2 *Copyright (C) 2018 Laurent Tréguier 3 * 4 *This file is part of DLS. 5 * 6 *DLS is free software: you can redistribute it and/or modify 7 *it under the terms of the GNU General Public License as published by 8 *the Free Software Foundation, either version 3 of the License, or 9 *(at your option) any later version. 10 * 11 *DLS is distributed in the hope that it will be useful, 12 *but WITHOUT ANY WARRANTY; without even the implied warranty of 13 *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 *GNU General Public License for more details. 15 * 16 *You should have received a copy of the GNU General Public License 17 *along with DLS. If not, see <http://www.gnu.org/licenses/>. 18 * 19 */ 20 21 module dls.protocol.interfaces.text_document; 22 23 import dls.protocol.definitions; 24 import dls.protocol.interfaces.client : TextDocumentRegistrationOptions; 25 import std.json : JSONValue; 26 27 final class DidOpenTextDocumentParams 28 { 29 TextDocumentItem textDocument; 30 31 @safe this() pure nothrow 32 { 33 this.textDocument = new TextDocumentItem(); 34 } 35 } 36 37 final class DidChangeTextDocumentParams 38 { 39 VersionedTextDocumentIdentifier textDocument; 40 TextDocumentContentChangeEvent[] contentChanges; 41 42 @safe this() pure nothrow 43 { 44 this.textDocument = new VersionedTextDocumentIdentifier(); 45 } 46 } 47 48 final class TextDocumentContentChangeEvent 49 { 50 import std.typecons : Nullable; 51 52 Nullable!Range range; 53 Nullable!size_t rangeLength; 54 string text; 55 56 @safe this() pure nothrow 57 { 58 } 59 } 60 61 final class TextDocumentChangeRegistrationOptions : TextDocumentRegistrationOptions 62 { 63 import dls.protocol.interfaces.general : TextDocumentSyncKind; 64 65 TextDocumentSyncKind syncKind; 66 67 @safe this(TextDocumentSyncKind syncKind = TextDocumentSyncKind.init) pure nothrow 68 { 69 this.syncKind = syncKind; 70 } 71 } 72 73 private class ParamsBase 74 { 75 TextDocumentIdentifier textDocument; 76 77 @safe this() pure nothrow 78 { 79 this.textDocument = new TextDocumentIdentifier(); 80 } 81 } 82 83 final class WillSaveTextDocumentParams : ParamsBase 84 { 85 TextDocumentSaveReason reason; 86 87 @safe this() pure nothrow 88 { 89 } 90 } 91 92 enum TextDocumentSaveReason : ubyte 93 { 94 manual = 1, 95 afterDelay = 2, 96 focusOut = 3 97 } 98 99 final class DidSaveTextDocumentParams : ParamsBase 100 { 101 import std.typecons : Nullable; 102 103 Nullable!string text; 104 105 @safe this() pure nothrow 106 { 107 } 108 } 109 110 final class TextDocumentSaveRegistrationOptions : TextDocumentRegistrationOptions 111 { 112 import std.typecons : Nullable; 113 114 Nullable!bool includeText; 115 116 @safe this(Nullable!bool includeText = Nullable!bool.init) pure nothrow 117 { 118 this.includeText = includeText; 119 } 120 } 121 122 alias DidCloseTextDocumentParams = ParamsBase; 123 124 final class PublishDiagnosticsParams 125 { 126 DocumentUri uri; 127 Diagnostic[] diagnostics; 128 129 @safe this(DocumentUri uri = DocumentUri.init, Diagnostic[] diagnostics = Diagnostic[].init) pure nothrow 130 { 131 this.uri = uri; 132 this.diagnostics = diagnostics; 133 } 134 } 135 136 final class CompletionParams : TextDocumentPositionParams 137 { 138 import std.typecons : Nullable; 139 140 Nullable!CompletionContext context; 141 142 @safe this() pure nothrow 143 { 144 } 145 } 146 147 final class CompletionContext 148 { 149 import std.typecons : Nullable; 150 151 CompletionTriggerKind triggerKind; 152 Nullable!string triggerCharacter; 153 154 @safe this() pure nothrow 155 { 156 } 157 } 158 159 enum CompletionTriggerKind : ubyte 160 { 161 invoked = 1, 162 triggerCharacter = 2, 163 triggerForIncompleteCompletions = 3 164 } 165 166 final class CompletionList 167 { 168 bool isIncomplete; 169 CompletionItem[] items; 170 171 @safe this(bool isIncomplete = bool.init, CompletionItem[] items = CompletionItem[].init) pure nothrow 172 { 173 this.isIncomplete = isIncomplete; 174 this.items = items; 175 } 176 } 177 178 enum InsertTextFormat : ubyte 179 { 180 plainText = 1, 181 snippet = 2 182 } 183 184 final class CompletionItem 185 { 186 import std.typecons : Nullable; 187 188 string label; 189 Nullable!CompletionItemKind kind; 190 Nullable!string detail; 191 Nullable!MarkupContent documentation; 192 Nullable!bool deprecated_; 193 Nullable!bool preselect; 194 Nullable!string sortText; 195 Nullable!string filterText; 196 Nullable!string insertText; 197 Nullable!InsertTextFormat insertTextFormat; 198 Nullable!TextEdit textEdit; 199 Nullable!(TextEdit[]) additionalTextEdits; 200 Nullable!(string[]) commitCharacters; 201 Nullable!Command command; 202 Nullable!JSONValue data; 203 204 @safe this(string label = string.init, Nullable!CompletionItemKind kind = Nullable!CompletionItemKind.init, 205 Nullable!string detail = Nullable!string.init, 206 Nullable!MarkupContent documentation = Nullable!MarkupContent.init, 207 Nullable!bool deprecated_ = Nullable!bool.init, Nullable!string sortText = Nullable!string.init, 208 Nullable!string filterText = Nullable!string.init, Nullable!string insertText = Nullable!string.init, 209 Nullable!InsertTextFormat insertTextFormat = Nullable!InsertTextFormat.init, 210 Nullable!TextEdit textEdit = Nullable!TextEdit.init, 211 Nullable!(TextEdit[]) additionalTextEdits = Nullable!(TextEdit[]) 212 .init, Nullable!(string[]) commitCharacters = Nullable!(string[]) 213 .init, Nullable!Command command = Nullable!Command.init, 214 Nullable!JSONValue data = Nullable!JSONValue.init) pure nothrow 215 { 216 this.label = label; 217 this.kind = kind; 218 this.detail = detail; 219 this.documentation = documentation; 220 this.deprecated_ = deprecated_; 221 this.sortText = sortText; 222 this.filterText = filterText; 223 this.insertText = insertText; 224 this.insertTextFormat = insertTextFormat; 225 this.textEdit = textEdit; 226 this.additionalTextEdits = additionalTextEdits; 227 this.commitCharacters = commitCharacters; 228 this.command = command; 229 this.data = data; 230 } 231 } 232 233 enum CompletionItemKind : ubyte 234 { 235 text = 1, 236 method = 2, 237 function_ = 3, 238 constructor = 4, 239 field = 5, 240 variable = 6, 241 class_ = 7, 242 interface_ = 8, 243 module_ = 9, 244 property = 10, 245 unit = 11, 246 value = 12, 247 enum_ = 13, 248 keyword = 14, 249 snippet = 15, 250 color = 16, 251 file = 17, 252 reference = 18, 253 folder = 19, 254 enumMember = 20, 255 constant = 21, 256 struct_ = 22, 257 event = 23, 258 operator = 24, 259 typeParameter = 25 260 } 261 262 final class CompletionRegistrationOptions : TextDocumentRegistrationOptions 263 { 264 import std.typecons : Nullable; 265 266 Nullable!(string[]) triggerCharacters; 267 Nullable!bool resolveProvider; 268 269 @safe this(Nullable!(string[]) triggerCharacters = Nullable!(string[]) 270 .init, Nullable!bool resolveProvider = Nullable!bool.init) pure nothrow 271 { 272 this.triggerCharacters = triggerCharacters; 273 this.resolveProvider = resolveProvider; 274 } 275 } 276 277 final class Hover 278 { 279 import std.typecons : Nullable; 280 281 MarkupContent contents; 282 Nullable!Range range; 283 284 @safe this(MarkupContent contents = MarkupContent.init, 285 Nullable!Range range = Nullable!Range.init) pure nothrow 286 { 287 this.contents = contents; 288 this.range = range; 289 } 290 } 291 292 final class SignatureHelp 293 { 294 import std.typecons : Nullable; 295 296 SignatureInformation[] signatures; 297 Nullable!double activeSignature; 298 Nullable!double activeParameter; 299 300 @safe this(SignatureInformation[] signatures = SignatureInformation[].init, 301 Nullable!double activeSignature = Nullable!double.init, 302 Nullable!double activeParameter = Nullable!double.init) pure nothrow 303 { 304 this.signatures = signatures; 305 this.activeSignature = activeSignature; 306 this.activeParameter = activeParameter; 307 } 308 } 309 310 private class InformationBase 311 { 312 import std.typecons : Nullable; 313 314 string label; 315 Nullable!string documentation; 316 317 @safe this() pure nothrow 318 { 319 } 320 } 321 322 final class SignatureInformation : InformationBase 323 { 324 import std.typecons : Nullable; 325 326 Nullable!(ParameterInformation[]) parameters; 327 328 @safe this(Nullable!(ParameterInformation[]) parameters = Nullable!( 329 ParameterInformation[]).init) pure nothrow 330 { 331 this.parameters = parameters; 332 } 333 } 334 335 final class ParameterInformation : InformationBase 336 { 337 JSONValue label; 338 339 @safe this() pure nothrow 340 { 341 } 342 } 343 344 final class SignatureHelpRegistrationOptions : TextDocumentRegistrationOptions 345 { 346 import std.typecons : Nullable; 347 348 Nullable!(string[]) triggerCharacters; 349 350 @safe this(Nullable!(string[]) triggerCharacters = Nullable!(string[]).init) pure nothrow 351 { 352 this.triggerCharacters = triggerCharacters; 353 } 354 } 355 356 final class ReferenceParams : TextDocumentPositionParams 357 { 358 ReferenceContext context; 359 360 @safe this() pure nothrow 361 { 362 this.context = new ReferenceContext(); 363 } 364 } 365 366 final class ReferenceContext 367 { 368 bool includeDeclaration; 369 370 @safe this() pure nothrow 371 { 372 } 373 } 374 375 final class DocumentHighlight 376 { 377 import std.typecons : Nullable; 378 379 Range range; 380 Nullable!DocumentHighlightKind kind; 381 382 @safe this(Range range = new Range(), 383 Nullable!DocumentHighlightKind kind = Nullable!DocumentHighlightKind.init) pure nothrow 384 { 385 this.range = range; 386 this.kind = kind; 387 } 388 } 389 390 enum DocumentHighlightKind : ubyte 391 { 392 text = 1, 393 read = 2, 394 write = 3 395 } 396 397 alias DocumentSymbolParams = ParamsBase; 398 399 final class DocumentSymbol 400 { 401 import std.typecons : Nullable; 402 403 string name; 404 Nullable!string detail; 405 SymbolKind kind; 406 Nullable!bool deprecated_; 407 Range range; 408 Range selectionRange; 409 Nullable!(DocumentSymbol[]) children; 410 411 @safe this(string name = string.init, Nullable!string detail = Nullable!string.init, 412 SymbolKind kind = SymbolKind.init, Nullable!bool deprecated_ = Nullable!bool.init, 413 Range range = new Range(), Range selectionRange = new Range(), 414 Nullable!(DocumentSymbol[]) children = Nullable!(DocumentSymbol[]).init) pure nothrow 415 { 416 this.name = name; 417 this.detail = detail; 418 this.kind = kind; 419 this.deprecated_ = deprecated_; 420 this.range = range; 421 this.selectionRange = selectionRange; 422 this.children = children; 423 } 424 } 425 426 final class SymbolInformation 427 { 428 import std.typecons : Nullable; 429 430 string name; 431 SymbolKind kind; 432 Location location; 433 Nullable!string containerName; 434 435 @safe this(string name = string.init, SymbolKind kind = SymbolKind.init, 436 Location location = new Location(), 437 Nullable!string containerName = Nullable!string.init) pure nothrow 438 { 439 this.name = name; 440 this.kind = kind; 441 this.location = location; 442 this.containerName = containerName; 443 } 444 } 445 446 enum SymbolKind : ubyte 447 { 448 file = 1, 449 module_ = 2, 450 namespace = 3, 451 package_ = 4, 452 class_ = 5, 453 method = 6, 454 property = 7, 455 field = 8, 456 constructor = 9, 457 enum_ = 10, 458 interface_ = 11, 459 function_ = 12, 460 variable = 13, 461 constant = 14, 462 string_ = 15, 463 number = 16, 464 boolean = 17, 465 array = 18, 466 object = 19, 467 key = 20, 468 null_ = 21, 469 enumMember = 22, 470 struct_ = 23, 471 event = 24, 472 operator = 25, 473 typeParameter = 26 474 } 475 476 final class CodeActionParams : ParamsBase 477 { 478 Range range; 479 CodeActionContext context; 480 481 @safe this() pure nothrow 482 { 483 this.range = new Range(); 484 this.context = new CodeActionContext(); 485 } 486 } 487 488 enum CodeActionKind : string 489 { 490 quickfix = "quickfix", 491 refactor = "refactor", 492 refactorExtract = "refactor.extract", 493 refactorInline = "refactor.inline", 494 source = "source", 495 sourceOrganizeImports = "source.organizeImports" 496 } 497 498 final class CodeActionContext 499 { 500 import std.typecons : Nullable; 501 502 Diagnostic[] diagnostics; 503 Nullable!(CodeActionKind[]) only; 504 505 @safe this() pure nothrow 506 { 507 } 508 } 509 510 final class CodeAction 511 { 512 import std.typecons : Nullable; 513 514 string title; 515 Nullable!CodeActionKind kind; 516 Nullable!(Diagnostic[]) diagnostics; 517 Nullable!WorkspaceEdit edit; 518 Nullable!Command command; 519 520 @safe this(string title = string.init, Nullable!CodeActionKind kind = Nullable!CodeActionKind.init, 521 Nullable!(Diagnostic[]) diagnostics = Nullable!(Diagnostic[]).init, 522 Nullable!WorkspaceEdit edit = Nullable!WorkspaceEdit.init, 523 Nullable!Command command = Nullable!Command.init) pure nothrow 524 { 525 this.title = title; 526 this.kind = kind; 527 this.diagnostics = diagnostics; 528 this.edit = edit; 529 this.command = command; 530 } 531 } 532 533 alias CodeActionRegistrationOptions = JSONValue; 534 535 alias CodeLensParams = ParamsBase; 536 537 final class CodeLens 538 { 539 import std.typecons : Nullable; 540 541 Range range; 542 Nullable!Command command; 543 Nullable!JSONValue data; 544 545 @safe this(Range range = new Range(), Nullable!Command command = Nullable!Command.init, 546 Nullable!JSONValue data = Nullable!JSONValue.init) pure nothrow 547 { 548 this.range = range; 549 this.command = command; 550 this.data = data; 551 } 552 } 553 554 final class CodeLensRegistrationOptions : TextDocumentRegistrationOptions 555 { 556 import std.typecons : Nullable; 557 558 Nullable!bool resolveProvider; 559 560 @safe this(Nullable!bool resolveProvider = Nullable!bool.init) pure nothrow 561 { 562 this.resolveProvider = resolveProvider; 563 } 564 } 565 566 alias DocumentLinkParams = ParamsBase; 567 568 final class DocumentLink 569 { 570 import std.typecons : Nullable; 571 572 Range range; 573 Nullable!DocumentUri target; 574 575 @safe this(Range range = new Range(), Nullable!DocumentUri target = Nullable!DocumentUri.init) pure nothrow 576 { 577 this.range = range; 578 this.target = target; 579 } 580 } 581 582 final class DocumentLinkRegistrationOptions : TextDocumentRegistrationOptions 583 { 584 import std.typecons : Nullable; 585 586 Nullable!bool resolveProvider; 587 588 @safe this(Nullable!bool resolveProvider = Nullable!bool.init) pure nothrow 589 { 590 this.resolveProvider = resolveProvider; 591 } 592 } 593 594 alias DocumentColorParams = ParamsBase; 595 596 final class ColorInformation 597 { 598 Range range; 599 Color color; 600 601 @safe this(Range range = new Range(), Color color = new Color()) pure nothrow 602 { 603 this.range = range; 604 this.color = color; 605 } 606 } 607 608 final class Color 609 { 610 float red; 611 float green; 612 float blue; 613 float alpha; 614 615 @safe this(float red = 0, float green = 0, float blue = 0, float alpha = 0) pure nothrow 616 { 617 this.red = red; 618 this.green = green; 619 this.blue = blue; 620 this.alpha = alpha; 621 } 622 } 623 624 final class ColorPresentationParams : ParamsBase 625 { 626 Color color; 627 Range range; 628 629 @safe this() pure nothrow 630 { 631 this.color = new Color(); 632 this.range = new Range(); 633 } 634 } 635 636 final class ColorPresentation 637 { 638 import std.typecons : Nullable; 639 640 string label; 641 Nullable!TextEdit textEdit; 642 Nullable!(TextEdit[]) additionalTextEdits; 643 644 @safe this(string label = string.init, Nullable!TextEdit textEdit = Nullable!TextEdit.init, 645 Nullable!(TextEdit[]) additionalTextEdits = Nullable!(TextEdit[]).init) pure nothrow 646 { 647 this.label = label; 648 this.textEdit = textEdit; 649 this.additionalTextEdits = additionalTextEdits; 650 } 651 } 652 653 class DocumentFormattingParams : ParamsBase 654 { 655 FormattingOptions options; 656 657 @safe this() pure nothrow 658 { 659 this.options = new FormattingOptions(); 660 } 661 } 662 663 final class FormattingOptions 664 { 665 size_t tabSize; 666 bool insertSpaces; 667 668 @safe this() pure nothrow 669 { 670 } 671 } 672 673 final class DocumentRangeFormattingParams : DocumentFormattingParams 674 { 675 Range range; 676 677 @safe this() pure nothrow 678 { 679 this.range = new Range(); 680 } 681 } 682 683 final class DocumentOnTypeFormattingParams : DocumentFormattingParams 684 { 685 Position position; 686 string ch; 687 688 @safe this() pure nothrow 689 { 690 this.position = new Position(); 691 } 692 } 693 694 final class DocumentOnTypeFormattingRegistrationOptions : TextDocumentRegistrationOptions 695 { 696 import std.typecons : Nullable; 697 698 string firstTriggerCharacter; 699 Nullable!(string[]) moreTriggerCharacter; 700 701 @safe this(string firstTriggerCharacter = string.init, 702 Nullable!(string[]) moreTriggerCharacter = Nullable!(string[]).init) pure nothrow 703 { 704 this.firstTriggerCharacter = firstTriggerCharacter; 705 this.moreTriggerCharacter = moreTriggerCharacter; 706 } 707 } 708 709 final class RenameParams : ParamsBase 710 { 711 Position position; 712 string newName; 713 714 @safe this() pure nothrow 715 { 716 this.position = new Position(); 717 } 718 } 719 720 final class RenameRegistrationOptions : TextDocumentRegistrationOptions 721 { 722 import std.typecons : Nullable; 723 724 Nullable!bool prepareProvider; 725 726 @safe this() pure nothrow 727 { 728 } 729 } 730 731 alias FoldingRangeParams = ParamsBase; 732 733 enum FoldingRangeKind : string 734 { 735 comments = "comments", 736 imports = "imports", 737 region = "region" 738 } 739 740 final class FoldingRange 741 { 742 import std.typecons : Nullable; 743 744 size_t startLine; 745 Nullable!size_t startCharacter; 746 size_t endLine; 747 Nullable!size_t endCharacter; 748 Nullable!FoldingRangeKind kind; 749 750 @safe this() pure nothrow 751 { 752 } 753 }