Commit 7e5e33d0 authored by Sarah Grebing's avatar Sarah Grebing

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/edu/kit/formal/psdb/gui/controller/DebuggerMain.java
#	src/main/java/edu/kit/formal/psdb/interpreter/graphs/ProofTreeController.java
parents 96b2b783 932ccd8b
...@@ -129,7 +129,7 @@ ...@@ -129,7 +129,7 @@
</executions> </executions>
<configuration> <configuration>
<!-- The package of your generated sources --> <!-- The package of your generated sources -->
<packageName>edu.kit.formal.proofscriptparser.lint</packageName> <packageName>edu.kit.formal.psdb.lint</packageName>
</configuration> </configuration>
</plugin> </plugin>
...@@ -207,7 +207,7 @@ ...@@ -207,7 +207,7 @@
<transformer <transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass> <mainClass>
edu.kit.formal.gui.ProofScriptDebugger edu.kit.formal.psdb.gui.ProofScriptDebugger
</mainClass> </mainClass>
</transformer> </transformer>
</transformers> </transformers>
......
grammar MatchPattern;
/* Examples for testing
f(x)
f(x,y,g(y))
X
?Y
_
...
f(... ?X ...)
f(..., ?X)
f(..., ...?X...)
f(..., ... g(x) ...)
f(_, x, _, y, ... y ...)
*/
termPattern :
DONTCARE #dontCare
//| STARDONTCARE #starDontCare
| SID #schemaVar
| STARDONTCARE termPattern STARDONTCARE #anywhere
| func=ID ( '(' termPattern (',' termPattern)* ')')? #function
;
/*
f(x), f(x,y,g(y)), X, ?Y, _, ..., f(... ?X ...), f(..., ?X), f(..., ...?X...), f(..., ... g(x) ...), f(_, x, _, y, ... y ...)
*/
semiSeqPattern : termPattern (',' termPattern)*;
sequentPattern : semiSeqPattern? ARROW semiSeqPattern?;
ARROW : '⇒' | '==>';
DONTCARE: '?' | '_' | '█';
STARDONTCARE: '...' | '…';
DIGITS : DIGIT+ ;
fragment DIGIT : [0-9] ;
SID: '?' [_a-zA-Z0-9\\]+ ;
ID : [a-zA-Z\\_] ([_a-zA-Z0-9\\])* ;
COMMENT: '//' ~[\n\r]* -> channel(HIDDEN);
WS: [\n\f\r\t ] -> channel(HIDDEN);
\ No newline at end of file
grammar MatchPattern;
schemaTerm :
'_'
|'...'
| schemaVar
| logicalVar
| functionSymbol ('('schemaTerm (',' schemaTerm)? ')')?
;
termHelper :
schemaTerm
| functionSymbol '('termHelper (',' termHelper)? ')'
;
functionSymbol :
ID+
;
schemaVar:
'?'ID+
;
logicalVar:
ID+
;
DIGITS : DIGIT+ ;
fragment DIGIT : [0-9] ;
ID : [a-zA-Z] ([_a-zA-Z0-9] | '.' | '\\' | '[]' | '-')* ;
\ No newline at end of file
package edu.kit.formal.gui; package edu.kit.formal.psdb.gui;
/** /**
* Main Entry for Debugger GUI * Main Entry for Debugger GUI
...@@ -17,7 +17,6 @@ import org.apache.logging.log4j.LogManager; ...@@ -17,7 +17,6 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.dockfx.DockNode; import org.dockfx.DockNode;
import java.io.IOException;
import java.util.Locale; import java.util.Locale;
public class ProofScriptDebugger extends Application { public class ProofScriptDebugger extends Application {
...@@ -36,9 +35,9 @@ public class ProofScriptDebugger extends Application { ...@@ -36,9 +35,9 @@ public class ProofScriptDebugger extends Application {
Locale.setDefault(Locale.ENGLISH); Locale.setDefault(Locale.ENGLISH);
try { try {
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/DebuggerMain.fxml")); FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/edu/kit/formal/psdb/gui/controller/DebuggerMain.fxml"));
Parent root = fxmlLoader.load(); Parent root = fxmlLoader.load();
//DebuggerMainWindowController controller = fxmlLoader.<DebuggerMainWindowController>getController(); //DebuggerMain controller = fxmlLoader.<DebuggerMain>getController();
Scene scene = new Scene(root); Scene scene = new Scene(root);
primaryStage.setOnCloseRequest(event -> Platform.exit()); primaryStage.setOnCloseRequest(event -> Platform.exit());
scene.getStylesheets().addAll( scene.getStylesheets().addAll(
...@@ -58,8 +57,9 @@ public class ProofScriptDebugger extends Application { ...@@ -58,8 +57,9 @@ public class ProofScriptDebugger extends Application {
//logger.error("sfklsajflksajfsdajfsdalfjsdaf", new IllegalAccessError("dlfsdalfjsadflj")); //logger.error("sfklsajflksajfsdajfsdalfjsdaf", new IllegalAccessError("dlfsdalfjsadflj"));
} catch (IOException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
System.exit(1);
} }
} }
......
package edu.kit.formal.gui.controller; package edu.kit.formal.psdb.gui.controller;
import de.uka.ilkd.key.java.Services; import de.uka.ilkd.key.java.Services;
import de.uka.ilkd.key.speclang.Contract; import de.uka.ilkd.key.speclang.Contract;
import javafx.beans.property.ObjectProperty; import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleListProperty; import javafx.beans.property.SimpleListProperty;
import javafx.collections.ObservableList; import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.scene.control.*; import javafx.scene.control.*;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.stage.Modality; import javafx.stage.Modality;
import lombok.Getter; import lombok.Getter;
import java.awt.event.KeyEvent;
import java.util.List; import java.util.List;
/** /**
......
package edu.kit.formal.gui.controller; package edu.kit.formal.psdb.gui.controller;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon; import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView; import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView;
import de.uka.ilkd.key.api.ProofApi;
import de.uka.ilkd.key.proof.init.ProofInputException; import de.uka.ilkd.key.proof.init.ProofInputException;
import de.uka.ilkd.key.speclang.Contract; import de.uka.ilkd.key.speclang.Contract;
import edu.kit.formal.gui.ProofScriptDebugger; import edu.kit.formal.psdb.gui.ProofScriptDebugger;
import edu.kit.formal.gui.controls.*; import edu.kit.formal.psdb.gui.controls.*;
import edu.kit.formal.gui.model.Breakpoint; import edu.kit.formal.psdb.gui.model.InspectionModel;
import edu.kit.formal.gui.model.InspectionModel; import edu.kit.formal.psdb.interpreter.Interpreter;
import edu.kit.formal.interpreter.Interpreter; import edu.kit.formal.psdb.interpreter.InterpreterBuilder;
import edu.kit.formal.interpreter.InterpreterBuilder; import edu.kit.formal.psdb.interpreter.KeYProofFacade;
import edu.kit.formal.interpreter.KeYProofFacade; import edu.kit.formal.psdb.interpreter.data.KeyData;
import edu.kit.formal.interpreter.data.KeyData; import edu.kit.formal.psdb.interpreter.graphs.PTreeNode;
import edu.kit.formal.interpreter.graphs.PTreeNode; import edu.kit.formal.psdb.interpreter.graphs.ProofTreeController;
import edu.kit.formal.interpreter.graphs.ProofTreeController; import edu.kit.formal.psdb.parser.ast.ProofScript;
import edu.kit.formal.proofscriptparser.ast.ProofScript;
import javafx.beans.property.*; import javafx.beans.property.*;
import javafx.beans.value.ChangeListener; import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableBooleanValue; import javafx.beans.value.ObservableBooleanValue;
...@@ -53,9 +53,9 @@ import java.util.concurrent.Executors; ...@@ -53,9 +53,9 @@ import java.util.concurrent.Executors;
* @author S.Grebing * @author S.Grebing
* @author Alexander Weigl * @author Alexander Weigl
*/ */
public class DebuggerMainWindowController implements Initializable { public class DebuggerMain implements Initializable {
public static final KeYProofFacade FACADE = new KeYProofFacade(); public static final KeYProofFacade FACADE = new KeYProofFacade();
protected static final Logger LOGGER = LogManager.getLogger(DebuggerMainWindowController.class); protected static final Logger LOGGER = LogManager.getLogger(DebuggerMain.class);
public final ContractLoaderService contractLoaderService = new ContractLoaderService(); public final ContractLoaderService contractLoaderService = new ContractLoaderService();
private final ProofTreeController proofTreeController = new ProofTreeController(); private final ProofTreeController proofTreeController = new ProofTreeController();
private final InspectionViewsController inspectionViewsController = new InspectionViewsController(); private final InspectionViewsController inspectionViewsController = new InspectionViewsController();
...@@ -86,6 +86,8 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -86,6 +86,8 @@ public class DebuggerMainWindowController implements Initializable {
//----------------------------------------------------------------------------------------------------------------- //-----------------------------------------------------------------------------------------------------------------
private ProofTree proofTree = new ProofTree();
private DockNode proofTreeDock = new DockNode(proofTree, "Proof Tree");
private WelcomePane welcomePane = new WelcomePane(this); private WelcomePane welcomePane = new WelcomePane(this);
private DockNode welcomePaneDock = new DockNode(welcomePane, "Welcome", new MaterialDesignIconView(MaterialDesignIcon.ACCOUNT)); private DockNode welcomePaneDock = new DockNode(welcomePane, "Welcome", new MaterialDesignIconView(MaterialDesignIcon.ACCOUNT));
private DockNode activeInspectorDock = inspectionViewsController.getActiveInterpreterTabDock(); private DockNode activeInspectorDock = inspectionViewsController.getActiveInterpreterTabDock();
...@@ -124,6 +126,17 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -124,6 +126,17 @@ public class DebuggerMainWindowController implements Initializable {
//statusBar.publishMessage("File: " + (newValue != null ? newValue.getAbsolutePath() : "n/a")); //statusBar.publishMessage("File: " + (newValue != null ? newValue.getAbsolutePath() : "n/a"));
marriageJavaCode(); marriageJavaCode();
//marriage key proof facade to proof tree
getFacade().proofProperty().addListener(
(prop, o, n) -> {
proofTree.setRoot(n.root());
proofTree.setProof(n);
getInspectionViewsController().getActiveInspectionViewTab().getModel().getGoals().setAll(FACADE.getPseudoGoals());
}
);
//Debugging //Debugging
Utils.addDebugListener(javaCode); Utils.addDebugListener(javaCode);
Utils.addDebugListener(executeNotPossible, "executeNotPossible"); Utils.addDebugListener(executeNotPossible, "executeNotPossible");
...@@ -345,11 +358,74 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -345,11 +358,74 @@ public class DebuggerMainWindowController implements Initializable {
} }
} }
//region Actions: Menu
@FXML
public void closeProgram() {
System.exit(0);
}
@FXML
public void openScript() {
File scriptFile = openFileChooserOpenDialog("Select Script File",
"Proof Script File", "kps");
if (scriptFile != null) {
openScript(scriptFile);
}
}
@FXML
public void saveScript() {
try {
scriptController.saveCurrentScript();
} catch (IOException e) {
Utils.showExceptionDialog("Could not save file", "Saving File Error", "Could not save current script", e);
}
}
private void saveScript(File scriptFile) {
try {
scriptController.saveCurrentScriptAs(scriptFile);
} catch (IOException e) {
Utils.showExceptionDialog("Could not save file", "Saving File Error", "Could not save to file " + scriptFile.getName(), e);
}
}
@FXML
public void saveAsScript() throws IOException {
File f = openFileChooserSaveDialog("Save script", "Save Script files", "kps");
if (f != null) {
/* if(!f.exists()){
f.createNewFile();
}*/
saveScript(f);
}
}
public void openScript(File scriptFile) {
assert scriptFile != null;
setInitialDirectory(scriptFile.getParentFile());
try {
String code = FileUtils.readFileToString(scriptFile, Charset.defaultCharset());
ScriptArea area = scriptController.createNewTab(scriptFile);
} catch (IOException e) {
Utils.showExceptionDialog("Exception occured", "",
"Could not load sourceName " + scriptFile, e);
}
}
@FXML
protected void loadKeYFile() {
File keyFile = openFileChooserOpenDialog("Select KeY File", "KeY Files", "key", "kps");
openKeyFile(keyFile);
}
public void openKeyFile(File keyFile) { public void openKeyFile(File keyFile) {
if (keyFile != null) { if (keyFile != null) {
setKeyFile(keyFile); setKeyFile(keyFile);
setInitialDirectory(keyFile.getParentFile()); setInitialDirectory(keyFile.getParentFile());
Task<Void> task = FACADE.loadKeyFileTask(keyFile); Task<ProofApi> task = FACADE.loadKeyFileTask(keyFile);
task.setOnSucceeded(event -> { task.setOnSucceeded(event -> {
statusBar.publishMessage("Loaded key sourceName: %s", keyFile); statusBar.publishMessage("Loaded key sourceName: %s", keyFile);
statusBar.stopProgress(); statusBar.stopProgress();
...@@ -370,6 +446,27 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -370,6 +446,27 @@ public class DebuggerMainWindowController implements Initializable {
} }
} }
/**
* Save KeY proof as proof file
*
* @param actionEvent
*/
public void saveProof(ActionEvent actionEvent) {
LOGGER.error("saveProof not implemented!!!");
}
//endregion
//region Santa's Little Helper
@FXML
protected void loadJavaFile() {
File javaFile = openFileChooserOpenDialog("Select Java File", "Java Files", "java");
openJavaFile(javaFile);
}
public void openJavaFile(File javaFile) { public void openJavaFile(File javaFile) {
if (javaFile != null) { if (javaFile != null) {
setJavaFile(javaFile); setJavaFile(javaFile);
...@@ -378,8 +475,9 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -378,8 +475,9 @@ public class DebuggerMainWindowController implements Initializable {
} }
} }
public void setKeyFile(File keyFile) { public void openJavaFile() {
this.keyFile.set(keyFile); loadJavaFile();
showCodeDock(null);
} }
@FXML @FXML
...@@ -545,19 +643,25 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -545,19 +643,25 @@ public class DebuggerMainWindowController implements Initializable {
} }
public void stepOver(ActionEvent actionEvent) { public void stepOver(ActionEvent actionEvent) {
LOGGER.debug("DebuggerMainWindowController.stepOver"); LOGGER.debug("DebuggerMain.stepOver");
PTreeNode newState = proofTreeController.stepOver(); PTreeNode newState = proofTreeController.stepOver();
} }
public void stepBack(ActionEvent actionEvent) { public void stepBack(ActionEvent actionEvent) {
LOGGER.debug("DebuggerMainWindowController.stepBack"); LOGGER.debug("DebuggerMain.stepBack");
PTreeNode newState = proofTreeController.stepBack(); PTreeNode newState = proofTreeController.stepBack();
} }
public KeYProofFacade getFacade() {
return FACADE;
}
//region Property //region Property
public boolean isDebugMode() { public boolean isDebugMode() {
return debugMode.get(); return debugMode.get();
} }
//endregion
public void setDebugMode(boolean debugMode) { public void setDebugMode(boolean debugMode) {
this.debugMode.set(debugMode); this.debugMode.set(debugMode);
...@@ -587,6 +691,12 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -587,6 +691,12 @@ public class DebuggerMainWindowController implements Initializable {
scriptController.newScript(); scriptController.newScript();
} }
public void showCodeDock(ActionEvent actionEvent) {
if (!javaAreaDock.isDocked()) {
javaAreaDock.dock(dockStation, DockPos.RIGHT);
}
}
public void showWelcomeDock(ActionEvent actionEvent) { public void showWelcomeDock(ActionEvent actionEvent) {
if (!welcomePaneDock.isDocked()) { if (!welcomePaneDock.isDocked()) {
welcomePaneDock.dock(dockStation, DockPos.CENTER); welcomePaneDock.dock(dockStation, DockPos.CENTER);
...@@ -600,6 +710,13 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -600,6 +710,13 @@ public class DebuggerMainWindowController implements Initializable {
} }
} }
@FXML
public void showProofTree(ActionEvent actionEvent) {
if (!proofTreeDock.isDocked() && !proofTreeDock.isFloating()) {
proofTreeDock.dock(dockStation, DockPos.CENTER);
}
}
public DockNode getJavaAreaDock() { public DockNode getJavaAreaDock() {
return javaAreaDock; return javaAreaDock;
} }
...@@ -632,6 +749,10 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -632,6 +749,10 @@ public class DebuggerMainWindowController implements Initializable {
return proofTreeController; return proofTreeController;
} }
public InspectionViewsController getInspectionViewsController() {
return inspectionViewsController;
}
public ExecutorService getExecutorService() { public ExecutorService getExecutorService() {
return executorService; return executorService;
} }
...@@ -656,10 +777,26 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -656,10 +777,26 @@ public class DebuggerMainWindowController implements Initializable {
return welcomePane; return welcomePane;