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