Commit f905acf7 authored by Sarah Grebing's avatar Sarah Grebing

bug fix

parent 9ab25960
Pipeline #13316 failed with stage
in 10 seconds
...@@ -236,7 +236,7 @@ public class Interpreter<T> extends DefaultASTVisitor<Object> ...@@ -236,7 +236,7 @@ public class Interpreter<T> extends DefaultASTVisitor<Object>
return null; return null;
} }
/* @Override @Override
public Object visit(SimpleCaseStatement simpleCaseStatement) { public Object visit(SimpleCaseStatement simpleCaseStatement) {
Expression matchExpression = simpleCaseStatement.getGuard(); Expression matchExpression = simpleCaseStatement.getGuard();
State<T> currentStateToMatch = peekState(); State<T> currentStateToMatch = peekState();
...@@ -250,7 +250,7 @@ public class Interpreter<T> extends DefaultASTVisitor<Object> ...@@ -250,7 +250,7 @@ public class Interpreter<T> extends DefaultASTVisitor<Object>
} else { } else {
return false; return false;
} }
}*/ }
@Override @Override
public Object visit(TryCase TryCase) { public Object visit(TryCase TryCase) {
......
...@@ -58,21 +58,6 @@ public class State<T> { ...@@ -58,21 +58,6 @@ public class State<T> {
return goals; return goals;
} }
public GoalNode<T> getSelectedGoalNode() {
if (selectedGoalNode == null) {
throw new IllegalStateException("no selected node");
} else {
if (getGoals().size() == 1) {
selectedGoalNode = getGoals().get(0);
}
return selectedGoalNode;
}
}
public void setSelectedGoalNode(GoalNode<T> gn) {
this.selectedGoalNode = gn;
}
/** /**
* Deep Copy state * Deep Copy state
* *
...@@ -81,17 +66,43 @@ public class State<T> { ...@@ -81,17 +66,43 @@ public class State<T> {
public State<T> copy() { public State<T> copy() {
List<GoalNode<T>> copiedGoals = new ArrayList<>(); List<GoalNode<T>> copiedGoals = new ArrayList<>();
GoalNode<T> refToSelGoal = null; GoalNode<T> refToSelGoal = null;
if (goals.size() == 1) {
for (GoalNode<T> goal : goals) { GoalNode<T> deepcopy = goals.get(0).deepCopy();
GoalNode<T> deepcopy = goal.deepCopy(); refToSelGoal = deepcopy;
copiedGoals.add(deepcopy); copiedGoals.add(deepcopy);
if (goal.equals(getSelectedGoalNode())) { } else {
refToSelGoal = deepcopy; for (GoalNode<T> goal : goals) {
GoalNode<T> deepcopy = goal.deepCopy();
copiedGoals.add(deepcopy);
if (selectedGoalNode != null && goal.equals(getSelectedGoalNode())) {
refToSelGoal = deepcopy;
}
} }
} }
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() {
/* if (selectedGoalNode == null) {
throw new IllegalStateException("no selected node");
} else {
if (getGoals().size() == 1) {
selectedGoalNode = getGoals().get(0);
}
return selectedGoalNode;
}*/
if (getGoals().size() == 1) {
selectedGoalNode = getGoals().get(0);
}
return selectedGoalNode;
}
public String toString() { public String toString() {
if (selectedGoalNode == null) { if (selectedGoalNode == null) {
return "No Goal selected"; return "No Goal selected";
......
...@@ -9,7 +9,6 @@ import edu.kit.iti.formal.psdbg.interpreter.data.GoalNode; ...@@ -9,7 +9,6 @@ import edu.kit.iti.formal.psdbg.interpreter.data.GoalNode;
import edu.kit.iti.formal.psdbg.interpreter.data.State; import edu.kit.iti.formal.psdbg.interpreter.data.State;
import edu.kit.iti.formal.psdbg.interpreter.exceptions.StateGraphException; import edu.kit.iti.formal.psdbg.interpreter.exceptions.StateGraphException;
import edu.kit.iti.formal.psdbg.parser.DefaultASTVisitor; import edu.kit.iti.formal.psdbg.parser.DefaultASTVisitor;
import edu.kit.iti.formal.psdbg.parser.Visitor;
import edu.kit.iti.formal.psdbg.parser.ast.*; import edu.kit.iti.formal.psdbg.parser.ast.*;
import javafx.application.Platform; import javafx.application.Platform;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
...@@ -269,6 +268,7 @@ public class StateGraphWrapper<T> { ...@@ -269,6 +268,7 @@ public class StateGraphWrapper<T> {
changeListeners.forEach(list -> { changeListeners.forEach(list -> {
Platform.runLater(() -> { Platform.runLater(() -> {
list.graphChanged(nodeAddedEvent); list.graphChanged(nodeAddedEvent);
System.out.println("New StateGraphChange " + this.asdot());
}); });
}); });
...@@ -310,11 +310,11 @@ public class StateGraphWrapper<T> { ...@@ -310,11 +310,11 @@ public class StateGraphWrapper<T> {
return createNewNode(casesStatement); return createNewNode(casesStatement);
} }
@Override /* @Override
public Void visit(CaseStatement caseStatement) { public Void visit(CaseStatement caseStatement) {
return createNewNode(caseStatement); return createNewNode(caseStatement);
} }
*/
@Override @Override
public Void visit(CallStatement call) { public Void visit(CallStatement call) {
return createNewNode(call); return createNewNode(call);
...@@ -334,6 +334,21 @@ public class StateGraphWrapper<T> { ...@@ -334,6 +334,21 @@ public class StateGraphWrapper<T> {
public Void visit(RepeatStatement repeatStatement) { public Void visit(RepeatStatement repeatStatement) {
return createNewNode(repeatStatement); return createNewNode(repeatStatement);
} }
@Override
public Void visit(TryCase tryCase) {
return createNewNode(tryCase);
}
@Override
public Void visit(SimpleCaseStatement simpleCaseStatement) {
return createNewNode(simpleCaseStatement);
}
@Override
public Void visit(ClosesCase closesCase) {
return createNewNode(closesCase);
}
} }
private class ExitListener extends DefaultASTVisitor<Void> { private class ExitListener extends DefaultASTVisitor<Void> {
...@@ -347,10 +362,10 @@ public class StateGraphWrapper<T> { ...@@ -347,10 +362,10 @@ public class StateGraphWrapper<T> {
return addState(casesStatement); return addState(casesStatement);
} }
@Override /*@Override
public Void visit(CaseStatement caseStatement) { public Void visit(CaseStatement caseStatement) {
return addState(caseStatement); return addState(caseStatement);
} }*/
@Override @Override
public Void visit(CallStatement call) { public Void visit(CallStatement call) {
...@@ -372,6 +387,20 @@ public class StateGraphWrapper<T> { ...@@ -372,6 +387,20 @@ public class StateGraphWrapper<T> {
return addState(repeatStatement); return addState(repeatStatement);
} }
@Override
public Void visit(TryCase tryCase) {
return addState(tryCase);
}
@Override
public Void visit(SimpleCaseStatement simpleCaseStatement) {
return addState(simpleCaseStatement);
}
@Override
public Void visit(ClosesCase closesCase) {
return addState(closesCase);
}
/* @Override /* @Override
public Void visit(ProofScript proofScript) { public Void visit(ProofScript proofScript) {
return addState(proofScript); return addState(proofScript);
......
...@@ -69,7 +69,7 @@ public class InterpretingService extends Service<State<KeyData>> { ...@@ -69,7 +69,7 @@ public class InterpretingService extends Service<State<KeyData>> {
//check state for empty/error goal nodes //check state for empty/error goal nodes
//currentGoals.set(state.getGoals()); //currentGoals.set(state.getGoals());
//currentSelectedGoal.set(state.getSelectedGoalNode()); //currentSelectedGoal.set(state.getSelectedGoalNode());
System.out.println("Updating View");
blocker.publishState(); blocker.publishState();
} }
......
...@@ -13,6 +13,12 @@ import java.nio.charset.Charset; ...@@ -13,6 +13,12 @@ import java.nio.charset.Charset;
* @author Alexander Weigl * @author Alexander Weigl
*/ */
public class JavaExample extends Example { public class JavaExample extends Example {
public void setJavaFile(URL javaFile) {
this.javaFile = javaFile;
}
protected URL javaFile; protected URL javaFile;
@Override @Override
...@@ -23,9 +29,12 @@ public class JavaExample extends Example { ...@@ -23,9 +29,12 @@ public class JavaExample extends Example {
try { try {
File script = newTempFile(scriptFile, getName() + ".kps"); File script = newTempFile(scriptFile, getName() + ".kps");
debuggerMain.openScript(script); debuggerMain.openScript(script);
File key = newTempFile(keyFile, "problem.key");
//File key = newTempFile(keyFile, "project.key");
File java = newTempFile(javaFile, getName() + ".java"); File java = newTempFile(javaFile, getName() + ".java");
debuggerMain.openKeyFile(key); //System.out.println(java.getAbsolutePath());
//debuggerMain.openKeyFile(key);
debuggerMain.openJavaFile(java);
if (helpText != null) { if (helpText != null) {
String content = IOUtils.toString(helpText, Charset.defaultCharset()); String content = IOUtils.toString(helpText, Charset.defaultCharset());
debuggerMain.openNewHelpDock(getName() + " Example", content); debuggerMain.openNewHelpDock(getName() + " Example", content);
......
package edu.kit.iti.formal.psdbg.examples.java;
import edu.kit.iti.formal.psdbg.examples.JavaExample;
public class JavaSimpleExample extends JavaExample {
public JavaSimpleExample() {
setName("Test");
setJavaFile(this.getClass().getResource("Test.java"));
defaultInit(getClass());
System.out.println(this);
}
}
...@@ -190,7 +190,7 @@ public class DebuggerMain implements Initializable { ...@@ -190,7 +190,7 @@ public class DebuggerMain implements Initializable {
//System.out.println("Pos: "+newValue.getData().getNode().getNodeInfo().getActiveStatement().getPositionInfo()); //System.out.println("Pos: "+newValue.getData().getNode().getNodeInfo().getActiveStatement().getPositionInfo());
}); });
//TODO nullpointer
proofTreeController.currentHighlightNodeProperty().addListener((observable, oldValue, newValue) -> { proofTreeController.currentHighlightNodeProperty().addListener((observable, oldValue, newValue) -> {
if (newValue != null) { if (newValue != null) {
scriptController.getDebugPositionHighlighter().highlight(newValue); scriptController.getDebugPositionHighlighter().highlight(newValue);
...@@ -211,16 +211,7 @@ public class DebuggerMain implements Initializable { ...@@ -211,16 +211,7 @@ public class DebuggerMain implements Initializable {
} }
public void marriageJavaCode() { public void marriageJavaCode() {
/*javaFileProperty().addListener((observable, oldValue, newValue) -> { //Listener on chosenContract from
showCodeDock(null);
try {
String code = FileUtils.readFileToString(newValue, Charset.defaultCharset());
javaCode.set(code);
} catch (IOException e) {
e.printStackTrace();
}
});*/
chosenContract.addListener(o -> { chosenContract.addListener(o -> {
//javaCode.set(Utils.getJavaCode(chosenContract.get())); //javaCode.set(Utils.getJavaCode(chosenContract.get()));
try { try {
......
...@@ -129,7 +129,9 @@ public class ProofTreeController { ...@@ -129,7 +129,9 @@ public class ProofTreeController {
//this.currentSelectedGoal.bindBidirectional(blocker.currentSelectedGoalProperty()); //this.currentSelectedGoal.bindBidirectional(blocker.currentSelectedGoalProperty());
blocker.currentSelectedGoalProperty().addListener((observable, oldValue, newValue) -> { blocker.currentSelectedGoalProperty().addListener((observable, oldValue, newValue) -> {
Platform.runLater(() -> { Platform.runLater(() -> {
this.setCurrentSelectedGoal(newValue); if (newValue != null) {
this.setCurrentSelectedGoal(newValue);
}
}); });
}); });
blocker.currentGoalsProperty().addListener((observable, oldValue, newValue) -> { blocker.currentGoalsProperty().addListener((observable, oldValue, newValue) -> {
...@@ -156,7 +158,9 @@ public class ProofTreeController { ...@@ -156,7 +158,9 @@ public class ProofTreeController {
*/ */
private void setNewState(State<KeyData> state) { private void setNewState(State<KeyData> state) {
setCurrentGoals(state == null ? null : state.getGoals()); setCurrentGoals(state == null ? null : state.getGoals());
setCurrentSelectedGoal(state == null ? null : state.getSelectedGoalNode());
setCurrentSelectedGoal(state == null ? null : (state.getSelectedGoalNode() == null ? null : state.getSelectedGoalNode()));
setCurrentHighlightNode(statePointer.getScriptstmt()); setCurrentHighlightNode(statePointer.getScriptstmt());
LOGGER.debug("New State from this command: {}@{}", LOGGER.debug("New State from this command: {}@{}",
this.statePointer.getScriptstmt().getNodeName(), this.statePointer.getScriptstmt().getNodeName(),
......
...@@ -100,8 +100,23 @@ public class PuppetMaster { ...@@ -100,8 +100,23 @@ public class PuppetMaster {
Platform.runLater(() -> { Platform.runLater(() -> {
currentGoals.set(state.getGoals());
currentSelectedGoal.set(state.getSelectedGoalNode()); //filter whether all goals are closed
Object[] arr = state.getGoals().stream().filter(keyDataGoalNode -> !keyDataGoalNode.isClosed()).toArray();
if (state.getSelectedGoalNode() == null) {
if (arr.length == 0) {
currentGoals.set(Collections.emptyList());
//currentSelectedGoal.set(state.getGoals().get(0));
currentSelectedGoal.set(null);
} else {
currentGoals.set(state.getGoals());
currentSelectedGoal.set(null);
}
} else {
currentGoals.set(state.getGoals());
currentSelectedGoal.set(state.getSelectedGoalNode());
}
}); });
} else { } else {
......
...@@ -228,16 +228,6 @@ public class ScriptArea extends CodeArea { ...@@ -228,16 +228,6 @@ public class ScriptArea extends CodeArea {
if (hasExecutionMarker()) { if (hasExecutionMarker()) {
System.out.println("getExecutionMarkerPosition() = " + getExecutionMarkerPosition()); System.out.println("getExecutionMarkerPosition() = " + getExecutionMarkerPosition());
/* getStyleSpans(0, getExecutionMarkerPosition()).stream()
.map(span -> {
Collection<String> style = span.getStyle();
if (style.isEmpty()) {
Collections.singleton("NON_EXE_AREA");
} else {
style.add("NON_EXE_AREA");
}
return style;
});*/
UnaryOperator<Collection<String>> styleMapper = strings -> { UnaryOperator<Collection<String>> styleMapper = strings -> {
if (strings.isEmpty()) { if (strings.isEmpty()) {
...@@ -252,11 +242,11 @@ public class ScriptArea extends CodeArea { ...@@ -252,11 +242,11 @@ public class ScriptArea extends CodeArea {
setStyleSpans(0, getStyleSpans(0, getExecutionMarkerPosition()).mapStyles(styleMapper)); setStyleSpans(0, getStyleSpans(0, getExecutionMarkerPosition()).mapStyles(styleMapper));
//this results in a NotSupportedOperation Exception because the add to an immutable list is not allowed
/* getStyleSpans(0, getExecutionMarkerPosition()).forEach(span -> { /* getStyleSpans(0, getExecutionMarkerPosition()).forEach(span -> {
Collection<String> style = span.getStyle(); Collection<String> style = span.getStyle();
if (style.isEmpty()) { if (style.isEmpty()) {
style.add("NON_EXE_AREA"); setStyle(0, getExecutionMarkerPosition(), Collections.singleton("NON_EXE_AREA"));
//setStyle(0, getExecutionMarkerPosition(), Collections.singleton("NON_EXE_AREA"));
} else { } else {
style.add("NON_EXE_AREA"); style.add("NON_EXE_AREA");
} }
......
...@@ -5,8 +5,6 @@ import edu.kit.iti.formal.psdbg.gui.controller.DebuggerMain; ...@@ -5,8 +5,6 @@ import edu.kit.iti.formal.psdbg.gui.controller.DebuggerMain;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.scene.layout.AnchorPane; import javafx.scene.layout.AnchorPane;
import java.io.File;
/** /**
* Welcome pane that allows for a more usable entry point * Welcome pane that allows for a more usable entry point
* Created by weigl on 7/7/17. * Created by weigl on 7/7/17.
...@@ -40,11 +38,16 @@ public class WelcomePane extends AnchorPane { ...@@ -40,11 +38,16 @@ public class WelcomePane extends AnchorPane {
public void loadJavaTest(ActionEvent event) { public void loadJavaTest(ActionEvent event) {
proofScriptDebugger.getWelcomePaneDock().close(); proofScriptDebugger.getWelcomePaneDock().close();
proofScriptDebugger.showActiveInspector(null); proofScriptDebugger.showActiveInspector(null);
proofScriptDebugger.openScript( Examples.loadExamples().forEach(example -> {
if (example.getName().equals("Test"))
example.open(proofScriptDebugger);
});
/* proofScriptDebugger.openScript(
new File("src/test/resources/edu/kit/formal/psdb/interpreter/javaExample/test.kps") new File("src/test/resources/edu/kit/formal/psdb/interpreter/javaExample/test.kps")
); );
proofScriptDebugger.openJavaFile( proofScriptDebugger.openJavaFile(
new File("src/test/resources/edu/kit/formal/psdb/interpreter/javaExample/Test.java")); new File("src/test/resources/edu/kit/formal/psdb/interpreter/javaExample/Test.java"));*/
} }
public void loadHelpPage(ActionEvent event) { public void loadHelpPage(ActionEvent event) {
......
...@@ -28,6 +28,7 @@ public class InspectionModel { ...@@ -28,6 +28,7 @@ public class InspectionModel {
private final BooleanProperty isInterpreterTab = new SimpleBooleanProperty(); private final BooleanProperty isInterpreterTab = new SimpleBooleanProperty();
private ObjectProperty<Mode> mode = new SimpleObjectProperty<>(); private ObjectProperty<Mode> mode = new SimpleObjectProperty<>();
public GoalNode<KeyData> getCurrentInterpreterGoal() { public GoalNode<KeyData> getCurrentInterpreterGoal() {
return currentInterpreterGoal.get(); return currentInterpreterGoal.get();
} }
......
edu.kit.iti.formal.psdbg.examples.contraposition.ContrapositionExample edu.kit.iti.formal.psdbg.examples.contraposition.ContrapositionExample
edu.kit.iti.formal.psdbg.examples.fol.FirstOrderLogicExample edu.kit.iti.formal.psdbg.examples.fol.FirstOrderLogicExample
\ No newline at end of file edu.kit.iti.formal.psdbg.examples.java.JavaSimpleExample
\ No newline at end of file
public class Test{
/*@ public normal_behavior
@ requires x >= 0;
@ ensures \result >0;
@*/
public int foo(int x){
if(x > 0){
x--;
}else{
x++;
}
return x++;
}
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Java Simple Test Example</title>
This is a simple Java example.
</head>
<body>
</body>
</html>
\ No newline at end of file
\javaSource "";
\chooseContract
\ No newline at end of file
script t1(){
symbex;
cases{
case match '.*x.*':
auto;
default:
auto;
}
}
...@@ -7,13 +7,17 @@ ...@@ -7,13 +7,17 @@
@base2: rgb(238, 232, 213); @base2: rgb(238, 232, 213);
@base3: rgb(253, 246, 227); @base3: rgb(253, 246, 227);
@yellow: rgb(181, 137, 0); @yellow: rgb(181, 137, 0);
@orange: rgb(203, 75, 22); @orange: rgb(203, 133, 91);
@red: rgb(220, 50, 47); @red: rgb(220, 50, 47);
@magenta: rgb(211, 54, 130); @magenta: rgb(211, 54, 130);
@violet: rgb(108, 113, 196); @violet: rgb(108, 113, 196);
@blue: rgb(38, 139, 210); @blue: rgb(38, 139, 210);
@cyan: rgb(42, 161, 152); @cyan: rgb(42, 161, 152);
@green: rgb(133, 153, 0); @green: rgb(38, 187, 108);
@basenavy: #f6f8ff;
@keywordColor: #200080;
@stringliteralColor: #6679aa;
@integerLiteralColor: #008c00;
.solarized-dark() { .solarized-dark() {
background-color: @base03; background-color: @base03;
...@@ -26,8 +30,10 @@ ...@@ -26,8 +30,10 @@
} }
.script-area { .script-area {
-fx-background-color: @base3; //-fx-background-color: @base3;
-fx-font-family: "Fira Code Medium", monospace; -fx-background-color: @basenavy;
-fx-font-family: "Inconsolata", monospace;
//-fx-font-family: "Fira Code Medium", monospace;
-fx-font-size: 12pt; -fx-font-size: 12pt;
-fx-fill: @base00; -fx-fill: @base00;
...@@ -53,7 +59,8 @@ ...@@ -53,7 +59,8 @@
// Structures // Structures
.FOREACH, .CASES, .CASE, .DEFAULT .FOREACH, .CASES, .CASE, .DEFAULT
.THEONLY, .SCRIPT, .USING, .REPEAT { .THEONLY, .SCRIPT, .USING, .REPEAT {
-fx-fill: @blue; // -fx-fill: @blue;
-fx-fill: @keywordColor;
-fx-font-weight: bold; -fx-font-weight: bold;
} }
...@@ -73,7 +80,8 @@ ...@@ -73,7 +80,8 @@
} }
.DIGITS, .TRUE, .FALSE { .DIGITS, .TRUE, .FALSE {
-fx-fill: @orange; -fx-fill: @integerLiteralColor;
//-fx-fill: @orange;
} }
.TERM_LITERAL { .TERM_LITERAL {
...@@ -81,7 +89,8 @@ ...@@ -81,7 +89,8 @@
} }
.STRING_LITERAL { .STRING_LITERAL {
-fx-fill: @violet; -fx-fill: @stringliteralColor;
//-fx-fill: @violet;
} }
.SINGLE_LINE_COMMENT, .MULTI_LINE_COMMENT { .SINGLE_LINE_COMMENT, .MULTI_LINE_COMMENT {
...@@ -103,7 +112,7 @@ ...@@ -103,7 +112,7 @@
} }
.line-highlight-postmortem { .line-highlight-postmortem {
-rtfx-background-color: @blue; -rtfx-background-color: @cyan;