Fix #8004 - try and fix start line / end line cached node output
[roobuilder] / src / JsRender / Node.vala
index e1cdd2a..eb686e8 100644 (file)
@@ -99,9 +99,9 @@ public class JsRender.Node : GLib.Object {
        private Gee.ArrayList<Node> items; // child items..
        public GLib.ListStore  childstore; // must be kept in sync with items
        public GLib.ListStore?  propstore; // must be kept in sync with items
-       public string  xvala_cls;
-       public string xvala_xcls; // 'Xcls_' + id;
-       public string xvala_id; // item id or ""
+       public string  xvala_cls; // set by node to vala
+       public string xvala_xcls; // 'Xcls_' + id; // set by nodetoVala
+       public string xvala_id; // item id or "" // set by nodetovala
        
        // line markers..
        public int line_start;
@@ -111,6 +111,9 @@ public class JsRender.Node : GLib.Object {
        public Gee.ArrayList<int> node_lines; 
        public Gee.HashMap<int,Node> node_lines_map; // store of l:xxx or p:....
        
+       
+       public string node_pad = "";
+       
        private int _updated_count = 0;
        public int updated_count { 
                get {
@@ -119,11 +122,28 @@ public class JsRender.Node : GLib.Object {
                set  {
                        this.nodeTitleProp = ""; // ?? should trigger set?
                        this.iconFilename = "";
-                       this. _updated_count = value;
+                       this._updated_count = value;
+                               
+                       //GLib.debug("Update Node %d p%d - rev %d", this.oid, this.parent != null ? this.parent.oid : -1, value);
+                       if (this.parent != null) {
+                               this.parent.updated_count++;
+                       }  else {
+                               //GLib.debug("UNDO top node is %d", value);
+                               this.version_changed();
+                       }
                }
  
        } // changes to this trigger updates on the tree..
-
+       
+       public string as_source = "";
+       public int as_source_version = -1;
+       public int as_source_start_line = -1;
+        
+       
+       
+       public signal void  version_changed();
+       
        public Node()
        {
                this.items = new Gee.ArrayList<Node>();
@@ -145,6 +165,20 @@ public class JsRender.Node : GLib.Object {
                
        }
        
+       public bool has_parent(Node n) 
+       {
+               if (this.parent == null) {
+                       return false;
+               }
+               if (this.parent.oid == n.oid) {
+                       return true;
+               }
+               
+
+               return this.parent.has_parent(n);
+       }
+       
+       
        public  Gee.ArrayList<Node> readItems()
        {
                return this.items; // note should not modify add/remove from this directly..
@@ -206,6 +240,7 @@ public class JsRender.Node : GLib.Object {
                
                
                
+               
                //GLib.debug("setLine %d, %s", line, type + ":" + prop);
        }
        public void sortLines() {
@@ -342,7 +377,10 @@ public class JsRender.Node : GLib.Object {
                owned get { return this.fqn(); }
                private set  {}
        }
-       
+       public string NS { // for sorting
+               owned get { return this.props.has_key("xns") ? this.props.get("xns").val  : ""; }
+               private set  {}
+       }
        public string fqn()
        {
                if (!this.hasXnsType ()) {
@@ -418,7 +456,7 @@ public class JsRender.Node : GLib.Object {
                if ( this.parent.childstore.find(this, out pos)) {
                        this.parent.childstore.remove(pos);
                } 
-               
+               this.parent.updated_count++;
                this.parent.items = nlist;
                this.parent = null;
 
@@ -1007,8 +1045,9 @@ public class JsRender.Node : GLib.Object {
        
        public void add_prop(NodeProp prop)
        {
-               if (this.has_prop_key(prop)) {
-                       GLib.error("duplicate key - can not add - call has_prop_key first");
+               if (this.has_prop_key(prop) && !prop.to_index_key().has_suffix("[]")) {
+                       GLib.warning("duplicate key' %s'- can not add - call has_prop_key first", prop.to_index_key());
+                       return;
                }
                prop.parent = this;
                this.propstore.append(prop);