Syntax editor: wrap now handles multiple possible positions for subtree

This commit is contained in:
john.j.camilleri
2012-12-04 15:45:41 +00:00
parent 01cdd10e07
commit 44138ff8ce
2 changed files with 37 additions and 12 deletions

View File

@@ -137,7 +137,8 @@ function AST(fun, cat) {
}
// Wrap the current node inside another node
this.wrap = function(typeobj, childid) {
// Doesn't check whether child_id is within in range
this.wrap = function(typeobj, child_id) {
var subtree = new ASTNode(this.currentNode);
this.currentNode.fun = typeobj.name.join(" ");
this.currentNode.cat = typeobj.ret;
@@ -145,7 +146,7 @@ function AST(fun, cat) {
for (var i in typeobj.args) {
this.add(null, typeobj.args[i]);
}
this.currentNode.children[i] = subtree;
this.currentNode.children[child_id] = subtree;
return subtree;
}