resources/RooUsage.txt
[app.Builder.js] / src / JsRender / Node.vala
index 5b09f40..cd10119 100644 (file)
@@ -132,18 +132,29 @@ public class JsRender.Node : Object {
        
        public void setNodeLine(int line, Node node) {
                //print("Add node @ %d\n", line);
+               if (this.node_lines_map.has_key(line)) {
+                       return;
+               }
                this.node_lines.add(line);
                this.node_lines_map.set(line, node);
+               
        }
        
        public void setLine(int line, string type, string prop) {
-               this.lines.add(line);
+               if (this.line_map.has_key(line)) {
+                       if  (this.line_map.get(line) != "e:"  ) {
+                               return;
+                       }
+               } else {
+                       this.lines.add(line);
+               }
                this.line_map.set(line, type + ":" + prop);
+               GLib.debug("setLine %d, %s", line, type + ":" + prop);
        }
        public void sortLines() {
                //print("sortLines\n");
                this.lines.sort((a,b) => {   
-                       return (int)b-(int)a;
+                       return (int)a-(int)b;
                });
                this.node_lines.sort((a,b) => {   
                        return (int)a-(int)b;
@@ -172,20 +183,29 @@ public class JsRender.Node : Object {
                                break;
                        }
                        if (l > -1) {
+                               var ret = this.node_lines_map.get(l);
+                               if (line > ret.line_end) {
+                                       return null;
+                               }
                                //print("RETURNING NODE ON LINE %d", l);
-                               return this.node_lines_map.get(l);
+                               return ret;
                        }
                        return null;
                        
                }
                if (l > -1) {
+                       var ret = this.node_lines_map.get(l);
+                       if (line > ret.line_end) {
+                               return null;
+                       }
                        //print("RETURNING NODE ON LINE %d", l);
-                       return this.node_lines_map.get(l);
+                       return ret;
+
                }
                return null;
                
        }
-       public lineToProp(line)
+       public string lineToProp(int line)
        {
                // assume lineToNode called first...
                var l = -1;
@@ -209,19 +229,49 @@ public class JsRender.Node : Object {
                        }
                        if (l > -1) {
                                //print("RETURNING NODE ON LINE %d", l);
-                               return this.lines.get(l);
+                               return this.line_map.get(l);
                        }
                        return null;
                        
                }
                if (l > -1) {
                        //print("RETURNING NODE ON LINE %d", l);
-                       return this.lines.get(l);
+                       return this.line_map.get(l);
                }
                return null;
        
        }
        
+       public bool getPropertyRange(string prop, out int start, out int end)
+       {
+               start = -1;
+               foreach(int el in this.lines) {
+                       if (start < 0) {
+                               if (this.line_map.get(el) == prop) {
+                                       start = el;
+                                       end = el;
+                               }
+                               continue;
+                       }
+                       end = el -1;
+                       break;
+               }
+               return start > -1;
+       
+       
+       }
+       
+       public void dumpProps(string indent = "")
+       {
+               print("%s:\n" , this.fqn());
+               foreach(int el in this.lines) {
+                       print("%d: %s%s\n", el, indent, this.line_map.get(el));
+               }
+               foreach(Node n in this.items) {
+                       n.dumpProps(indent + "  ");
+               }
+       }
+       
        
        
        public string uid()