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 std.typecons : 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 std.typecons : 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 std.typecons : 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 std.typecons : 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 std.typecons : 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 211 @safe this() pure nothrow 212 { 213 } 214 } 215 216 static final class CompletionItemKind 217 { 218 import dls.protocol.interfaces.text_document : CompletionItemKind; 219 220 Nullable!(CompletionItemKind[]) valueSet; 221 222 @safe this() pure nothrow 223 { 224 } 225 } 226 227 Nullable!CompletionItem completionItem; 228 Nullable!CompletionItemKind completionItemKind; 229 Nullable!bool contextSupport; 230 231 @safe this() pure nothrow 232 { 233 } 234 } 235 236 static final class Hover : WithDynamicRegistration 237 { 238 import dls.protocol.definitions : MarkupKind; 239 240 Nullable!(MarkupKind[]) contentFormat; 241 242 @safe this() pure nothrow 243 { 244 } 245 } 246 247 static final class SignatureHelp : WithDynamicRegistration 248 { 249 static final class SignatureInformation 250 { 251 import dls.protocol.definitions : MarkupKind; 252 253 static final class ParameterInformation 254 { 255 Nullable!bool labelOffsetSupport; 256 257 @safe this() pure nothrow 258 { 259 } 260 } 261 262 Nullable!(MarkupKind[]) documentationFormat; 263 Nullable!ParameterInformation parameterInformation; 264 265 @safe this() pure nothrow 266 { 267 } 268 } 269 270 Nullable!SignatureInformation signatureInformation; 271 272 @safe this() pure nothrow 273 { 274 } 275 } 276 277 static final class DocumentSymbol : WithDynamicRegistration 278 { 279 static final class SymbolKind 280 { 281 import dls.protocol.interfaces.text_document : SymbolKind; 282 283 Nullable!(SymbolKind[]) valueSet; 284 285 @safe this() pure nothrow 286 { 287 } 288 } 289 290 Nullable!SymbolKind symbolKind; 291 Nullable!bool hierarchicalDocumentSymbolSupport; 292 293 @safe this() pure nothrow 294 { 295 } 296 } 297 298 static final class CodeAction : WithDynamicRegistration 299 { 300 static final class CodeActionLiteralSupport 301 { 302 static final class CodeActionKind 303 { 304 import dls.protocol.interfaces.text_document : CodeActionKind; 305 306 CodeActionKind[] valueSet; 307 308 @safe this() pure nothrow 309 { 310 } 311 } 312 313 CodeActionKind codeActionKind; 314 315 @safe this() pure nothrow 316 { 317 this.codeActionKind = new CodeActionKind(); 318 } 319 } 320 321 Nullable!CodeActionLiteralSupport codeActionLiteralSupport; 322 323 @safe this() pure nothrow 324 { 325 } 326 } 327 328 static final class Rename : WithDynamicRegistration 329 { 330 Nullable!bool prepareSupport; 331 332 @safe this() pure nothrow 333 { 334 } 335 } 336 337 static final class PublishDiagnostics 338 { 339 Nullable!bool relatedInformation; 340 341 @safe this() pure nothrow 342 { 343 } 344 } 345 346 static final class FoldingRange : WithDynamicRegistration 347 { 348 Nullable!size_t rangeLimit; 349 Nullable!bool lineFoldingOnly; 350 351 @safe this() pure nothrow 352 { 353 } 354 } 355 356 Nullable!Synchronisation synchronisation; 357 Nullable!Completion completion; 358 Nullable!Hover hover; 359 Nullable!SignatureHelp signatureHelp; 360 Nullable!WithDynamicRegistration references; 361 Nullable!WithDynamicRegistration documentHighlight; 362 Nullable!DocumentSymbol documentSymbol; 363 Nullable!WithDynamicRegistration formatting; 364 Nullable!WithDynamicRegistration rangeFormatting; 365 Nullable!WithDynamicRegistration onTypeFormatting; 366 Nullable!WithLinkSupport declaration; 367 Nullable!WithLinkSupport definition; 368 Nullable!WithLinkSupport typeDefinition; 369 Nullable!WithLinkSupport implementation; 370 Nullable!CodeAction codeAction; 371 Nullable!WithDynamicRegistration codeLens; 372 Nullable!WithDynamicRegistration documentLink; 373 Nullable!WithDynamicRegistration colorProvider; 374 Nullable!Rename rename; 375 Nullable!PublishDiagnostics publishDiagnostics; 376 Nullable!FoldingRange foldingRange; 377 378 @safe this() pure nothrow 379 { 380 } 381 } 382 383 final class ClientCapabilities 384 { 385 import std.json : JSONValue; 386 import std.typecons : Nullable; 387 388 Nullable!WorkspaceClientCapabilities workspace; 389 Nullable!TextDocumentClientCapabilities textDocument; 390 Nullable!JSONValue experimental; 391 392 @safe this() pure nothrow 393 { 394 } 395 } 396 397 final class InitializeResult 398 { 399 ServerCapabilities capabilities; 400 401 @safe this(ServerCapabilities capabilities = new ServerCapabilities()) pure nothrow 402 { 403 this.capabilities = capabilities; 404 } 405 } 406 407 final class InitializeErrorData 408 { 409 bool retry; 410 411 @safe this() pure nothrow 412 { 413 } 414 } 415 416 enum TextDocumentSyncKind : ubyte 417 { 418 none = 0, 419 full = 1, 420 incremental = 2 421 } 422 423 private class OptionsBase 424 { 425 import std.typecons : Nullable; 426 427 Nullable!bool resolveProvider; 428 429 @safe this(Nullable!bool resolveProvider = Nullable!bool.init) pure nothrow 430 { 431 this.resolveProvider = resolveProvider; 432 } 433 } 434 435 final class CompletionOptions : OptionsBase 436 { 437 import std.typecons : Nullable; 438 439 Nullable!(string[]) triggerCharacters; 440 441 @safe this(Nullable!bool resolveProvider = Nullable!bool.init, 442 Nullable!(string[]) triggerCharacters = Nullable!(string[]).init) pure nothrow 443 { 444 super(resolveProvider); 445 this.triggerCharacters = triggerCharacters; 446 } 447 } 448 449 final class SignatureHelpOptions 450 { 451 import std.typecons : Nullable; 452 453 Nullable!(string[]) triggerCharacters; 454 455 @safe this(Nullable!(string[]) triggerCharacters = Nullable!(string[]).init) pure nothrow 456 { 457 this.triggerCharacters = triggerCharacters; 458 } 459 } 460 461 final class CodeActionOptions 462 { 463 import dls.protocol.interfaces.text_document : CodeActionKind; 464 import std.typecons : Nullable; 465 466 Nullable!(CodeActionKind[]) codeActionKinds; 467 468 @safe this(Nullable!(CodeActionKind[]) codeActionKinds = Nullable!(CodeActionKind[]).init) pure nothrow 469 { 470 this.codeActionKinds = codeActionKinds; 471 } 472 } 473 474 alias CodeLensOptions = OptionsBase; 475 476 final class DocumentOnTypeFormattingOptions 477 { 478 import std.typecons : Nullable; 479 480 string firstTriggerCharacter; 481 Nullable!(string[]) moreTriggerCharacter; 482 483 @safe this(string firstTriggerCharacter = string.init, 484 Nullable!(string[]) moreTriggerCharacter = Nullable!(string[]).init) pure nothrow 485 { 486 this.firstTriggerCharacter = firstTriggerCharacter; 487 this.moreTriggerCharacter = moreTriggerCharacter; 488 } 489 } 490 491 final class RenameOptions 492 { 493 import std.typecons : Nullable; 494 495 Nullable!bool prepareProvider; 496 497 @safe this(Nullable!bool prepareProvider = Nullable!bool.init) pure nothrow 498 { 499 this.prepareProvider = prepareProvider; 500 } 501 } 502 503 alias DocumentLinkOptions = OptionsBase; 504 505 final class ExecuteCommandOptions 506 { 507 string[] commands; 508 509 @safe this(string[] commands = string[].init) pure nothrow 510 { 511 this.commands = commands; 512 } 513 } 514 515 final class SaveOptions 516 { 517 import std.typecons : Nullable; 518 519 Nullable!bool includeText; 520 521 @safe this(Nullable!bool includeText = Nullable!bool.init) pure nothrow 522 { 523 this.includeText = includeText; 524 } 525 } 526 527 final class ColorProviderOptions 528 { 529 @safe this() pure nothrow 530 { 531 } 532 } 533 534 final class FoldingRangeProviderOptions 535 { 536 @safe this() pure nothrow 537 { 538 } 539 } 540 541 final class TextDocumentSyncOptions 542 { 543 import std.typecons : Nullable; 544 545 Nullable!bool openClose; 546 Nullable!TextDocumentSyncKind change; 547 Nullable!bool willSave; 548 Nullable!bool willSaveWaitUntil; 549 Nullable!SaveOptions save; 550 551 @safe this(Nullable!bool openClose = Nullable!bool.init, 552 Nullable!TextDocumentSyncKind change = Nullable!TextDocumentSyncKind.init, 553 Nullable!bool willSave = Nullable!bool.init, Nullable!bool willSaveWaitUntil = Nullable!bool.init, 554 Nullable!SaveOptions save = Nullable!SaveOptions.init) pure nothrow 555 { 556 this.openClose = openClose; 557 this.change = change; 558 this.willSave = willSave; 559 this.willSaveWaitUntil = willSaveWaitUntil; 560 this.save = save; 561 } 562 } 563 564 final class StaticRegistrationOptions 565 { 566 import std.typecons : Nullable; 567 568 Nullable!string id; 569 570 @safe this(Nullable!string id = Nullable!string.init) pure nothrow 571 { 572 this.id = id; 573 } 574 } 575 576 final class ServerCapabilities 577 { 578 import std.json : JSONValue; 579 import std.typecons : Nullable; 580 581 static final class Workspace 582 { 583 static final class WorkspaceFolders 584 { 585 Nullable!bool supported; 586 Nullable!JSONValue changeNotifications; 587 588 @safe this(Nullable!bool supported = Nullable!bool.init, 589 Nullable!JSONValue changeNotifications = Nullable!JSONValue.init) pure nothrow 590 { 591 this.supported = supported; 592 this.changeNotifications = changeNotifications; 593 } 594 } 595 596 Nullable!WorkspaceFolders workspaceFolders; 597 598 @safe this(Nullable!WorkspaceFolders workspaceFolders = Nullable!WorkspaceFolders.init) pure nothrow 599 { 600 this.workspaceFolders = workspaceFolders; 601 } 602 } 603 604 Nullable!TextDocumentSyncOptions textDocumentSync; // TODO: add TextDocumentSyncKind compatibility 605 Nullable!bool hoverProvider; 606 Nullable!CompletionOptions completionProvider; 607 Nullable!SignatureHelpOptions signatureHelpProvider; 608 Nullable!bool definitionProvider; 609 Nullable!JSONValue typeDefinitionProvider; 610 Nullable!JSONValue implementationProvider; 611 Nullable!bool referencesProvider; 612 Nullable!bool documentHighlightProvider; 613 Nullable!bool documentSymbolProvider; 614 Nullable!bool workspaceSymbolProvider; 615 Nullable!JSONValue codeActionProvider; 616 Nullable!CodeLensOptions codeLensProvider; 617 Nullable!bool documentFormattingProvider; 618 Nullable!bool documentRangeFormattingProvider; 619 Nullable!DocumentOnTypeFormattingOptions documentOnTypeFormattingProvider; 620 Nullable!JSONValue renameProvider; 621 Nullable!DocumentLinkOptions documentLinkProvider; 622 Nullable!JSONValue colorProvider; 623 Nullable!JSONValue foldingRangeProvider; 624 Nullable!ExecuteCommandOptions executeCommandProvider; 625 Nullable!Workspace workspace; 626 Nullable!JSONValue experimental; 627 628 @safe this() pure nothrow 629 { 630 } 631 } 632 633 final class CancelParams 634 { 635 import std.json : JSONValue; 636 637 JSONValue id; 638 639 @safe this() pure nothrow 640 { 641 } 642 }