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