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