X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=src%2FJsRender%2FNode.vala;h=cd101190f84b60f4572a2e350cae2d9021e8df46;hb=HEAD;hp=160da39faa3c5a4493a5d51ca283ea40d81bf9fc;hpb=05534783d6faf7ac0d63ac9dc5a2972534820d25;p=app.Builder.js diff --git a/src/JsRender/Node.vala b/src/JsRender/Node.vala index 160da39fa..cd101190f 100644 --- a/src/JsRender/Node.vala +++ b/src/JsRender/Node.vala @@ -131,53 +131,148 @@ public class JsRender.Node : Object { } public void setNodeLine(int line, Node node) { - print("Add node @ %s\n", line); + //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)b-(int)a; + return (int)a-(int)b; }); } public Node? lineToNode(int line) { - print("Searching for line %d\n",line); + //print("Searching for line %d\n",line); var l = -1; + //foreach(int el in this.node_lines) { + //print("all lines %d\n", el); + //} + + foreach(int el in this.node_lines) { - print("?match %d\n", el); + //print("?match %d\n", el); if (el < line) { l = el; - print("LESS\n"); + //print("LESS\n"); continue; } if (el == line) { - print("SAME\n"); + //print("SAME\n"); l = el; + break; } if (l > -1) { - print("RETURNING NODE ON LINE %d", l); - return this.node_lines_map.get(l); + var ret = this.node_lines_map.get(l); + if (line > ret.line_end) { + return null; + } + //print("RETURNING NODE ON LINE %d", l); + return ret; } return null; } if (l > -1) { - print("RETURNING NODE ON LINE %d", l); - return this.node_lines_map.get(l); + var ret = this.node_lines_map.get(l); + if (line > ret.line_end) { + return null; + } + //print("RETURNING NODE ON LINE %d", l); + return ret; + } return null; } + public string lineToProp(int line) + { + // assume lineToNode called first... + var l = -1; + //foreach(int el in this.lines) { + // //print("all lines %d\n", el); + // + + + foreach(int el in this.lines) { + //print("?match %d\n", el); + if (el < line) { + + l = el; + //print("LESS\n"); + continue; + } + if (el == line) { + //print("SAME\n"); + l = el; + break; + } + if (l > -1) { + //print("RETURNING NODE ON LINE %d", l); + return this.line_map.get(l); + } + return null; + + } + if (l > -1) { + //print("RETURNING NODE ON LINE %d", 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() { @@ -215,7 +310,7 @@ public class JsRender.Node : Object { this.props.set("xtype", ar[ar.length-1]); var l = name.length - (ar[ar.length-1].length +1); this.props.set("$ xns", name.substring(0, l)); - print("setFQN %s to %s\n", name , this.fqn()); + //print("setFQN %s to %s\n", name , this.fqn()); } @@ -286,7 +381,7 @@ public class JsRender.Node : Object { kk+= kkv[i]; } } - print("normalize %s => %s\n", key,string.joinv("=:=",kk)); + //print("normalize %s => %s\n", key,string.joinv("=:=",kk)); switch(kk.length) { case 1: