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