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