0f699093d341c9d73c94ef2f84b0a1d9e44072d5
[roobuilder] / src / Lsp.vala
1 /* protocol.vala
2  *
3  * Copyright 2017-2019 Ben Iofel <ben@iofel.me>
4  * Copyright 2017-2020 Princeton Ferro <princetonferro@gmail.com>
5  * Copyright 2020 Sergii Fesenko <s.fesenko@outlook.com>
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation, either version 2.1 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 namespace Lsp {
22     /**
23      * Defines how the host (editor) should sync document changes to the language server.
24      */
25     [CCode (default_value = "LSP_TEXT_DOCUMENT_SYNC_KIND_Unset")]
26     public enum TextDocumentSyncKind {
27         Unset = -1,
28         /**
29          * Documents should not be synced at all.
30          */
31         None = 0,
32         /**
33          * Documents are synced by always sending the full content of the document.
34          */
35         Full = 1,
36         /**
37          * Documents are synced by sending the full content on open. After that only incremental
38          * updates to the document are sent.
39          */
40         Incremental = 2
41     }
42
43     public  enum DiagnosticSeverity {
44         Unset = 0,
45         /**
46          * Reports an error.
47          */
48         Error = 1,
49         /**
50          * Reports a warning.
51          */
52         Warning = 2,
53         /**
54          * Reports an information.
55          */
56         Information = 3,
57         /**
58          * Reports a hint.
59          */
60         Hint = 4
61         
62     }
63
64     public  class Position : Object, Gee.Comparable<Position> {
65         /**
66          * Line position in a document (zero-based).
67          */
68         public uint line { get; set; default = -1; }
69
70         /**
71          * Character offset on a line in a document (zero-based). Assuming that the line is
72          * represented as a string, the `character` value represents the gap between the
73          * `character` and `character + 1`.
74          *
75          * If the character value is greater than the line length it defaults back to the
76          * line length.
77          */
78         public uint character { get; set; default = -1; }
79
80         public int compare_to (Position other) {
81             return line > other.line ? 1 :
82                 (line == other.line ?
83                  (character > other.character ? 1 :
84                   (character == other.character ? 0 : -1)) : -1);
85         }
86         public bool equals(Position o) {
87                 return o.line == this.line && o.character == this.character;
88         }
89                 
90         public string to_string () {
91             return @"$line:$character";
92         }
93
94         public Position.from_libvala (Vala.SourceLocation sloc) {
95             line = sloc.line - 1;
96             character = sloc.column;
97         }
98
99         public Position dup () {
100             return this.translate ();
101         }
102
103         public Position translate (int dl = 0, int dc = 0) {
104             return new Position () {
105                 line = this.line + dl,
106                 character = this.character + dc
107             };
108         }
109     }
110
111     public class Range : Object, Gee.Hashable<Range>, Gee.Comparable<Range> {
112         
113         public Range.simple(uint line, uint pos) {
114                 var p =  new Position () {
115                 line = line,
116                 character = pos
117             };
118                 this.start = p;
119                 this.end = p;
120                 
121         }
122         /**
123          * The range's start position.
124          */
125         public Position start { get; set; }
126
127         /**
128          * The range's end position.
129          */
130         public Position end { get; set; }
131
132         private string? filename;
133
134         public string to_string () { return (filename != null ? @"$filename:" : "") + @"$start -> $end"; }
135
136         public Range.from_pos (Position pos) {
137             this.start = pos;
138             this.end = pos.dup ();
139         }
140
141         public Range.from_sourceref (Vala.SourceReference sref) {
142             this.start = new Position.from_libvala (sref.begin);
143             this.end = new Position.from_libvala (sref.end);
144             this.start.character -= 1;
145             this.filename = sref.file.filename;
146         }
147
148         public uint hash () {
149             return this.to_string ().hash ();
150         }
151
152         public bool equal_to (Range other) { return this.to_string () == other.to_string (); }
153                 public bool equals (Range o) {
154                         return this.filename == o.filename && this.start.equals(o.start) && this.end.equals(o.end);
155                 }
156
157         public int compare_to (Range other) {
158             return start.compare_to (other.start);
159         }
160
161         /**
162          * Return a new range that includes `this` and `other`.
163          */
164         public Range union (Range other) {
165             var range = new Range () {
166                 start = start.compare_to (other.start) < 0 ? start : other.start,
167                 end = end.compare_to (other.end) < 0 ? other.end : end,
168             };
169             if (filename == other.filename)
170                 range.filename = filename;
171             return range;
172         }
173
174         public bool contains (Position pos) {
175             return start.compare_to (pos) <= 0 && pos.compare_to (end) <= 0;
176         }
177        
178     }
179
180     public class Diagnostic : Object {
181         
182         public Diagnostic.simple ( int line, int character, string message)
183         {
184                 this.message = message;
185                 this.severity = DiagnosticSeverity.Error;
186                 this.range =  new Range.simple(line, character );
187                 
188                 
189         
190         }
191         /**
192          * The range at which the message applies.
193          */
194         public Range range { get; set; }
195
196         /**
197          * The diagnostic's severity. Can be omitted. If omitted it is up to the
198          * client to interpret diagnostics as error, warning, info or hint.
199          */
200         public DiagnosticSeverity severity { get; set; }
201
202         /**
203          * The diagnostic's code. Can be omitted.
204          */
205         public string? code { get; set; }
206
207         /**
208          * A human-readable string describing the source of this
209          * diagnostic, e.g. 'typescript' or 'super lint'.
210          */
211         public string? source { get; set; }
212
213         /**
214          * The diagnostic's message.
215          */
216         public string message { get; set; }
217         
218         
219         public string category {
220                 get { 
221                         switch(this.severity) {
222
223                                 case DiagnosticSeverity.Error : 
224                                         return "ERR";
225                                 case DiagnosticSeverity.Warning : 
226                                         return this.message.contains("deprecated") ? "DEPR" : "WARN";
227                                 default : 
228                                         return "WARN";
229                         }
230                 }
231                 private set {}
232                 
233         }
234         public bool equals(Lsp.Diagnostic o) {
235                 var ret = this.range.equals(o.range) && this.severity == o.severity && this.message == o.message;
236                 //GLib.debug("compare %s  (%s == %s)", ret ? "YES" : "NO", this.to_string(), o.to_string()); 
237                 
238                 
239                 return ret;
240         }
241         public string to_string()
242         {
243                 return "%s : %d - %s".printf(this.category, (int) this.range.start.line , this.message);
244         }
245         
246     }
247
248     /**
249      * An event describing a change to a text document. If range and rangeLength are omitted
250      * the new text is considered to be the full content of the document.
251      */
252     public class TextDocumentContentChangeEvent : Object {
253         public Range? range    { get; set; }
254         public int rangeLength { get; set; }
255         public string text     { get; set; }
256     }
257
258     public enum MessageType {
259         /**
260          * An error message.
261          */
262         Error = 1,
263         /**
264          * A warning message.
265          */
266         Warning = 2,
267         /**
268          * An information message.
269          */
270         Info = 3,
271         /**
272          * A log message.
273          */
274         Log = 4
275     }
276
277     public class TextDocumentIdentifier : Object {
278         public string uri { get; set; }
279     }
280
281     public class VersionedTextDocumentIdentifier : TextDocumentIdentifier {
282         /**
283          * The version number of this document. If a versioned text document identifier
284          * is sent from the server to the client and the file is not open in the editor
285          * (the server has not received an open notification before) the server can send
286          * `null` to indicate that the version is known and the content on disk is the
287          * master (as speced with document content ownership).
288          *
289          * The version number of a document will increase after each change, including
290          * undo/redo. The number doesn't need to be consecutive.
291          */
292         public int version { get; set; default = -1; }
293     }
294
295     public class TextDocumentPositionParams : Object {
296         public TextDocumentIdentifier textDocument { get; set; }
297         public Position position { get; set; }
298     }
299
300     public class ReferenceParams : TextDocumentPositionParams {
301         public class ReferenceContext : Object {
302             public bool includeDeclaration { get; set; }
303         }
304         public ReferenceContext? context { get; set; }
305     }
306
307     public class Location : Object {
308         public string uri { get; set; }
309         public Range range { get; set; }
310
311         public Location.from_sourceref (Vala.SourceReference sref) {
312             this (sref.file.filename, new Range.from_sourceref (sref));
313         }
314
315         public Location (string filename, Range range) {
316             this.uri = File.new_for_commandline_arg (filename).get_uri ();
317             this.range = range;
318         }
319     }
320
321     [CCode (default_value = "LSP_DOCUMENT_HIGHLIGHT_KIND_Text")]
322     public enum DocumentHighlightKind {
323         Text = 1,
324         Read = 2,
325         Write = 3
326     }
327
328     public class DocumentHighlight : Object {
329         public Range range { get; set; }
330         public DocumentHighlightKind kind { get; set; }
331     }
332
333     public class DocumentSymbolParams: Object {
334         public TextDocumentIdentifier textDocument { get; set; }
335     }
336
337     public class DocumentSymbol : Object, Json.Serializable {
338                 private Vala.SourceReference? _source_reference;
339                 public string name { get; set; }
340                 public string detail { get; set; default = ""; }
341                 public SymbolKind kind { get; set; }
342                 public bool deprecated { get; set; }
343
344                 public Range range { get; set; } 
345                 public Range selectionRange { get; set; }
346                 public GLib.ListStore children { get;  set; default = new GLib.ListStore(typeof(DocumentSymbol)); }
347                 public string? parent_name;
348
349                 private DocumentSymbol () {}
350
351         /**
352          * @param type the data type containing this symbol, if there was one (not available for Namespaces, for example)
353          * @param sym the symbol
354          */
355          /*
356         public DocumentSymbol.from_vala_symbol (Vala.DataType? type, Vala.Symbol sym, SymbolKind kind) {
357             this.parent_name = sym.parent_symbol != null ? sym.parent_symbol.name : null;
358             this._initial_range = new Range.from_sourceref (sym.source_reference);
359             if (sym is Vala.Subroutine) {
360                 var sub = (Vala.Subroutine) sym;
361                 var body_sref = sub.body != null ? sub.body.source_reference : null;
362                 // debug ("subroutine %s found (body @ %s)", sym.get_full_name (),
363                 //         body_sref != null ? body_sref.to_string () : null);
364                 if (body_sref != null && (body_sref.begin.line < body_sref.end.line ||
365                                 val = GLib.Value (typeof(Gee.ArrayList));                          body_sref.begin.line == body_sref.end.line && body_sref.begin.pos <= body_sref.end.pos)) {
366                     this._initial_range = this._initial_range.union (new Range.from_sourceref (body_sref));
367                 }
368             }
369             this.name = sym.name;
370             this.detail = Vls.CodeHelp.get_symbol_representation (type, sym, null, false);
371             this.kind = kind;
372             this.selectionRange = new Range.from_sourceref (sym.source_reference);
373             this.deprecated = sym.version.deprecated;
374         }
375         */
376         public new void Json.Serializable.set_property (ParamSpec pspec, Value value) {
377             base.set_property (pspec.get_name (), value);
378         }
379
380         public new Value Json.Serializable.get_property (ParamSpec pspec) {
381             Value val = Value (pspec.value_type);
382             base.get_property (pspec.get_name (), ref val);
383             return val;
384         }
385
386         public unowned ParamSpec? find_property (string name) {
387             return this.get_class ().find_property (name);
388         }
389
390         public Json.Node serialize_property (string property_name, Value value, ParamSpec pspec) {
391            // if (property_name != "children")
392                 return default_serialize_property (property_name, value, pspec);
393             /*var node = new Json.Node (Json.NodeType.ARRAY);
394             node.init_array (new Json.Array ());
395             var array = node.get_array ();
396             foreach (var child in children)
397                 array.add_element (Json.gobject_serialize (child));
398             return node;
399             */
400         }
401
402         public bool deserialize_property (string property_name, out Value value, ParamSpec pspec, Json.Node property_node) 
403             {
404                 GLib.debug("deserialise property %s" , property_name);
405                 if (property_name != "children") {
406                     return default_deserialize_property (property_name, out value, pspec, property_node);
407                 }
408             value = GLib.Value (typeof(GLib.ListStore));
409                 if (property_node.get_node_type () != Json.NodeType.ARRAY) {
410                     GLib.debug ("unexpected property node type for 'arguments' %s", property_node.get_node_type ().to_string ());
411                     return false;
412                 }
413                         GLib.debug("got child length of %d", (int) property_node.get_array ().get_length());
414                 var arguments = new GLib.ListStore(typeof(DocumentSymbol));
415
416                 property_node.get_array ().foreach_element ((array, index, element) => {
417                     
418                         var add= Json.gobject_deserialize ( typeof (DocumentSymbol),  array.get_element(index)) as DocumentSymbol;
419                                 arguments.append( add);
420
421                    
422                 });
423
424                 value.set_object (arguments);
425                 return true;
426            }
427            public string symbol_icon { 
428                         
429                         owned get {
430                                 return this.kind.icon(); 
431                         }
432                 }
433                 public string[] symbol_classes { 
434                         
435                         owned get {
436                                 string[] ret = { };
437                                 ret += this.kind.icon(); 
438                                 return ret;
439                         }
440                 }
441                 public string tooltip {
442                         owned get {
443                                 GLib.debug("%s : %s", this.name, this.detail);
444                                 //var detail = this.detail == "" ? (this.kind.to_string() + ": " + this.name) : this.detail;
445                                  return GLib.Markup.escape_text(this.detail + "\nline: " + this.range.start.line.to_string());
446                                 
447                         }
448                 }
449            
450            
451     }
452
453     public class SymbolInformation : Object {
454         public string name { get; set; }
455         public SymbolKind kind { get; set; }
456         public Location location { get; set; }
457         public string? containerName { get; set; }
458
459         public SymbolInformation.from_document_symbol (DocumentSymbol dsym, string uri) {
460             this.name = dsym.name;
461             this.kind = dsym.kind;
462           //  this.location = new Location (uri, dsym.range);
463             this.containerName = dsym.parent_name;
464         }
465     }
466
467     [CCode (default_value = "LSP_SYMBOL_KIND_Variable")]
468     public enum SymbolKind {
469         File = 1,
470         Module = 2,
471         Namespace = 3,
472         Package = 4,
473         Class = 5,
474         Method = 6,
475         Property = 7,
476         Field = 8,
477         Constructor = 9,
478         Enum = 10,
479         Interface = 11,
480         Function = 12,
481         Variable = 13,
482         Constant = 14,
483         String = 15,
484         Number = 16,
485         Boolean = 17,
486         Array = 18,
487         Object = 19,
488         Key = 20,
489         Null = 21,
490         EnumMember = 22,
491         Struct = 23,
492         Event = 24,
493         Operator = 25,
494         TypeParameter = 26;
495         
496         public string icon () { 
497                                 
498                         switch (this) {
499                                 
500                                 // case         SymbolKind.Text: return "completion-snippet-symbolic";
501                                 case    SymbolKind.Method: return "lang-method-symbolic";
502                                 case    SymbolKind.Function: return "lang-function-symbolic";
503                                 case    SymbolKind.Constructor: return "lang-method-symbolic";
504                                 case    SymbolKind.Field: return "lang-struct-field-symbolic";
505                                 case    SymbolKind.Variable: return "lang-variable-symbolic";
506                                 case    SymbolKind.Class: return "lang-class-symbolic";
507                                 case    SymbolKind.Interface: return "lang-class-symbolic";
508                                 case    SymbolKind.Module: return "lang-namespace-symbolic";
509                                 case    SymbolKind.Property:return "lang-struct-field-symbolic";
510                                 //case  SymbolKind.Unit: return "lang-variable-symbolic";
511                                 //case  SymbolKind.Value: return "lang-variable-symbolic";
512                                 case    SymbolKind.Enum: return "lang-enum-symbolic";
513                                 //case  SymbolKind.Keyword: return "completion-word-symbolic";
514                                 //case  SymbolKind.Snippet: return "completion-snippet-symbolic";
515
516                                 //case  SymbolKind.Color: return "lang-typedef-symbolic";
517                                 case    SymbolKind.File:return "lang-typedef-symbolic";
518                                 //case  SymbolKind.Reference: return "lang-typedef-symbolic";
519                                 //case  SymbolKind.Folder:return "lang-typedef-symbolic";
520                                 case    SymbolKind.EnumMember: return "lang-typedef-symbolic";
521                                 case    SymbolKind.Constant:return "lang-typedef-symbolic";
522                                 case    SymbolKind.Struct: return "lang-struct-symbolic";
523                                 case    SymbolKind.Event:return "lang-typedef-symbolic";
524                                 case    SymbolKind.Operator:return "lang-typedef-symbolic";
525                                 case    SymbolKind.TypeParameter:return "lang-typedef-symbolic";
526                         
527                                 default: 
528                                  return "completion-snippet-symbolic";
529                                                 
530                         }
531                 }
532                 public int sort_key() { 
533                          
534                         switch (this) {
535                                 case Enum : return 1;
536                                 case Class: return 2;
537                                 
538                                 case Constructor : return 1;
539                                 case Method : return 2;
540                                 case Field : return 3;
541                                 case Property : return 3;
542                                 
543                                 default:
544                                         return 5;
545                         }       
546                 
547                 
548                 
549                 }
550         
551     }
552
553         public class CompletionList : Object, Json.Serializable {
554         public bool isIncomplete { get; set; }
555         public Gee.List<CompletionItem> items { get; private set; default = new Gee.LinkedList<CompletionItem> (); }
556
557         public new void Json.Serializable.set_property (ParamSpec pspec, Value value) {
558             base.set_property (pspec.get_name (), value);
559         }
560
561         public new Value Json.Serializable.get_property (ParamSpec pspec) {
562             Value val = Value(pspec.value_type);
563             base.get_property (pspec.get_name (), ref val);
564             return val;
565         }
566
567         public unowned ParamSpec? find_property (string name) {
568             return this.get_class ().find_property (name);
569         }
570
571         public Json.Node serialize_property (string property_name, Value value, ParamSpec pspec) {
572             if (property_name != "items")
573                 return default_serialize_property (property_name, value, pspec);
574             var node = new Json.Node (Json.NodeType.ARRAY);
575             node.init_array (new Json.Array ());
576             var array = node.get_array ();
577             foreach (var child in items)
578                 array.add_element (Json.gobject_serialize (child));
579             return node;
580         }
581
582         public bool deserialize_property (string property_name, out Value value, ParamSpec pspec, Json.Node property_node) {
583             error ("deserialization not supported");
584         }
585     }
586
587     [CCode (default_value = "LSP_COMPLETION_TRIGGER_KIND_Invoked")]
588     public enum CompletionTriggerKind {
589         /**
590              * Completion was triggered by typing an identifier (24x7 code
591              * complete), manual invocation (e.g Ctrl+Space) or via API.
592              */
593         Invoked = 1,
594
595         /**
596              * Completion was triggered by a trigger character specified by
597              * the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
598              */
599         TriggerCharacter = 2,
600
601         /**
602              * Completion was re-triggered as the current completion list is incomplete.
603              */
604         TriggerForIncompleteCompletions = 3
605     }
606
607     public class CompletionContext : Object {
608         public CompletionTriggerKind triggerKind { get; set;}
609         public string? triggerCharacter { get; set; }
610     }
611
612     public class CompletionParams : TextDocumentPositionParams {
613         /**
614          * The completion context. This is only available if the client specifies
615          * to send this using `ClientCapabilities.textDocument.completion.contextSupport === true`
616          */
617         public CompletionContext? context { get; set; }
618     }
619
620     public enum CompletionItemTag {
621         // Render a completion as obsolete, usually using a strike-out.
622         Deprecated = 1,
623     }
624
625     [CCode (default_value = "LSP_INSERT_TEXT_FORMAT_PlainText")]
626     public enum InsertTextFormat {
627         /**
628          * The primary text to be inserted is treated as a plain string.
629          */
630         PlainText = 1,
631
632         /**
633          * The primary text to be inserted is treated as a snippet.
634          *
635          * A snippet can define tab stops and placeholders with `$1`, `$2`
636          * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
637          * the end of the snippet. Placeholders with equal identifiers are linked,
638          * that is typing in one will update others too.
639          */
640         Snippet = 2,
641     }
642
643     public class CompletionItem : Object, Gee.Hashable<CompletionItem>, Json.Serializable {
644         public string label { get; set; }
645         public CompletionItemKind kind { get; set; }
646         public string detail { get; set; }
647         public MarkupContent? documentation { get; set; }
648         public bool deprecated { get; set; }
649         public Gee.List<CompletionItemTag> tags { get; private set; default = new Gee.ArrayList<CompletionItemTag> (); }
650         public string? insertText { get; set; }
651         public InsertTextFormat insertTextFormat { get; set; default = InsertTextFormat.PlainText; }
652         private uint _hash;
653
654         private CompletionItem () {}
655
656         public CompletionItem.keyword (string keyword, string? insert_text = null, string? documentation = null) {
657             this.label = keyword;
658             this.kind = CompletionItemKind.Keyword;
659             this.insertText = insert_text;
660             if (insert_text != null && (insert_text.contains ("$0") || insert_text.contains ("${0")))
661                 this.insertTextFormat = InsertTextFormat.Snippet;
662             if (documentation != null)
663                 this.documentation = new MarkupContent.from_plaintext (documentation);
664             this._hash = @"$label $kind".hash ();
665         }
666
667         /**
668          * A completion suggestion from an existing Vala symbol.
669          * 
670          * @param instance_type the parent data type of data type of the expression where this symbol appears, or null
671          * @param sym the symbol itself
672          * @param scope the scope to display this in
673          * @param kind the kind of completion to display
674          * @param documentation the documentation to display
675          * @param label_override if non-null, override the displayed symbol name with this
676          */
677          /*
678         public CompletionItem.from_symbol (Vala.DataType? instance_type, Vala.Symbol sym, Vala.Scope? scope,
679             CompletionItemKind kind,
680             Vls.DocComment? documentation, string? label_override = null) {
681             this.label = label_override ?? sym.name;
682             this.kind = kind;
683             this.detail = Vls.CodeHelp.get_symbol_representation (instance_type, sym, scope, true, null, label_override, false);
684             this._hash = @"$label $kind".hash ();
685
686             if (documentation != null)
687                 this.documentation = new MarkupContent.from_markdown (documentation.body);
688
689             var version = sym.get_attribute ("Version");
690             if (version != null && (version.get_bool ("deprecated") || version.get_string ("deprecated_since") != null)) {
691                 this.tags.add (CompletionItemTag.Deprecated);
692                 this.deprecated = true;
693             }public
694         }
695                 */
696         /**
697          * A completion suggestion from a data type and a synthetic symbol name.
698          *
699          * @param symbol_type       the data type of the symbol
700          * @param symbol_name       the name of the synthetic symbol
701          * @param scope             the scope that this completion item is displayed in, or null
702          * @param kind              the type of completion to display
703          * @param documentation     the documentation for this symbol, or null
704          */
705          /*
706         public CompletionItem.from_synthetic_symbol (Vala.DataType symbol_type, string symbol_name, Vala.Scope? scope,
707                                                      CompletionItemKind kind, Vls.DocComment? documentation) {
708             this.label = symbol_name;
709             this.kind = kind;
710             this.detail = @"$(Vls.CodeHelp.get_symbol_representation (symbol_type, null, scope, true, null, null, false)) $symbol_name";
711             this._hash = @"$label $kind".hash ();
712
713             if (documentation != null)
714                 this.documentation = new MarkupContent.from_markdown (documentation.body);
715         }
716         */
717                 /*
718         public CompletionItem.from_unimplemented_symbol (Vala.Symbol sym, 
719                                                          string label, CompletionItemKind kind,
720                                                          string insert_text,
721                                                          Vls.DocComment? documentation) {
722             this.label = label;
723             this.kind = kind;
724             this.insertText = insert_text;
725             if (insert_text.contains ("$0") || insert_text.contains ("${0"))
726                 this.insertTextFormat = InsertTextFormat.Snippet;
727             this._hash = @"$label $kind".hash ();
728             if (documentation != null)
729                 this.documentation = new MarkupContent.from_markdown (documentation.body);
730         }
731         */
732
733         public uint hash () {
734             return this._hash;
735         }
736
737         public bool equal_to (CompletionItem other) {
738             return other.label == this.label && other.kind == this.kind;
739         }
740
741         public new void Json.Serializable.set_property (ParamSpec pspec, Value value) {
742             base.set_property (pspec.get_name (), value);
743         }
744
745         public new Value Json.Serializable.get_property (ParamSpec pspec) {
746             Value val = Value(pspec.value_type);
747             base.get_property (pspec.get_name (), ref val);
748             return val;
749         }
750
751         public unowned ParamSpec? find_property (string name) {
752             return this.get_class ().find_property (name);
753         }
754
755         public Json.Node serialize_property (string property_name, Value value, ParamSpec pspec) {
756             if (property_name != "tags")
757                 return default_serialize_property (property_name, value, pspec);
758
759             var node = new Json.Node (Json.NodeType.ARRAY);
760             node.init_array (new Json.Array ());
761             var array = node.get_array ();
762             foreach (var tag in this.tags) {
763                 array.add_int_element (tag);
764             }
765
766             return node;
767         }
768         public bool deserialize_property (string property_name, out Value value, ParamSpec pspec, Json.Node property_node) 
769         {
770                 if (property_name != "tags") {
771                 return default_deserialize_property (property_name, out value, pspec, property_node);
772             }
773             value = GLib.Value (typeof(Gee.ArrayList));
774             if (property_node.get_node_type () != Json.NodeType.ARRAY) {
775                 warning ("unexpected property node type for 'arguments' %s", property_node.get_node_type ().to_string ());
776                 return false;
777             }
778
779             var arguments = new Gee.ArrayList<CompletionItemTag>();
780
781             property_node.get_array ().foreach_element ((array, index, element) => {
782                 try {
783                     arguments.add ((CompletionItemTag) Json.gvariant_deserialize (element, null).get_int32() );
784                 } catch (Error e) {
785                     warning ("argument %u to command could not be deserialized: %s", index, e.message);
786                 }
787             });
788
789             value.set_object (arguments);
790             return true;
791        }
792     }
793
794     public class MarkupContent : Object {
795         public string kind { get; set; }
796         public string value { get; set; }
797
798         private MarkupContent () {}
799
800         /**
801          * Create a MarkupContent with plain text.
802          */
803         public MarkupContent.from_plaintext (string doc) {
804             this.kind = "plaintext";
805             this.value = doc;
806         }
807
808         /**
809          * Create a MarkupContent with markdown text.
810          */
811         public MarkupContent.from_markdown (string doc) {
812             this.kind = "markdown";
813             this.value = doc;
814         }
815     }
816     
817     [CCode (default_value = "LSP_COMPLETION_ITEM_KIND_Text")]
818     public enum CompletionItemKind {
819         Text = 1,
820         Method = 2,
821         Function = 3,
822         Constructor = 4,
823         Field = 5,
824         Variable = 6,
825         Class = 7,
826         Interface = 8,
827         Module = 9,
828         Property = 10,
829         Unit = 11,
830         Value = 12,
831         Enum = 13,
832         Keyword = 14,
833         Snippet = 15,
834         Color = 16,
835         File = 17,
836         Reference = 18,
837         Folder = 19,
838         EnumMember = 20,
839         Constant = 21,
840         Struct = 22,
841         Event = 23,
842         Operator = 24,
843         TypeParameter = 25
844     }
845     
846     /**
847      * Capabilities of the client/editor for `textDocument/documentSymbol`
848      */
849     public class DocumentSymbolCapabilities : Object {
850         public bool hierarchicalDocumentSymbolSupport { get; set; }
851     }
852
853     /**
854      * Capabilities of the client/editor for `textDocument/rename`
855      */
856     public class RenameClientCapabilities : Object {
857         public bool prepareSupport { get; set; }
858     }
859
860     /**
861      * Capabilities of the client/editor pertaining to language features.
862      */
863     public class TextDocumentClientCapabilities : Object {
864         public DocumentSymbolCapabilities documentSymbol { get; set; default = new DocumentSymbolCapabilities ();}
865         public RenameClientCapabilities rename { get; set; default = new RenameClientCapabilities (); }
866     }
867
868     /**
869      * Capabilities of the client/editor.
870      */
871     public class ClientCapabilities : Object {
872         public TextDocumentClientCapabilities textDocument { get; set; default = new TextDocumentClientCapabilities (); }
873     }
874
875     public class InitializeParams : Object {
876         public int processId { get; set; }
877         public string? rootPath { get; set; }
878         public string? rootUri { get; set; }
879         public ClientCapabilities capabilities { get; set; default = new ClientCapabilities (); }
880     }
881
882     public class SignatureInformation : Object, Json.Serializable {
883         public string label { get; set; }
884         public MarkupContent documentation { get; set; }
885
886         public Gee.List<ParameterInformation> parameters { get; private set; default = new Gee.LinkedList<ParameterInformation> (); }
887
888         public new void Json.Serializable.set_property (ParamSpec pspec, Value value) {
889             base.set_property (pspec.get_name (), value);
890         }
891
892         public new Value Json.Serializable.get_property (ParamSpec pspec) {
893             Value val = Value(pspec.value_type);
894             base.get_property (pspec.get_name (), ref val);
895             return val;
896         }
897
898         public unowned ParamSpec? find_property (string name) {
899             return this.get_class ().find_property (name);
900         }
901
902         public Json.Node serialize_property (string property_name, Value value, ParamSpec pspec) {
903             if (property_name != "parameters")
904                 return default_serialize_property (property_name, value, pspec);
905             var node = new Json.Node (Json.NodeType.ARRAY);
906             node.init_array (new Json.Array ());
907             var array = node.get_array ();
908             foreach (var child in parameters)
909                 array.add_element (Json.gobject_serialize (child));
910             return node;
911         }
912
913         public bool deserialize_property (string property_name, out Value value, ParamSpec pspec, Json.Node property_node) {
914             error ("deserialization not supported");
915         }
916     }
917
918     public class SignatureHelp : Object, Json.Serializable {
919         public Gee.Collection<SignatureInformation> signatures { get; set; default = new Gee.ArrayList<SignatureInformation> (); }
920         public int activeSignature { get; set; }
921         public int activeParameter { get; set; }
922
923         public Json.Node serialize_property (string property_name, Value value, ParamSpec pspec) {
924             if (property_name != "signatures")
925                 return default_serialize_property (property_name, value, pspec);
926
927             var node = new Json.Node (Json.NodeType.ARRAY);
928             node.init_array (new Json.Array ());
929             var array = node.get_array ();
930             foreach (var child in signatures)
931                 array.add_element (Json.gobject_serialize (child));
932             return node;
933         }
934
935         public bool deserialize_property (string property_name, out Value value, ParamSpec pspec, Json.Node property_node) {
936             error ("deserialization not supported");
937         }
938     }
939
940     public class ParameterInformation : Object {
941         public string label { get; set; }
942         public MarkupContent documentation { get; set; }
943     }
944
945    public  class MarkedString : Object {
946                 public MarkedString(string language, string value) 
947                 {
948                         this.language = language;
949                         this.value = value;
950                         GLib.debug("new marked string %s : %s", language, value);
951                 }
952         public string language { get; set; }
953         public string value { get; set; }
954     }
955
956     public class Hover : Object, Json.Serializable {
957         public Gee.List<MarkedString> contents { get; set; default = new Gee.ArrayList<MarkedString> (); }
958         public Range range { get; set; }
959
960         public new void Json.Serializable.set_property (ParamSpec pspec, Value value) {
961             base.set_property (pspec.get_name (), value);
962         }
963
964         public new Value Json.Serializable.get_property (ParamSpec pspec) {
965             Value val = Value(pspec.value_type);
966             base.get_property (pspec.get_name (), ref val);
967             return val;
968         }
969
970         public unowned ParamSpec? find_property (string name) {
971             return this.get_class ().find_property (name);
972         }
973
974         public Json.Node serialize_property (string property_name, Value value, ParamSpec pspec) {
975             if (property_name != "contents")
976                 return default_serialize_property (property_name, value, pspec);
977             var node = new Json.Node (Json.NodeType.ARRAY);
978             node.init_array (new Json.Array ());
979             var array = node.get_array ();
980             foreach (var child in contents) {
981                 if (child.language != null)
982                     array.add_element (Json.gobject_serialize (child));
983                 else
984                     array.add_element (new Json.Node (Json.NodeType.VALUE).init_string (child.value));
985             }
986             return node;
987         }
988
989         public bool deserialize_property (string property_name, out Value value, ParamSpec pspec, Json.Node property_node) 
990         {
991             if (property_name == "contents") {
992                 value = GLib.Value (typeof(Gee.ArrayList));
993                         if (property_node.get_node_type () != Json.NodeType.ARRAY) {
994                             warning ("unexpected property node type for 'arguments' %s", property_node.get_node_type ().to_string ());
995                             return false;
996                         }
997                                 var contents = new Gee.ArrayList<MarkedString>();
998
999                         property_node.get_array ().foreach_element ((array, index, element) => {
1000                                 try {
1001                                                 var add = new MarkedString(
1002                                                         array.get_object_element(index).get_string_member("language"),
1003                                                         array.get_object_element(index).get_string_member("value")
1004                                                 );
1005                              
1006                                 contents.add ( add );
1007                             } catch (Error e) {
1008                                 warning ("argument %u to command could not be deserialized: %s", index, e.message);
1009                             }
1010                         });
1011                 value.set_object (contents);
1012                         return true;
1013             } 
1014             
1015             return default_deserialize_property (property_name, out value, pspec, property_node);
1016         }
1017     }
1018
1019     /**
1020      * A textual edit applicable to a text document.
1021      */
1022     public class TextEdit : Object {
1023         /**
1024          * The range of the text document to be manipulated. To insert
1025          * text into a document create a range where ``start === end``.
1026          */
1027         public Range range { get; set; }
1028
1029         /**
1030          * The string to be inserted. For delete operations use an
1031          * empty string.
1032          */
1033         public string newText { get; set; }
1034
1035         public TextEdit (Range range, string new_text = "") {
1036             this.range = range;
1037             this.newText = new_text;
1038         }
1039     }
1040
1041     /** 
1042      * Describes textual changes on a single text document. The text document is
1043      * referred to as a {@link VersionedTextDocumentIdentifier} to allow clients to
1044      * check the text document version before an edit is applied. A
1045      * {@link TextDocumentEdit} describes all changes on a version ``Si`` and after they are
1046      * applied move the document to version ``Si+1``. So the creator of a
1047      * {@link TextDocumentEdit} doesn’t need to sort the array of edits or do any kind
1048      * of ordering. However the edits must be non overlapping.
1049      */
1050     public class TextDocumentEdit : Object, Json.Serializable {
1051         /**
1052          * The text document to change.
1053          */
1054         public VersionedTextDocumentIdentifier textDocument { get; set; }
1055
1056         /**
1057          * The edits to be applied.
1058          */
1059         public Gee.ArrayList<TextEdit> edits { get; set; default = new Gee.ArrayList<TextEdit> (); }
1060
1061         public TextDocumentEdit (VersionedTextDocumentIdentifier text_document) {
1062             this.textDocument = text_document;
1063         }
1064
1065         public Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) {
1066             if (property_name != "edits")
1067                 return default_serialize_property (property_name, value, pspec);
1068             
1069             var node = new Json.Node (Json.NodeType.ARRAY);
1070             node.init_array (new Json.Array ());
1071             var array = node.get_array ();
1072             foreach (var text_edit in edits) {
1073                 array.add_element (Json.gobject_serialize (text_edit));
1074             }
1075             return node;
1076         }
1077
1078         public bool deserialize_property (string property_name, out GLib.Value value, GLib.ParamSpec pspec, Json.Node property_node) {
1079             error ("deserialization not supported");
1080         }
1081     }
1082
1083     public abstract class CommandLike : Object, Json.Serializable {
1084         /**
1085          * The identifier of the actual command handler.
1086          */
1087         public string command { get; set; }
1088
1089         /**
1090          * Arguments that the command handler should be invoked with.
1091          */
1092         public Array<Variant>? arguments { get; set; }
1093
1094         public Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) {
1095             if (property_name != "arguments" || arguments == null)
1096                 return default_serialize_property (property_name, value, pspec);
1097
1098             var array = new Json.Array ();
1099             for (int i = 0; i < arguments.length; i++)
1100                 array.add_element (Json.gvariant_serialize (arguments.index (i)));
1101
1102             var node = new Json.Node (Json.NodeType.ARRAY);
1103             node.set_array (array);
1104             return node;
1105         }
1106
1107         public bool deserialize_property (string property_name, out GLib.Value value, GLib.ParamSpec pspec, Json.Node property_node) 
1108         {
1109             if (property_name == "arguments") {
1110                 value = GLib.Value (typeof(Array));
1111                 if (property_node.get_node_type () != Json.NodeType.ARRAY) {
1112                     warning ("unexpected property node type for 'arguments' %s", property_node.get_node_type ().to_string ());
1113                     return false;
1114                 }
1115
1116                 var arguments = new Array<Variant> ();
1117
1118                 property_node.get_array ().foreach_element ((array, index, element) => {
1119                     try {
1120                         arguments.append_val (Json.gvariant_deserialize (element, null));
1121                     } catch (Error e) {
1122                         warning ("argument %u to command could not be deserialized: %s", index, e.message);
1123                     }
1124                 });
1125
1126                 value.set_boxed (arguments);
1127                 return true;
1128             } else if (property_name == "command") {
1129                 // workaround for json-glib < 1.5.2 (Ubuntu 20.04 / eOS 6)
1130                 if (property_node.get_value_type () != typeof (string)) {
1131                     value = "";
1132                     warning ("unexpected property node type for 'commands' %s", property_node.get_node_type ().to_string ());
1133                     return false;
1134                 }
1135
1136                 value = property_node.get_string ();
1137                 return true;
1138             } else {
1139                 return default_deserialize_property (property_name, out value, pspec, property_node);
1140             }
1141         }
1142     }
1143
1144     public class ExecuteCommandParams : CommandLike {
1145     }
1146
1147     /**
1148      * Represents a reference to a command. Provides a title which will be used
1149      * to represent a command in the UI. Commands are identified by a string
1150      * identifier. The recommended way to handle commands is to implement their
1151      * execution on the server side if the client and server provides the
1152      * corresponding capabilities. Alternatively the tool extension code could
1153      * handle the command. The protocol currently doesn’t specify a set of
1154      * well-known commands.
1155      */
1156     public class Command : CommandLike {
1157         /**
1158          * The title of the command, like `save`.
1159          */
1160         public string title { get; set; }
1161     }
1162
1163     /**
1164      * A code lens represents a command that should be shown along with
1165      * source text, like the number of references, a way to run tests, etc.
1166      *
1167      * A code lens is _unresolved_ when no command is associated to it. For
1168      * performance reasons the creation of a code lens and resolving should be done
1169      * in two stages.
1170      */
1171     public class CodeLens : Object {
1172         /**
1173          * The range in which this code lens is valid. Should only span a single
1174          * line.
1175          */
1176         public Range range { get; set; }
1177
1178         /**
1179          * The command this code lens represents.
1180          */
1181         public Command? command { get; set; }
1182     }
1183     
1184     public class DocumentRangeFormattingParams : Object {
1185         public TextDocumentIdentifier textDocument { get; set; }
1186         public Range? range { get; set; }
1187         public FormattingOptions options { get; set; }
1188     }
1189
1190     public class FormattingOptions : Object {
1191         public uint tabSize { get; set; }
1192         public bool insertSpaces { get; set; }
1193         public bool trimTrailingWhitespace { get; set; }
1194         public bool insertFinalNewline { get; set; }
1195         public bool trimFinalNewlines { get; set; }
1196     }
1197
1198     public class CodeActionParams : Object {
1199         public TextDocumentIdentifier textDocument { get; set; }
1200         public Range range { get; set; }
1201         public CodeActionContext context { get; set; }
1202     }
1203
1204
1205     public class CodeActionContext : Object, Json.Serializable {
1206         public Gee.List<Diagnostic> diagnostics { get; set; default = new Gee.ArrayList<Diagnostic> (); }
1207         public string[]? only { get; set; }
1208 /*
1209         public bool deserialize_property (string property_name, out Value value, ParamSpec pspec, Json.Node property_node) {
1210             if (property_name != "diagnostics")
1211                 return default_deserialize_property (property_name, out value, pspec, property_node);
1212             var diags = new Gee.ArrayList<Diagnostic> ();
1213             property_node.get_array ().foreach_element ((array, index, element) => {
1214                 try {
1215                     diags.add (Vls.Util.parse_variant<Diagnostic> (Json.gvariant_deserialize (element, null)));
1216                 } catch (Error e) {
1217                     warning ("argument %u could not be deserialized: %s", index, e.message);
1218                 }
1219             });
1220             value = diags;
1221             return true;
1222         }
1223         */
1224     }
1225
1226
1227         public class Diagnostics : Object, Json.Serializable 
1228         {
1229                 public Diagnostics()
1230                 {
1231                         this.diagnostics = new Gee.ArrayList<Diagnostic>((a,b) => {
1232                                 return a.equals(b);
1233                         });
1234                 }
1235                 
1236                 public string uri { get; set; }
1237
1238                 public int version  { get; set; default = 0; }
1239         public Gee.ArrayList<Diagnostic>? diagnostics { get; set; }
1240                  
1241                 public string filename { 
1242                         owned get {
1243                                 return File.new_for_uri (this.uri).get_path();
1244                         }
1245                         private set {}
1246                 }
1247                 
1248                 public bool deserialize_property (string property_name, out GLib.Value val, GLib.ParamSpec pspec, Json.Node property_node) {
1249                         if (property_name == "diagnostics") {
1250                 val = GLib.Value (typeof(Gee.ArrayList));
1251                                 var diags =  new Gee.ArrayList<Diagnostic> ((a,b) => {
1252                                         return a.equals(b);
1253                                 });
1254                                 if (property_node.get_node_type () != Json.NodeType.ARRAY) {
1255                                         val.set_object(diags);
1256                                         warning ("unexpected property node type for 'arguments' %s", property_node.get_node_type ().to_string ());
1257                                         return false;
1258                                 }
1259
1260                                 
1261
1262                                 property_node.get_array ().foreach_element ((array, index, element) => {
1263                                          
1264                                                 diags.add (Json.gobject_deserialize (typeof (Lsp.Diagnostic), element) as Diagnostic );
1265                                          
1266                                                 //warning ("argument %u to command could not be deserialized: %s", index, e.message);
1267                                          
1268                                 });
1269                                 val.set_object(diags);
1270                                  
1271                                 return true;
1272                         }   
1273                          
1274                         return default_deserialize_property (property_name, out val, pspec, property_node);
1275                          
1276                 }
1277
1278                 
1279         }
1280
1281
1282    public  class CodeAction : Object, Json.Serializable {
1283         public string title { get; set; }
1284         public string? kind { get; set; }
1285         public Gee.Collection<Diagnostic>? diagnostics { get; set; }
1286         public bool isPreferred { get; set; }
1287         public WorkspaceEdit? edit { get; set; }
1288         public Command? command { get; set; }
1289         public Object? data { get; set; }
1290
1291         protected void add_diagnostic (Diagnostic diag) {
1292             if (diagnostics == null)
1293                 diagnostics = new Gee.ArrayList<Diagnostic> ();
1294             diagnostics.add (diag);
1295         }
1296
1297         public override Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) {
1298             if (property_name != "diagnostics")
1299                 return default_serialize_property (property_name, value, pspec);
1300
1301             var array = new Json.Array ();
1302             if (diagnostics != null)
1303                 foreach (var text_edit in diagnostics)
1304                     array.add_element (Json.gobject_serialize (text_edit));
1305             return new Json.Node.alloc ().init_array (array);
1306         }
1307     }
1308
1309     public class WorkspaceEdit : Object, Json.Serializable {
1310         public Gee.List<TextDocumentEdit>? documentChanges { get; set; }
1311
1312         public Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) {
1313             if (property_name != "documentChanges")
1314                 return default_serialize_property (property_name, value, pspec);
1315
1316             var node = new Json.Node (Json.NodeType.ARRAY);
1317             node.init_array (new Json.Array ());
1318             if (documentChanges != null) {
1319                 var array = node.get_array ();
1320                 foreach (var text_edit in documentChanges) {
1321                     array.add_element (Json.gobject_serialize (text_edit));
1322                 }
1323             }
1324             return node;
1325         }
1326     }
1327
1328     [Flags]
1329     public enum SymbolTags {
1330         NONE,
1331         DEPRECATED
1332     }
1333
1334     public class CallHierarchyItem : Object, Json.Serializable {
1335         public string name { get; set; }
1336         public SymbolKind kind { get; set; }
1337         public SymbolTags tags { get; set; }
1338         public string? detail { get; set; }
1339         public string uri { get; set; }
1340         public Range range { get; set; }
1341         public Range selectionRange { get; set; }
1342
1343         public override Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) {
1344             if (property_name != "tags")
1345                 return default_serialize_property (property_name, value, pspec);
1346             var array = new Json.Array ();
1347             if (SymbolTags.DEPRECATED in tags)
1348                 array.add_int_element (SymbolTags.DEPRECATED);
1349             return new Json.Node.alloc ().init_array (array);
1350         }
1351 /*
1352         public CallHierarchyItem.from_symbol (Vala.Symbol symbol) {
1353             this.name = symbol.get_full_name ();
1354             if (symbol is Vala.Method) {
1355                 if (symbol.parent_symbol is Vala.Namespace)
1356                     this.kind = SymbolKind.Function;
1357                 else
1358                     this.kind = SymbolKind.Method;
1359             } else if (symbol is Vala.Signal) {
1360                 this.kind = SymbolKind.Event;
1361             } else if (symbol is Vala.Constructor) {
1362                 this.kind = SymbolKind.Constructor;
1363             } else {
1364                 this.kind = SymbolKind.Method;
1365             }
1366             var version = symbol.get_attribute ("Version");
1367             if (version != null && (version.get_bool ("deprecated") || version.get_string ("deprecated_since") != null)) {
1368                 this.tags |= SymbolTags.DEPRECATED;
1369             }
1370             this.detail = Vls.CodeHelp.get_symbol_representation (null, symbol, null, true);
1371             this.uri = File.new_for_commandline_arg (symbol.source_reference.file.filename).get_uri ();
1372             this.range = new Range.from_sourceref (symbol.source_reference);
1373             if (symbol.comment != null)
1374                 this.range = new Range.from_sourceref (symbol.comment.source_reference).union (this.range);
1375             if (symbol is Vala.Subroutine && ((Vala.Subroutine)symbol).body != null)
1376                 this.range = new Range.from_sourceref (((Vala.Subroutine)symbol).body.source_reference).union (this.range);
1377             this.selectionRange = new Range.from_sourceref (symbol.source_reference);
1378         }
1379         */
1380     }
1381
1382     public class CallHierarchyIncomingCall : Json.Serializable, Object {
1383         /**
1384          * The method that calls the query method.
1385          */
1386         public CallHierarchyItem from { get; set; }
1387
1388         /**
1389          * The ranges at which the query method is called by `from`.
1390          */
1391         public Gee.ArrayList<Range> fromRanges { get; set; default = new Gee.ArrayList<Range> (); }
1392
1393         public override Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) {
1394             if (property_name == "from")
1395                 return default_serialize_property (property_name, value, pspec);
1396             var array = new Json.Array ();
1397             foreach (var range in fromRanges)
1398                 array.add_element (Json.gobject_serialize (range));
1399             return new Json.Node.alloc ().init_array (array);
1400         }
1401     }
1402
1403     public class CallHierarchyOutgoingCall : Json.Serializable, Object {
1404         /**
1405          * The method that the query method calls.
1406          */
1407         public CallHierarchyItem to { get; set; }
1408
1409         /**
1410          * The ranges at which the method is called by the query method.
1411          */
1412         public Gee.ArrayList<Range> fromRanges { get; set; default = new Gee.ArrayList<Range> (); }
1413
1414         public override Json.Node serialize_property (string property_name, GLib.Value value, GLib.ParamSpec pspec) {
1415             if (property_name == "to")
1416                 return default_serialize_property (property_name, value, pspec);
1417             var array = new Json.Array ();
1418             foreach (var range in fromRanges)
1419                 array.add_element (Json.gobject_serialize (range));
1420             return new Json.Node.alloc ().init_array (array);
1421         }
1422     }
1423
1424     public class InlayHintParams : Json.Serializable, Object {
1425         public TextDocumentIdentifier textDocument { get; set; }
1426         public Range range { get; set; }
1427     }
1428
1429     public enum InlayHintKind {
1430         UNSET,
1431         TYPE,
1432         PARAMETER
1433     }
1434
1435     public class InlayHint : Object {
1436         public Position position { get; set; }
1437         public string label { get; set; }
1438         public InlayHintKind kind { get; set; }
1439         public string? tooltip { get; set; }
1440         public bool paddingLeft { get; set; }
1441         public bool paddingRight { get; set; }
1442     }
1443
1444    public  class TypeHierarchyItem : Object, Json.Serializable {
1445         /**
1446          * The name of this item
1447          */
1448         public string name { get; set; }
1449
1450         /**
1451          * The kind of this item
1452          */
1453         public SymbolKind kind { get; set; }
1454
1455         /**
1456          * Tags for this item
1457          */
1458         public SymbolTags tags { get; set; }
1459
1460         /**
1461          * More detail for this item, e.g. the signature of a function.
1462          */
1463         public string? detail { get; set; }
1464
1465         /**
1466          * The resource identifier of this item.
1467          */
1468         public string uri { get; set; }
1469
1470         /**
1471          * The range enclosing this symbol not including leading/trailing
1472          * whitespace, but everything else, e.g. comments and code.
1473          */
1474         public Range range { get; set; }
1475
1476         /**
1477          * The range that should be selected and revealed when this symbol
1478          * is being picked, e.g. the name of a function. Must be contained
1479          * by {@link TypeHierarchyItem.range}
1480          */
1481         public Range selectionRange { get; set; }
1482
1483         private TypeHierarchyItem () {}
1484 /*
1485         public TypeHierarchyItem.from_symbol (Vala.TypeSymbol symbol) {
1486             this.name = symbol.get_full_name ();
1487             if (symbol is Vala.Class)
1488                 this.kind = SymbolKind.Class;
1489             else if (symbol is Vala.Delegate)
1490                 this.kind = SymbolKind.Interface;
1491             else if (symbol is Vala.Enum)
1492                 this.kind = SymbolKind.Enum;
1493             else if (symbol is Vala.ErrorCode)
1494                 this.kind = SymbolKind.EnumMember;
1495             else if (symbol is Vala.ErrorDomain)
1496                 this.kind = SymbolKind.Enum;
1497             else if (symbol is Vala.Interface)
1498                 this.kind = SymbolKind.Interface;
1499             else if (symbol is Vala.Struct)
1500                 this.kind = SymbolKind.Struct;
1501             else if (symbol is Vala.TypeParameter)
1502                 this.kind = SymbolKind.TypeParameter;
1503             else {
1504                 this.kind = SymbolKind.Module;
1505                 warning ("unexpected symbol kind in type hierarchy: `%s'", symbol.type_name);
1506             }
1507
1508             var version = symbol.get_attribute ("Version");
1509             if (version != null && (version.get_bool ("deprecated") || version.get_string ("deprecated_since") != null)) {
1510                 this.tags |= SymbolTags.DEPRECATED;
1511             }
1512             this.detail = Vls.CodeHelp.get_symbol_representation (null, symbol, null, true);
1513             this.uri = File.new_for_commandline_arg (symbol.source_reference.file.filename).get_uri ();
1514             this.range = new Range.from_sourceref (symbol.source_reference);
1515             this.selectionRange = this.range;
1516
1517             // widen range to include all members
1518             if (symbol is Vala.ObjectTypeSymbol) {
1519                 foreach (var member in ((Vala.ObjectTypeSymbol)symbol).get_members ()) {
1520                     if (member.source_reference != null)
1521                         this.range = this.range.union (new Range.from_sourceref (member.source_reference));
1522                 }
1523             } else if (symbol is Vala.Enum) {
1524                 foreach (var member in ((Vala.Enum)symbol).get_values ()) {
1525                     if (member.source_reference != null)
1526                         this.range = this.range.union (new Range.from_sourceref (member.source_reference));
1527                 }
1528                 foreach (var method in ((Vala.Enum)symbol).get_methods ()) {
1529                     if (method.source_reference != null)
1530                         this.range = this.range.union (new Range.from_sourceref (method.source_reference));
1531                 }
1532             } else if (symbol is Vala.ErrorDomain) {
1533                 foreach (var member in ((Vala.ErrorDomain)symbol).get_codes ()) {
1534                     if (member.source_reference != null)
1535                         this.range = this.range.union (new Range.from_sourceref (member.source_reference));
1536                 }
1537                 foreach (var method in ((Vala.ErrorDomain)symbol).get_methods ()) {
1538                     if (method.source_reference != null)
1539                         this.range = this.range.union (new Range.from_sourceref (method.source_reference));
1540                 }
1541             } else if (symbol is Vala.Struct) {
1542                 foreach (var field in ((Vala.Struct)symbol).get_fields ()) {
1543                     if (field.source_reference != null)
1544                         this.range = this.range.union (new Range.from_sourceref (field.source_reference));
1545                 }
1546                 foreach (var method in ((Vala.Struct)symbol).get_methods ()) {
1547                     if (method.source_reference != null)
1548                         this.range = this.range.union (new Range.from_sourceref (method.source_reference));
1549                 }
1550             }
1551         }
1552         */
1553     }
1554 }