Commit 6098d211 authored by Lulu Luong's avatar Lulu Luong

foreach end fix

parent ee92cd85
Pipeline #28099 passed with stages
in 2 minutes and 50 seconds
......@@ -162,6 +162,8 @@ public class ScriptTreeGraph {
}
List<AbstractTreeNode> subchild = new ArrayList<>();
subchild.add(atn);
//TODO: Hack for double foreach-end recognition
if(atn.getParent() == childlist.get(0).getParent()) return;
childlist.get(0).setChildren(subchild);
}
}
......@@ -428,7 +430,7 @@ public class ScriptTreeGraph {
AbstractTreeNode current = mapping.get(n);
if (current instanceof PlaceholderNode ) {
//TODO : atn.setParent(current.getParent()); -> leads to concurretn exception
current.getParent().setChildren(new ArrayList<>(Arrays.asList(atn)));
mapping.put(n, atn);
iterator.remove();
......@@ -437,11 +439,11 @@ public class ScriptTreeGraph {
while (!(current instanceof PlaceholderNode)) {
//TODO: if(current.getChildren().size() > 0) return;
if (current.getChildren() == null) return;
if (current.getChildren().get(0) instanceof PlaceholderNode) {
//TODO: insert a variable instead of using atn?
atn.setParent(current.getChildren().get(0).getParent());
current.setChildren(new ArrayList<>(Arrays.asList(atn)));
iterator.remove();
......@@ -484,6 +486,9 @@ public class ScriptTreeGraph {
}
}
/*
checks if given node is the end of a foreach-statement
*/
private void checkIfForeachEnd(Node n) {
if(foreachNodes.containsKey(n)) {
PTreeNode ptn = foreachNodes.get(n);
......@@ -492,8 +497,8 @@ public class ScriptTreeGraph {
ptn,
ptn.getStatement().getStartPosition().getLineNumber(),
false);
replacePlaceholder(nextPtreeNode.getStateBeforeStmt().getSelectedGoalNode().getData().getNode(), ftn);
//TODO: replacePlaceholder(nextPtreeNode.getStateBeforeStmt().getSelectedGoalNode().getData().getNode(), ftn);
replacePlaceholder(n, ftn);
addPlaceholder(ftn, n);
foreachNodes.remove(n);
......
......@@ -184,7 +184,7 @@
<MaterialDesignIconView glyphName="TREE" size="24.0"/>
</graphic>
</CheckMenuItem>
<CheckMenuItem fx:id="miScriptTree" onAction="#showScriptTree" text="Show Script Tree">
<CheckMenuItem fx:id="miScriptTree" onAction="#showScriptTree" text="Show Script Tree" accelerator="Ctrl+r">
<graphic>
<ImageView>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment