Fix #8076 - gtknotebookpage fake wrapper
[roobuilder] / src / Lsp.vala
index d13b916..fb2dae7 100644 (file)
@@ -83,7 +83,10 @@ namespace Lsp {
                  (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";
         }
@@ -148,7 +151,7 @@ namespace Lsp {
 
         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 == o.start && this.end == o.end;
+                       return this.filename == o.filename && this.start.equals(o.start) && this.end.equals(o.end);
                }
 
         public int compare_to (Range other) {
@@ -229,7 +232,11 @@ namespace Lsp {
                
         }
         public bool equals(Lsp.Diagnostic o) {
-               return this.range.equals(o.range) && this.severity == o.severity && this.message == o.message;
+                       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()
         {
@@ -862,6 +869,12 @@ namespace Lsp {
     }
 
    public  class MarkedString : Object {
+               public MarkedString(string language, string value) 
+               {
+                       this.language = language;
+                       this.value = value;
+                       GLib.debug("new marked string %s : %s", language, value);
+               }
         public string language { get; set; }
         public string value { get; set; }
     }
@@ -899,8 +912,33 @@ namespace Lsp {
             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 == "contents") {
+                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 contents = new Gee.ArrayList<MarkedString>();
+
+                       property_node.get_array ().foreach_element ((array, index, element) => {
+                               try {
+                                               var add = new MarkedString(
+                                                       array.get_object_element(index).get_string_member("language"),
+                                                       array.get_object_element(index).get_string_member("value")
+                                               );
+                            
+                               contents.add ( add );
+                           } catch (Error e) {
+                               warning ("argument %u to command could not be deserialized: %s", index, e.message);
+                           }
+                       });
+                value.set_object (contents);
+                       return true;
+            } 
+            
+            return default_deserialize_property (property_name, out value, pspec, property_node);
         }
     }