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 { ...@@ -162,6 +162,8 @@ public class ScriptTreeGraph {
} }
List<AbstractTreeNode> subchild = new ArrayList<>(); List<AbstractTreeNode> subchild = new ArrayList<>();
subchild.add(atn); subchild.add(atn);
//TODO: Hack for double foreach-end recognition
if(atn.getParent() == childlist.get(0).getParent()) return;
childlist.get(0).setChildren(subchild); childlist.get(0).setChildren(subchild);
} }
} }
...@@ -428,7 +430,7 @@ public class ScriptTreeGraph { ...@@ -428,7 +430,7 @@ public class ScriptTreeGraph {
AbstractTreeNode current = mapping.get(n); AbstractTreeNode current = mapping.get(n);
if (current instanceof PlaceholderNode ) { if (current instanceof PlaceholderNode ) {
//TODO : atn.setParent(current.getParent()); -> leads to concurretn exception
current.getParent().setChildren(new ArrayList<>(Arrays.asList(atn))); current.getParent().setChildren(new ArrayList<>(Arrays.asList(atn)));
mapping.put(n, atn); mapping.put(n, atn);
iterator.remove(); iterator.remove();
...@@ -437,11 +439,11 @@ public class ScriptTreeGraph { ...@@ -437,11 +439,11 @@ public class ScriptTreeGraph {
while (!(current instanceof PlaceholderNode)) { while (!(current instanceof PlaceholderNode)) {
//TODO: if(current.getChildren().size() > 0) return;
if (current.getChildren() == null) return; if (current.getChildren() == null) return;
if (current.getChildren().get(0) instanceof PlaceholderNode) { if (current.getChildren().get(0) instanceof PlaceholderNode) {
//TODO: insert a variable instead of using atn?
atn.setParent(current.getChildren().get(0).getParent()); atn.setParent(current.getChildren().get(0).getParent());
current.setChildren(new ArrayList<>(Arrays.asList(atn))); current.setChildren(new ArrayList<>(Arrays.asList(atn)));
iterator.remove(); iterator.remove();
...@@ -484,6 +486,9 @@ public class ScriptTreeGraph { ...@@ -484,6 +486,9 @@ public class ScriptTreeGraph {
} }
} }
/*
checks if given node is the end of a foreach-statement
*/
private void checkIfForeachEnd(Node n) { private void checkIfForeachEnd(Node n) {
if(foreachNodes.containsKey(n)) { if(foreachNodes.containsKey(n)) {
PTreeNode ptn = foreachNodes.get(n); PTreeNode ptn = foreachNodes.get(n);
...@@ -492,8 +497,8 @@ public class ScriptTreeGraph { ...@@ -492,8 +497,8 @@ public class ScriptTreeGraph {
ptn, ptn,
ptn.getStatement().getStartPosition().getLineNumber(), ptn.getStatement().getStartPosition().getLineNumber(),
false); false);
//TODO: replacePlaceholder(nextPtreeNode.getStateBeforeStmt().getSelectedGoalNode().getData().getNode(), ftn);
replacePlaceholder(nextPtreeNode.getStateBeforeStmt().getSelectedGoalNode().getData().getNode(), ftn); replacePlaceholder(n, ftn);
addPlaceholder(ftn, n); addPlaceholder(ftn, n);
foreachNodes.remove(n); foreachNodes.remove(n);
......
...@@ -184,7 +184,7 @@ ...@@ -184,7 +184,7 @@
<MaterialDesignIconView glyphName="TREE" size="24.0"/> <MaterialDesignIconView glyphName="TREE" size="24.0"/>
</graphic> </graphic>
</CheckMenuItem> </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> <graphic>
<ImageView> <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