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