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