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.general; 22 23 private class WithDynamicRegistration 24 { 25 import dls.util.nullable: Nullable; 26 27 Nullable!bool dynamicRegistration; 28 29 @safe this() pure nothrow 30 { 31 } 32 } 33 34 private final class WithLinkSupport : WithDynamicRegistration 35 { 36 import dls.util.nullable: Nullable; 37 38 Nullable!bool linkSupport; 39 40 @safe this() pure nothrow 41 { 42 } 43 } 44 45 final class InitializeParams 46 { 47 import dls.protocol.definitions : DocumentUri; 48 import dls.protocol.interfaces.workspace : WorkspaceFolder; 49 import std.json : JSONValue; 50 import dls.util.nullable: Nullable; 51 52 static enum Trace : string 53 { 54 off = "off", 55 messages = "messages", 56 verbose = "verbose" 57 } 58 59 static final class InitializationOptions 60 { 61 static final class Capabilities 62 { 63 bool hover = true; 64 bool completion = true; 65 bool definition = true; 66 bool typeDefinition = true; 67 bool references = true; 68 bool documentHighlight = true; 69 bool documentSymbol = true; 70 bool workspaceSymbol = true; 71 bool codeAction = true; 72 bool documentFormatting = true; 73 bool documentRangeFormatting = true; 74 bool documentOnTypeFormatting = true; 75 bool rename = true; 76 77 @safe this() pure nothrow 78 { 79 } 80 } 81 82 static final class Symbol 83 { 84 bool autoImports = true; 85 86 @safe this() pure nothrow 87 { 88 } 89 } 90 91 bool autoUpdate = true; 92 bool preReleaseBuilds = false; 93 bool safeMode = false; 94 bool catchErrors = false; 95 string logFile = ""; 96 Capabilities capabilities; 97 Symbol symbol; 98 99 @safe this() pure nothrow 100 { 101 this.capabilities = new Capabilities(); 102 this.symbol = new Symbol(); 103 } 104 } 105 106 JSONValue processId; 107 Nullable!string rootPath; 108 Nullable!DocumentUri rootUri; 109 Nullable!InitializationOptions initializationOptions; 110 ClientCapabilities capabilities; 111 Nullable!Trace trace; 112 Nullable!(WorkspaceFolder[]) workspaceFolders; 113 114 @safe this() pure nothrow 115 { 116 this.capabilities = new ClientCapabilities(); 117 } 118 } 119 120 enum ResourceOperationKind : string 121 { 122 create = "create", 123 rename = "rename", 124 delete_ = "delete" 125 } 126 127 enum FailureHandlingKind : string 128 { 129 abort = "abort", 130 transactional = "transactional", 131 textOnlyTransactional = "textOnlyTransactional", 132 undo = "undo" 133 } 134 135 final class WorkspaceClientCapabilities 136 { 137 import dls.util.nullable: Nullable; 138 139 static final class WorkspaceEdit 140 { 141 Nullable!bool documentChanges; 142 Nullable!(ResourceOperationKind[]) resourceOperations; 143 Nullable!FailureHandlingKind failureHandling; 144 145 @safe this() pure nothrow 146 { 147 } 148 } 149 150 static final class Symbol : WithDynamicRegistration 151 { 152 static final class SymbolKind 153 { 154 import dls.protocol.interfaces.text_document : SymbolKind; 155 156 Nullable!(SymbolKind[]) valueSet; 157 158 @safe this() pure nothrow 159 { 160 } 161 } 162 163 Nullable!SymbolKind symbolKind; 164 165 @safe this() pure nothrow 166 { 167 } 168 } 169 170 Nullable!bool applyEdit; 171 Nullable!WorkspaceEdit workspaceEdit; 172 Nullable!WithDynamicRegistration didChangeConfiguration; 173 Nullable!WithDynamicRegistration didChangeWatchedFiles; 174 Nullable!Symbol symbol; 175 Nullable!WithDynamicRegistration executeCommand; 176 Nullable!bool workspaceFolders; 177 Nullable!bool configuration; 178 179 @safe this() pure nothrow 180 { 181 } 182 } 183 184 final class TextDocumentClientCapabilities 185 { 186 import dls.util.nullable: Nullable; 187 188 static final class Synchronisation : WithDynamicRegistration 189 { 190 Nullable!bool willSave; 191 Nullable!bool willSaveWaitUntil; 192 Nullable!bool didSave; 193 194 @safe this() pure nothrow 195 { 196 } 197 } 198 199 static final class Completion : WithDynamicRegistration 200 { 201 static final class CompletionItem 202 { 203 import dls.protocol.definitions : MarkupKind; 204 205 Nullable!bool snippetSupport; 206 Nullable!bool commitCharactersSupport; 207 Nullable!(MarkupKind[]) documentationFormat; 208 Nullable!bool deprecatedSupport; 209 Nullable!bool preselectSupport; 210 Nullable!bool labelDetailsSupport; 211 212 @safe this() pure nothrow 213 { 214 } 215 } 216 217 static final class CompletionItemKind 218 { 219 import dls.protocol.interfaces.text_document : CompletionItemKind; 220 221 Nullable!(CompletionItemKind[]) valueSet; 222 223 @safe this() pure nothrow 224 { 225 } 226 } 227 228 Nullable!CompletionItem completionItem; 229 Nullable!CompletionItemKind completionItemKind; 230 Nullable!bool contextSupport; 231 232 @safe this() pure nothrow 233 { 234 } 235 } 236 237 static final class Hover : WithDynamicRegistration 238 { 239 import dls.protocol.definitions : MarkupKind; 240 241 Nullable!(MarkupKind[]) contentFormat; 242 243 @safe this() pure nothrow 244 { 245 } 246 } 247 248 static final class SignatureHelp : WithDynamicRegistration 249 { 250 static final class SignatureInformation 251 { 252 import dls.protocol.definitions : MarkupKind; 253 254 static final class ParameterInformation 255 { 256 Nullable!bool labelOffsetSupport; 257 258 @safe this() pure nothrow 259 { 260 } 261 } 262 263 Nullable!(MarkupKind[]) documentationFormat; 264 Nullable!ParameterInformation parameterInformation; 265 266 @safe this() pure nothrow 267 { 268 } 269 } 270 271 Nullable!SignatureInformation signatureInformation; 272 273 @safe this() pure nothrow 274 { 275 } 276 } 277 278 static final class DocumentSymbol : WithDynamicRegistration 279 { 280 static final class SymbolKind 281 { 282 import dls.protocol.interfaces.text_document : SymbolKind; 283 284 Nullable!(SymbolKind[]) valueSet; 285 286 @safe this() pure nothrow 287 { 288 } 289 } 290 291 Nullable!SymbolKind symbolKind; 292 Nullable!bool hierarchicalDocumentSymbolSupport; 293 294 @safe this() pure nothrow 295 { 296 } 297 } 298 299 static final class CodeAction : WithDynamicRegistration 300 { 301 static final class CodeActionLiteralSupport 302 { 303 static final class CodeActionKind 304 { 305 import dls.protocol.interfaces.text_document : CodeActionKind; 306 307 CodeActionKind[] valueSet; 308 309 @safe this() pure nothrow 310 { 311 } 312 } 313 314 CodeActionKind codeActionKind; 315 316 @safe this() pure nothrow 317 { 318 this.codeActionKind = new CodeActionKind(); 319 } 320 } 321 322 Nullable!CodeActionLiteralSupport codeActionLiteralSupport; 323 324 @safe this() pure nothrow 325 { 326 } 327 } 328 329 static final class Rename : WithDynamicRegistration 330 { 331 Nullable!bool prepareSupport; 332 333 @safe this() pure nothrow 334 { 335 } 336 } 337 338 static final class PublishDiagnostics 339 { 340 Nullable!bool relatedInformation; 341 342 @safe this() pure nothrow 343 { 344 } 345 } 346 347 static final class FoldingRange : WithDynamicRegistration 348 { 349 Nullable!size_t rangeLimit; 350 Nullable!bool lineFoldingOnly; 351 352 @safe this() pure nothrow 353 { 354 } 355 } 356 357 Nullable!Synchronisation synchronisation; 358 Nullable!Completion completion; 359 Nullable!Hover hover; 360 Nullable!SignatureHelp signatureHelp; 361 Nullable!WithDynamicRegistration references; 362 Nullable!WithDynamicRegistration documentHighlight; 363 Nullable!DocumentSymbol documentSymbol; 364 Nullable!WithDynamicRegistration formatting; 365 Nullable!WithDynamicRegistration rangeFormatting; 366 Nullable!WithDynamicRegistration onTypeFormatting; 367 Nullable!WithLinkSupport declaration; 368 Nullable!WithLinkSupport definition; 369 Nullable!WithLinkSupport typeDefinition; 370 Nullable!WithLinkSupport implementation; 371 Nullable!CodeAction codeAction; 372 Nullable!WithDynamicRegistration codeLens; 373 Nullable!WithDynamicRegistration documentLink; 374 Nullable!WithDynamicRegistration colorProvider; 375 Nullable!Rename rename; 376 Nullable!PublishDiagnostics publishDiagnostics; 377 Nullable!FoldingRange foldingRange; 378 379 @safe this() pure nothrow 380 { 381 } 382 } 383 384 final class ClientCapabilities 385 { 386 import std.json : JSONValue; 387 import dls.util.nullable: Nullable; 388 389 Nullable!WorkspaceClientCapabilities workspace; 390 Nullable!TextDocumentClientCapabilities textDocument; 391 Nullable!JSONValue experimental; 392 393 @safe this() pure nothrow 394 { 395 } 396 } 397 398 final class InitializeResult 399 { 400 ServerCapabilities capabilities; 401 402 @safe this(ServerCapabilities capabilities = new ServerCapabilities()) pure nothrow 403 { 404 this.capabilities = capabilities; 405 } 406 } 407 408 final class InitializeErrorData 409 { 410 bool retry; 411 412 @safe this() pure nothrow 413 { 414 } 415 } 416 417 enum TextDocumentSyncKind : ubyte 418 { 419 none = 0, 420 full = 1, 421 incremental = 2 422 } 423 424 private class OptionsBase 425 { 426 import dls.util.nullable: Nullable; 427 428 Nullable!bool resolveProvider; 429 430 @safe this(Nullable!bool resolveProvider = Nullable!bool.init) pure nothrow 431 { 432 this.resolveProvider = resolveProvider; 433 } 434 } 435 436 final class CompletionOptions : OptionsBase 437 { 438 import dls.util.nullable: Nullable; 439 440 Nullable!(string[]) triggerCharacters; 441 442 @safe this(Nullable!bool resolveProvider = Nullable!bool.init, 443 Nullable!(string[]) triggerCharacters = Nullable!(string[]).init) pure nothrow 444 { 445 super(resolveProvider); 446 this.triggerCharacters = triggerCharacters; 447 } 448 } 449 450 final class SignatureHelpOptions 451 { 452 import dls.util.nullable: Nullable; 453 454 Nullable!(string[]) triggerCharacters; 455 456 @safe this(Nullable!(string[]) triggerCharacters = Nullable!(string[]).init) pure nothrow 457 { 458 this.triggerCharacters = triggerCharacters; 459 } 460 } 461 462 final class CodeActionOptions 463 { 464 import dls.protocol.interfaces.text_document : CodeActionKind; 465 import dls.util.nullable: Nullable; 466 467 Nullable!(CodeActionKind[]) codeActionKinds; 468 469 @safe this(Nullable!(CodeActionKind[]) codeActionKinds = Nullable!(CodeActionKind[]).init) pure nothrow 470 { 471 this.codeActionKinds = codeActionKinds; 472 } 473 } 474 475 alias CodeLensOptions = OptionsBase; 476 477 final class DocumentOnTypeFormattingOptions 478 { 479 import dls.util.nullable: Nullable; 480 481 string firstTriggerCharacter; 482 Nullable!(string[]) moreTriggerCharacter; 483 484 @safe this(string firstTriggerCharacter = string.init, 485 Nullable!(string[]) moreTriggerCharacter = Nullable!(string[]).init) pure nothrow 486 { 487 this.firstTriggerCharacter = firstTriggerCharacter; 488 this.moreTriggerCharacter = moreTriggerCharacter; 489 } 490 } 491 492 final class RenameOptions 493 { 494 import dls.util.nullable: Nullable; 495 496 Nullable!bool prepareProvider; 497 498 @safe this(Nullable!bool prepareProvider = Nullable!bool.init) pure nothrow 499 { 500 this.prepareProvider = prepareProvider; 501 } 502 } 503 504 alias DocumentLinkOptions = OptionsBase; 505 506 final class ExecuteCommandOptions 507 { 508 string[] commands; 509 510 @safe this(string[] commands = string[].init) pure nothrow 511 { 512 this.commands = commands; 513 } 514 } 515 516 final class SaveOptions 517 { 518 import dls.util.nullable: Nullable; 519 520 Nullable!bool includeText; 521 522 @safe this(Nullable!bool includeText = Nullable!bool.init) pure nothrow 523 { 524 this.includeText = includeText; 525 } 526 } 527 528 final class ColorProviderOptions 529 { 530 @safe this() pure nothrow 531 { 532 } 533 } 534 535 final class FoldingRangeProviderOptions 536 { 537 @safe this() pure nothrow 538 { 539 } 540 } 541 542 final class TextDocumentSyncOptions 543 { 544 import dls.util.nullable: Nullable; 545 546 Nullable!bool openClose; 547 Nullable!TextDocumentSyncKind change; 548 Nullable!bool willSave; 549 Nullable!bool willSaveWaitUntil; 550 Nullable!SaveOptions save; 551 552 @safe this(Nullable!bool openClose = Nullable!bool.init, 553 Nullable!TextDocumentSyncKind change = Nullable!TextDocumentSyncKind.init, 554 Nullable!bool willSave = Nullable!bool.init, Nullable!bool willSaveWaitUntil = Nullable!bool.init, 555 Nullable!SaveOptions save = Nullable!SaveOptions.init) pure nothrow 556 { 557 this.openClose = openClose; 558 this.change = change; 559 this.willSave = willSave; 560 this.willSaveWaitUntil = willSaveWaitUntil; 561 this.save = save; 562 } 563 } 564 565 final class StaticRegistrationOptions 566 { 567 import dls.util.nullable: Nullable; 568 569 Nullable!string id; 570 571 @safe this(Nullable!string id = Nullable!string.init) pure nothrow 572 { 573 this.id = id; 574 } 575 } 576 577 final class ServerCapabilities 578 { 579 import std.json : JSONValue; 580 import dls.util.nullable: Nullable; 581 582 static final class Workspace 583 { 584 static final class WorkspaceFolders 585 { 586 Nullable!bool supported; 587 Nullable!JSONValue changeNotifications; 588 589 @safe this(Nullable!bool supported = Nullable!bool.init, 590 Nullable!JSONValue changeNotifications = Nullable!JSONValue.init) pure nothrow 591 { 592 this.supported = supported; 593 this.changeNotifications = changeNotifications; 594 } 595 } 596 597 Nullable!WorkspaceFolders workspaceFolders; 598 599 @safe this(Nullable!WorkspaceFolders workspaceFolders = Nullable!WorkspaceFolders.init) pure nothrow 600 { 601 this.workspaceFolders = workspaceFolders; 602 } 603 } 604 605 Nullable!TextDocumentSyncOptions textDocumentSync; // TODO: add TextDocumentSyncKind compatibility 606 Nullable!bool hoverProvider; 607 Nullable!CompletionOptions completionProvider; 608 Nullable!SignatureHelpOptions signatureHelpProvider; 609 Nullable!bool definitionProvider; 610 Nullable!JSONValue typeDefinitionProvider; 611 Nullable!JSONValue implementationProvider; 612 Nullable!bool referencesProvider; 613 Nullable!bool documentHighlightProvider; 614 Nullable!bool documentSymbolProvider; 615 Nullable!bool workspaceSymbolProvider; 616 Nullable!JSONValue codeActionProvider; 617 Nullable!CodeLensOptions codeLensProvider; 618 Nullable!bool documentFormattingProvider; 619 Nullable!bool documentRangeFormattingProvider; 620 Nullable!DocumentOnTypeFormattingOptions documentOnTypeFormattingProvider; 621 Nullable!JSONValue renameProvider; 622 Nullable!DocumentLinkOptions documentLinkProvider; 623 Nullable!JSONValue colorProvider; 624 Nullable!JSONValue foldingRangeProvider; 625 Nullable!ExecuteCommandOptions executeCommandProvider; 626 Nullable!Workspace workspace; 627 Nullable!JSONValue experimental; 628 629 @safe this() pure nothrow 630 { 631 } 632 } 633 634 final class CancelParams 635 { 636 import std.json : JSONValue; 637 638 JSONValue id; 639 640 @safe this() pure nothrow 641 { 642 } 643 }