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