(character > other.character ? 1 :
(character == other.character ? 0 : -1)) : -1);
}
-
+ public bool equals(Position o) {
+ return o.line == this.line && o.character == this.character;
+ }
+
public string to_string () {
return @"$line:$character";
}
}
public class Range : Object, Gee.Hashable<Range>, Gee.Comparable<Range> {
+
+ public Range.simple(uint line, uint pos) {
+ var p = new Position () {
+ line = line,
+ character = pos
+ };
+ this.start = p;
+ this.end = p;
+
+ }
/**
* The range's start position.
*/
}
public bool equal_to (Range other) { return this.to_string () == other.to_string (); }
+ public bool equals (Range o) {
+ return this.filename == o.filename && this.start.equals(o.start) && this.end.equals(o.end);
+ }
public int compare_to (Range other) {
return start.compare_to (other.start);
public bool contains (Position pos) {
return start.compare_to (pos) <= 0 && pos.compare_to (end) <= 0;
}
+
}
public class Diagnostic : Object {
+
+ public Diagnostic.simple ( int line, int character, string message)
+ {
+ this.message = message;
+ this.severity = DiagnosticSeverity.Error;
+ this.range = new Range.simple(line, character );
+
+
+
+ }
/**
* The range at which the message applies.
*/
private set {}
}
+ public bool equals(Lsp.Diagnostic o) {
+ var ret = this.range.equals(o.range) && this.severity == o.severity && this.message == o.message;
+ //GLib.debug("compare %s (%s == %s)", ret ? "YES" : "NO", this.to_string(), o.to_string());
+
+
+ return ret;
+ }
+ public string to_string()
+ {
+ return "%s : %d - %s".printf(this.category, (int) this.range.start.line , this.message);
+ }
+
}
/**
// debug ("subroutine %s found (body @ %s)", sym.get_full_name (),
// body_sref != null ? body_sref.to_string () : null);
if (body_sref != null && (body_sref.begin.line < body_sref.end.line ||
- body_sref.begin.line == body_sref.end.line && body_sref.begin.pos <= body_sref.end.pos)) {
+ val = GLib.Value (typeof(Gee.ArrayList)); body_sref.begin.line == body_sref.end.line && body_sref.begin.pos <= body_sref.end.pos)) {
this._initial_range = this._initial_range.union (new Range.from_sourceref (body_sref));
}
}
return node;
}
- public bool deserialize_property (string property_name, out Value value, ParamSpec pspec, Json.Node property_node) {
- error ("deserialization not supported");
- }
+ public bool deserialize_property (string property_name, out Value value, ParamSpec pspec, Json.Node property_node)
+ {
+
+ if (property_name != "children") {
+ return default_deserialize_property (property_name, out value, pspec, property_node);
+ }
+ value = GLib.Value (typeof(Gee.ArrayList));
+ if (property_node.get_node_type () != Json.NodeType.ARRAY) {
+ warning ("unexpected property node type for 'arguments' %s", property_node.get_node_type ().to_string ());
+ return false;
+ }
+
+ var arguments = new Gee.ArrayList<DocumentSymbol>();
+
+ property_node.get_array ().foreach_element ((array, index, element) => {
+
+ var add= Json.gobject_deserialize ( typeof (DocumentSymbol), array.get_element(index)) as DocumentSymbol;
+ arguments.add( add);
+
+
+ });
+
+ value.set_object (arguments);
+ return true;
+ }
}
public class SymbolInformation : Object {
if (property_name != "tags") {
return default_deserialize_property (property_name, out value, pspec, property_node);
}
+ value = GLib.Value (typeof(Gee.ArrayList));
if (property_node.get_node_type () != Json.NodeType.ARRAY) {
warning ("unexpected property node type for 'arguments' %s", property_node.get_node_type ().to_string ());
return false;
}
});
- value.set_boxed (arguments);
+ value.set_object (arguments);
return true;
}
}
return node;
}
- public bool deserialize_property (string property_name, out GLib.Value value, GLib.ParamSpec pspec, Json.Node property_node) {
+ public bool deserialize_property (string property_name, out GLib.Value value, GLib.ParamSpec pspec, Json.Node property_node)
+ {
if (property_name == "arguments") {
- value = Value (typeof (Array));
+ value = GLib.Value (typeof(Array));
if (property_node.get_node_type () != Json.NodeType.ARRAY) {
warning ("unexpected property node type for 'arguments' %s", property_node.get_node_type ().to_string ());
return false;
public class Diagnostics : Object, Json.Serializable
{
+ public Diagnostics()
+ {
+ this.diagnostics = new Gee.ArrayList<Diagnostic>((a,b) => {
+ return a.equals(b);
+ });
+ }
+
public string uri { get; set; }
public int version { get; set; default = 0; }
public bool deserialize_property (string property_name, out GLib.Value val, GLib.ParamSpec pspec, Json.Node property_node) {
if (property_name == "diagnostics") {
- var diags = new Gee.ArrayList<Diagnostic> ();
+ val = GLib.Value (typeof(Gee.ArrayList));
+ var diags = new Gee.ArrayList<Diagnostic> ((a,b) => {
+ return a.equals(b);
+ });
if (property_node.get_node_type () != Json.NodeType.ARRAY) {
- val = diags;
+ val.set_object(diags);
warning ("unexpected property node type for 'arguments' %s", property_node.get_node_type ().to_string ());
return false;
}
//warning ("argument %u to command could not be deserialized: %s", index, e.message);
});
- val = diags;
+ val.set_object(diags);
return true;
}