Commit a006bc8f authored by Alexander Weigl's avatar Alexander Weigl

Merge branch 'master' of git.scc.kit.edu:xt9634/ProofScriptParser

* 'master' of git.scc.kit.edu:xt9634/ProofScriptParser:
  Highlighting of node in proof tree, interactive mode now working a bit better
  Bugfix that removed/expanded nodes were still in state due to selectedGoalNode field
parents 400269f0 fe78f6e4
Pipeline #15280 failed with stages
in 1 minute and 34 seconds
...@@ -2,7 +2,6 @@ package edu.kit.iti.formal.psdbg.interpreter; ...@@ -2,7 +2,6 @@ package edu.kit.iti.formal.psdbg.interpreter;
import com.google.common.collect.BiMap; import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap; import com.google.common.collect.ImmutableBiMap;
import de.uka.ilkd.key.api.ScriptApi;
import de.uka.ilkd.key.api.VariableAssignments; import de.uka.ilkd.key.api.VariableAssignments;
import de.uka.ilkd.key.proof.Node; import de.uka.ilkd.key.proof.Node;
import de.uka.ilkd.key.proof.Proof; import de.uka.ilkd.key.proof.Proof;
...@@ -66,7 +65,7 @@ public class KeyInterpreter extends Interpreter<KeyData> { ...@@ -66,7 +65,7 @@ public class KeyInterpreter extends Interpreter<KeyData> {
} }
} }
//prune proof //prune proof
logger.debug("The closes script " + (allClosed ? "closed the proof.\n" : "did not close the proof.\n") + "Rolling Back proof now."); LOGGER.debug("The closes script " + (allClosed ? "closed the proof.\n" : "did not close the proof.\n") + "Rolling Back proof now.");
Proof currentKeYproof = selectedGoalNode.getData().getProof(); Proof currentKeYproof = selectedGoalNode.getData().getProof();
ImmutableList<Goal> subtreeGoals = currentKeYproof.getSubtreeGoals(((KeyData) selectedGoalNode.getData()).getNode()); ImmutableList<Goal> subtreeGoals = currentKeYproof.getSubtreeGoals(((KeyData) selectedGoalNode.getData()).getNode());
currentKeYproof.pruneProof(selectedGoalCopy.getData().getNode()); currentKeYproof.pruneProof(selectedGoalCopy.getData().getNode());
......
...@@ -15,6 +15,8 @@ import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment; ...@@ -15,6 +15,8 @@ import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment;
import edu.kit.iti.formal.psdbg.parser.ast.CallStatement; import edu.kit.iti.formal.psdbg.parser.ast.CallStatement;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableList;
import java.util.Collection; import java.util.Collection;
...@@ -28,6 +30,8 @@ import java.util.Map; ...@@ -28,6 +30,8 @@ import java.util.Map;
*/ */
@RequiredArgsConstructor @RequiredArgsConstructor
public class MacroCommandHandler implements CommandHandler<KeyData> { public class MacroCommandHandler implements CommandHandler<KeyData> {
protected static Logger LOGGER = LogManager.getLogger(MacroCommandHandler.class);
@Getter @Getter
private final Map<String, ProofMacro> macros; private final Map<String, ProofMacro> macros;
...@@ -57,6 +61,7 @@ public class MacroCommandHandler implements CommandHandler<KeyData> { ...@@ -57,6 +61,7 @@ public class MacroCommandHandler implements CommandHandler<KeyData> {
State<KeyData> state = interpreter.getCurrentState(); State<KeyData> state = interpreter.getCurrentState();
GoalNode<KeyData> expandedNode = state.getSelectedGoalNode(); GoalNode<KeyData> expandedNode = state.getSelectedGoalNode();
assert state.getGoals().contains(expandedNode);
try { try {
...@@ -67,6 +72,8 @@ public class MacroCommandHandler implements CommandHandler<KeyData> { ...@@ -67,6 +72,8 @@ public class MacroCommandHandler implements CommandHandler<KeyData> {
ImmutableList<Goal> ngoals = expandedNode.getData().getProof().getSubtreeGoals(expandedNode.getData().getNode()); ImmutableList<Goal> ngoals = expandedNode.getData().getProof().getSubtreeGoals(expandedNode.getData().getNode());
state.getGoals().remove(expandedNode); state.getGoals().remove(expandedNode);
state.setSelectedGoalNode(null);
if (ngoals.isEmpty()) { if (ngoals.isEmpty()) {
Node start = expandedNode.getData().getNode(); Node start = expandedNode.getData().getNode();
//start.leavesIterator() //start.leavesIterator()
...@@ -74,7 +81,7 @@ public class MacroCommandHandler implements CommandHandler<KeyData> { ...@@ -74,7 +81,7 @@ public class MacroCommandHandler implements CommandHandler<KeyData> {
Iterator<Node> nodeIterator = start.leavesIterator(); Iterator<Node> nodeIterator = start.leavesIterator();
while (nodeIterator.hasNext()) { while (nodeIterator.hasNext()) {
Node n = nodeIterator.next(); Node n = nodeIterator.next();
System.out.println(n.isClosed()); LOGGER.error(n.isClosed());
} }
} else { } else {
...@@ -83,6 +90,9 @@ public class MacroCommandHandler implements CommandHandler<KeyData> { ...@@ -83,6 +90,9 @@ public class MacroCommandHandler implements CommandHandler<KeyData> {
KeyData kdn = new KeyData(expandedNode.getData(), g.node()); KeyData kdn = new KeyData(expandedNode.getData(), g.node());
state.getGoals().add(new GoalNode<>(expandedNode, kdn, kdn.isClosedNode())); state.getGoals().add(new GoalNode<>(expandedNode, kdn, kdn.isClosedNode()));
} }
assert !state.getGoals().contains(expandedNode);
} }
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
......
...@@ -15,6 +15,8 @@ import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment; ...@@ -15,6 +15,8 @@ import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment;
import edu.kit.iti.formal.psdbg.parser.ast.CallStatement; import edu.kit.iti.formal.psdbg.parser.ast.CallStatement;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.key_project.util.collection.ImmutableList; import org.key_project.util.collection.ImmutableList;
import java.util.Collection; import java.util.Collection;
...@@ -30,6 +32,8 @@ import java.util.Map; ...@@ -30,6 +32,8 @@ import java.util.Map;
*/ */
@RequiredArgsConstructor @RequiredArgsConstructor
public class ProofScriptCommandBuilder implements CommandHandler<KeyData> { public class ProofScriptCommandBuilder implements CommandHandler<KeyData> {
protected static Logger LOGGER = LogManager.getLogger(ProofScriptCommandBuilder.class);
@Getter @Getter
private final Map<String, ProofScriptCommand> commands; private final Map<String, ProofScriptCommand> commands;
...@@ -65,7 +69,10 @@ public class ProofScriptCommandBuilder implements CommandHandler<KeyData> { ...@@ -65,7 +69,10 @@ public class ProofScriptCommandBuilder implements CommandHandler<KeyData> {
AbstractUserInterfaceControl uiControl = new DefaultUserInterfaceControl(); AbstractUserInterfaceControl uiControl = new DefaultUserInterfaceControl();
c.execute(uiControl, cc, estate); c.execute(uiControl, cc, estate);
//what happens if this is empty -> meaning proof is closed //what happens if this is empty -> meaning proof is closed
state.getGoals().remove(expandedNode);
if (state.getSelectedGoalNode().equals(expandedNode)) {
state.setSelectedGoalNode(null);
}
ImmutableList<Goal> ngoals = kd.getProof().getSubtreeGoals(kd.getNode()); ImmutableList<Goal> ngoals = kd.getProof().getSubtreeGoals(kd.getNode());
if (ngoals.isEmpty()) { if (ngoals.isEmpty()) {
Node start = expandedNode.getData().getNode(); Node start = expandedNode.getData().getNode();
...@@ -74,7 +81,7 @@ public class ProofScriptCommandBuilder implements CommandHandler<KeyData> { ...@@ -74,7 +81,7 @@ public class ProofScriptCommandBuilder implements CommandHandler<KeyData> {
Iterator<Node> nodeIterator = start.leavesIterator(); Iterator<Node> nodeIterator = start.leavesIterator();
while (nodeIterator.hasNext()) { while (nodeIterator.hasNext()) {
Node n = nodeIterator.next(); Node n = nodeIterator.next();
System.out.println(n.isClosed()); LOGGER.error(n.isClosed());
} }
} else { } else {
...@@ -83,7 +90,7 @@ public class ProofScriptCommandBuilder implements CommandHandler<KeyData> { ...@@ -83,7 +90,7 @@ public class ProofScriptCommandBuilder implements CommandHandler<KeyData> {
state.getGoals().add(new GoalNode<>(expandedNode, kdn, kdn.isClosedNode())); state.getGoals().add(new GoalNode<>(expandedNode, kdn, kdn.isClosedNode()));
} }
} }
state.getGoals().remove(expandedNode);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
......
...@@ -68,6 +68,9 @@ public class RuleCommandHandler implements CommandHandler<KeyData> { ...@@ -68,6 +68,9 @@ public class RuleCommandHandler implements CommandHandler<KeyData> {
ImmutableList<Goal> ngoals = kd.getProof().getSubtreeGoals(kd.getNode()); ImmutableList<Goal> ngoals = kd.getProof().getSubtreeGoals(kd.getNode());
state.getGoals().remove(expandedNode); state.getGoals().remove(expandedNode);
if (state.getSelectedGoalNode().equals(expandedNode)) {
state.setSelectedGoalNode(null);
}
for (Goal g : ngoals) { for (Goal g : ngoals) {
KeyData kdn = new KeyData(kd, g.node()); KeyData kdn = new KeyData(kd, g.node());
state.getGoals().add(new GoalNode<>(expandedNode, kdn, kdn.getNode().isClosed())); state.getGoals().add(new GoalNode<>(expandedNode, kdn, kdn.getNode().isClosed()));
......
...@@ -221,6 +221,9 @@ public class Interpreter<T> extends DefaultASTVisitor<Object> ...@@ -221,6 +221,9 @@ public class Interpreter<T> extends DefaultASTVisitor<Object>
} }
State<T> stateAfterCase = popState(); //remove state from stack State<T> stateAfterCase = popState(); //remove state from stack
if (stateAfterCase.getSelectedGoalNode() != null) {
assert stateAfterCase.getGoals().contains(stateAfterCase.getSelectedGoalNode());
}
if (result && stateAfterCase.getGoals() != null) { if (result && stateAfterCase.getGoals() != null) {
resultingGoals.addAll(stateAfterCase.getGoals()); resultingGoals.addAll(stateAfterCase.getGoals());
...@@ -273,6 +276,7 @@ public class Interpreter<T> extends DefaultASTVisitor<Object> ...@@ -273,6 +276,7 @@ public class Interpreter<T> extends DefaultASTVisitor<Object>
Expression matchExpression = guardedCaseStatement.getGuard(); Expression matchExpression = guardedCaseStatement.getGuard();
State<T> currentStateToMatch = peekState(); State<T> currentStateToMatch = peekState();
GoalNode<T> selectedGoal = currentStateToMatch.getSelectedGoalNode(); GoalNode<T> selectedGoal = currentStateToMatch.getSelectedGoalNode();
assert currentStateToMatch.getGoals().contains(selectedGoal);
VariableAssignment va = evaluateMatchInGoal(matchExpression, selectedGoal); VariableAssignment va = evaluateMatchInGoal(matchExpression, selectedGoal);
try { try {
...@@ -510,6 +514,7 @@ public class Interpreter<T> extends DefaultASTVisitor<Object> ...@@ -510,6 +514,7 @@ public class Interpreter<T> extends DefaultASTVisitor<Object>
enterScope(caseStmts); enterScope(caseStmts);
goalNode.enterScope(va); goalNode.enterScope(va);
State<T> s = newState(goalNode); State<T> s = newState(goalNode);
assert s.getGoals().contains(s.getSelectedGoalNode());
caseStmts.accept(this); caseStmts.accept(this);
//popState(s); //This may be incorrect-> Bug? -> Cases Statement needs to pop, as goals need to be collected //popState(s); //This may be incorrect-> Bug? -> Cases Statement needs to pop, as goals need to be collected
exitScope(caseStmts); exitScope(caseStmts);
...@@ -644,7 +649,11 @@ public class Interpreter<T> extends DefaultASTVisitor<Object> ...@@ -644,7 +649,11 @@ public class Interpreter<T> extends DefaultASTVisitor<Object>
//region State Handling //region State Handling
public GoalNode<T> getSelectedNode() { public GoalNode<T> getSelectedNode() {
try { try {
return stateStack.peek().getSelectedGoalNode(); GoalNode<T> selectedGoalNode = stateStack.peek().getSelectedGoalNode();
if (selectedGoalNode != null) {
assert stateStack.peek().getGoals().contains(selectedGoalNode);
}
return selectedGoalNode;
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
if (scrictSelectedGoalMode) if (scrictSelectedGoalMode)
throw e; throw e;
......
...@@ -79,10 +79,6 @@ public class State<T> { ...@@ -79,10 +79,6 @@ public class State<T> {
return new State<T>(copiedGoals, refToSelGoal); return new State<T>(copiedGoals, refToSelGoal);
} }
public void setSelectedGoalNode(GoalNode<T> gn) {
this.selectedGoalNode = gn;
}
public GoalNode<T> getSelectedGoalNode() { public GoalNode<T> getSelectedGoalNode() {
/* if (selectedGoalNode == null) { /* if (selectedGoalNode == null) {
throw new IllegalStateException("no selected node"); throw new IllegalStateException("no selected node");
...@@ -96,9 +92,17 @@ public class State<T> { ...@@ -96,9 +92,17 @@ public class State<T> {
if (getGoals().size() == 1) { if (getGoals().size() == 1) {
selectedGoalNode = getGoals().get(0); selectedGoalNode = getGoals().get(0);
} }
return selectedGoalNode; return selectedGoalNode;
} }
public void setSelectedGoalNode(GoalNode<T> gn) {
if (gn != null) {
assert goals.contains(gn);
}
this.selectedGoalNode = gn;
}
public String toString() { public String toString() {
if (selectedGoalNode == null) { if (selectedGoalNode == null) {
return "No Goal selected"; return "No Goal selected";
......
...@@ -103,7 +103,7 @@ public class ProofScriptDebugger extends Application { ...@@ -103,7 +103,7 @@ public class ProofScriptDebugger extends Application {
logger.info("KeY: " + KeYConstants.COPYRIGHT); logger.info("KeY: " + KeYConstants.COPYRIGHT);
logger.info("KeY Version: " + KeYConstants.VERSION); logger.info("KeY Version: " + KeYConstants.VERSION);
logger.info("KeY Internal: " + KeYConstants.INTERNAL_VERSION); logger.info("KeY Internal: " + KeYConstants.INTERNAL_VERSION);
//logger.error("sfklsajflksajfsdajfsdalfjsdaf", new IllegalAccessError("dlfsdalfjsadflj")); //LOGGER.error("sfklsajflksajfsdajfsdalfjsdaf", new IllegalAccessError("dlfsdalfjsadflj"));
} catch (Exception e) { } catch (Exception e) {
......
...@@ -26,6 +26,7 @@ import edu.kit.iti.formal.psdbg.interpreter.KeYProofFacade; ...@@ -26,6 +26,7 @@ import edu.kit.iti.formal.psdbg.interpreter.KeYProofFacade;
import edu.kit.iti.formal.psdbg.interpreter.KeyInterpreter; import edu.kit.iti.formal.psdbg.interpreter.KeyInterpreter;
import edu.kit.iti.formal.psdbg.interpreter.data.GoalNode; import edu.kit.iti.formal.psdbg.interpreter.data.GoalNode;
import edu.kit.iti.formal.psdbg.interpreter.data.KeyData; import edu.kit.iti.formal.psdbg.interpreter.data.KeyData;
import edu.kit.iti.formal.psdbg.interpreter.data.State;
import edu.kit.iti.formal.psdbg.interpreter.dbg.*; import edu.kit.iti.formal.psdbg.interpreter.dbg.*;
import edu.kit.iti.formal.psdbg.parser.ast.ProofScript; import edu.kit.iti.formal.psdbg.parser.ast.ProofScript;
import javafx.application.Platform; import javafx.application.Platform;
...@@ -80,10 +81,14 @@ public class DebuggerMain implements Initializable { ...@@ -80,10 +81,14 @@ public class DebuggerMain implements Initializable {
protected static final Logger LOGGER = LogManager.getLogger(DebuggerMain.class); protected static final Logger LOGGER = LogManager.getLogger(DebuggerMain.class);
public final ContractLoaderService contractLoaderService = new ContractLoaderService(); public final ContractLoaderService contractLoaderService = new ContractLoaderService();
private InspectionViewsController inspectionViewsController;
private final ExecutorService executorService = Executors.newFixedThreadPool(2); private final ExecutorService executorService = Executors.newFixedThreadPool(2);
@Getter @Getter
private final DebuggerMainModel model = new DebuggerMainModel(); private final DebuggerMainModel model = new DebuggerMainModel();
private InspectionViewsController inspectionViewsController;
private ScriptController scriptController; private ScriptController scriptController;
@FXML @FXML
...@@ -123,7 +128,7 @@ public class DebuggerMain implements Initializable { ...@@ -123,7 +128,7 @@ public class DebuggerMain implements Initializable {
private CheckMenuItem miProofTree; private CheckMenuItem miProofTree;
@FXML @FXML
private ToggleButton btnIM; private ToggleButton btnInteractiveMode;
private JavaArea javaArea = new JavaArea(); private JavaArea javaArea = new JavaArea();
...@@ -194,6 +199,7 @@ public class DebuggerMain implements Initializable { ...@@ -194,6 +199,7 @@ public class DebuggerMain implements Initializable {
model.setDebugMode(false); model.setDebugMode(false);
scriptController = new ScriptController(dockStation); scriptController = new ScriptController(dockStation);
interactiveModeController = new InteractiveModeController(scriptController); interactiveModeController = new InteractiveModeController(scriptController);
btnInteractiveMode.setSelected(false);
inspectionViewsController = new InspectionViewsController(dockStation); inspectionViewsController = new InspectionViewsController(dockStation);
activeInspectorDock = inspectionViewsController.getActiveInterpreterTabDock(); activeInspectorDock = inspectionViewsController.getActiveInterpreterTabDock();
//register the welcome dock in the center //register the welcome dock in the center
...@@ -857,15 +863,16 @@ public class DebuggerMain implements Initializable { ...@@ -857,15 +863,16 @@ public class DebuggerMain implements Initializable {
@FXML @FXML
public void interactiveMode(ActionEvent actionEvent) { public void interactiveMode(ActionEvent actionEvent) {
if (btnIM.isSelected()) { if (btnInteractiveMode.isSelected()) {
interactiveModeController.stop();
} else {
interactiveModeController.setActivated(true); interactiveModeController.setActivated(true);
interactiveModeController.start(getFacade().getProof(), getInspectionViewsController().getActiveInspectionViewTab().getModel()); interactiveModeController.start(getFacade().getProof(), getInspectionViewsController().getActiveInspectionViewTab().getModel());
} } else {
interactiveModeController.stop();
}
} }
}
@FXML @FXML
public void showWelcomeDock(ActionEvent actionEvent) { public void showWelcomeDock(ActionEvent actionEvent) {
if (!welcomePaneDock.isDocked() && !welcomePaneDock.isFloating()) { if (!welcomePaneDock.isDocked() && !welcomePaneDock.isFloating()) {
......
...@@ -67,7 +67,7 @@ public class InteractiveModeController { ...@@ -67,7 +67,7 @@ public class InteractiveModeController {
public void stop() { public void stop() {
Events.unregister(this); Events.unregister(this);
String c = getCasesAsString(); String c = getCasesAsString();
scriptController.getDockNode(scriptArea).undock(); scriptController.getDockNode(scripundocktArea).undock();
Events.fire(new Events.InsertAtTheEndOfMainScript(c)); Events.fire(new Events.InsertAtTheEndOfMainScript(c));
} }
......
...@@ -309,17 +309,19 @@ public class ProofTree extends BorderPane { ...@@ -309,17 +309,19 @@ public class ProofTree extends BorderPane {
} }
if (n.childrenCount() == 0) { if (n.childrenCount() == 0) {
ti.getChildren().add(new TreeItem<>(new TreeNode( TreeItem<TreeNode> e = new TreeItem<>(new TreeNode(
n.isClosed() ? "CLOSED GOAL" : "OPEN GOAL", null))); n.isClosed() ? "CLOSED GOAL" : "OPEN GOAL", null));
ti.getChildren().add(e);
return ti; return ti;
} }
Node node = n.child(0); Node node = n.child(0);
if (n.childrenCount() == 1) { if (n.childrenCount() == 1) {
ti.getChildren().add(new TreeItem<>(new TreeNode(toString(node), node))); ti.getChildren().add(new TreeItem<>(new TreeNode(node.serialNr() + ": " + toString(node), node)));
while (node.childrenCount() == 1) { while (node.childrenCount() == 1) {
node = node.child(0); node = node.child(0);
ti.getChildren().add(new TreeItem<>(new TreeNode(toString(node), node))); ti.getChildren().add(new TreeItem<>(new TreeNode(node.serialNr() + ": " + toString(node), node)));
} }
} }
...@@ -364,20 +366,24 @@ public class ProofTree extends BorderPane { ...@@ -364,20 +366,24 @@ public class ProofTree extends BorderPane {
} }
}; };
tftc.setConverter(stringConverter); tftc.setConverter(stringConverter);
tftc.itemProperty().addListener((p, o, n) -> {
//tftc.itemProperty().addListener((p, o, n) -> repaint(tftc)); if (n != null)
repaint(tftc);
});
//colorOfNodes.addListener((InvalidationListener) o -> repaint(tftc)); //colorOfNodes.addListener((InvalidationListener) o -> repaint(tftc));
return tftc; return tftc;
} }
/*private void repaint(TextFieldTreeCell<TreeNode> tftc) { private void repaint(TextFieldTreeCell<TreeNode> tftc) {
Node n = tftc.getItem().node; Node n = tftc.getItem().node;
tftc.setStyle(""); tftc.setStyle("");
if (n != null) { if (n != null && n.leaf()) {
if (n.isClosed()) { if (n.isClosed()) {
colorOfNodes.putIfAbsent(n, "green"); colorOfNodes.putIfAbsent(n, "seagreen");
//tftc.setStyle("-fx-background-color: greenyellow"); //tftc.setStyle("-fx-background-color: greenyellow");
} else {
colorOfNodes.putIfAbsent(n, "darkred");
} }
if (colorOfNodes.containsKey(n)) { if (colorOfNodes.containsKey(n)) {
tftc.setStyle("-fx-background-color: " + colorOfNodes.get(n) + ";"); tftc.setStyle("-fx-background-color: " + colorOfNodes.get(n) + ";");
...@@ -385,7 +391,7 @@ public class ProofTree extends BorderPane { ...@@ -385,7 +391,7 @@ public class ProofTree extends BorderPane {
} }
expandRootToItem(tftc.getTreeItem()); expandRootToItem(tftc.getTreeItem());
}*/ }
public Object getColorOfNodes() { public Object getColorOfNodes() {
return colorOfNodes.get(); return colorOfNodes.get();
......
...@@ -15,8 +15,6 @@ import javafx.beans.value.ChangeListener; ...@@ -15,8 +15,6 @@ import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue; import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections; import javafx.collections.FXCollections;
import javafx.collections.ObservableMap; import javafx.collections.ObservableMap;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.CharStreams;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
...@@ -122,6 +120,7 @@ public class ScriptController { ...@@ -122,6 +120,7 @@ public class ScriptController {
return getDockNode(findEditor(filepath)); return getDockNode(findEditor(filepath));
} }
<<<<<<< HEAD
public DockNode getDockNode(ScriptArea editor) { public DockNode getDockNode(ScriptArea editor) {
if (editor == null) { if (editor == null) {
return null; return null;
...@@ -162,6 +161,8 @@ public class ScriptController { ...@@ -162,6 +161,8 @@ public class ScriptController {
} }
} }
=======
>>>>>>> fe78f6e478dd00993310329ee09e52cb3af7a516
/** /**
* Create new DockNode for ScriptArea Tab * Create new DockNode for ScriptArea Tab
* *
...@@ -200,6 +201,46 @@ public class ScriptController { ...@@ -200,6 +201,46 @@ public class ScriptController {
return dockNode; return dockNode;
} }
/**
* Create a new Tab in the ScriptTabPane containing the contents of the file given as argument
*
* @param filePath to file that should be loaded to new tab
* @return refernce to new scriptArea in new tab
* @throws IOException if an Exception occurs while loading file
*/
public ScriptArea createNewTab(File filePath) throws IOException {
filePath = filePath.getAbsoluteFile();
if (findEditor(filePath) == null) {
ScriptArea area = new ScriptArea();
area.mainScriptProperty().bindBidirectional(mainScript);
area.setFilePath(filePath);
DockNode dockNode = createDockNode(area);
openScripts.put(area, dockNode);
if (filePath.exists()) {
String code = FileUtils.readFileToString(filePath, "utf-8");
if (!area.textProperty().getValue().isEmpty()) {
area.deleteText(0, area.textProperty().getValue().length());
}
area.setText(code);
}
return area;
} else {
logger.info("File already exists. Will not load it again");
ScriptArea area = findEditor(filePath);
return area;
}
}
public DockNode getDockNode(ScriptArea editor) {
if (editor == null) {
return null;
}
return openScripts.get(editor);
}
/** /**
* Get all breakpoints in the current area * Get all breakpoints in the current area
* *
......
...@@ -6,15 +6,25 @@ script test(){ ...@@ -6,15 +6,25 @@ script test(){
exLeft; exLeft;
andLeft; andLeft;
eqSymm formula = `agatha = butler`; eqSymm formula = `agatha = butler`;
nnf_imp2or formula=`\foral S w6;(hates(agatha,w6) -> hates(butler,w6))`; nnf_imp2or formula=`\forall S w6;(hates(agatha,w6) -> hates(butler,w6))`;
} }
script SolveAgathaRiddle_1() { script SolveAgathaRiddle_1() {
impRight; impRight;
andLeft; andLeft;
notLeft; notLeft;
repeat { andLeft; }
exLeft;
andLeft;
eqSymm formula = `agatha = butler`;
auto;
}
script SolveAgathaRiddle_2() {
impRight;
andLeft;
notLeft;
andLeft;