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