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 @@
</executions>
<configuration>
<!-- The package of your generated sources -->
<packageName>edu.kit.formal.proofscriptparser.lint</packageName>
<packageName>edu.kit.formal.psdb.lint</packageName>
</configuration>
</plugin>
......@@ -207,7 +207,7 @@
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>
edu.kit.formal.gui.ProofScriptDebugger
edu.kit.formal.psdb.gui.ProofScriptDebugger
</mainClass>
</transformer>
</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
......@@ -17,7 +17,6 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.dockfx.DockNode;
import java.io.IOException;
import java.util.Locale;
public class ProofScriptDebugger extends Application {
......@@ -36,9 +35,9 @@ public class ProofScriptDebugger extends Application {
Locale.setDefault(Locale.ENGLISH);
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();
//DebuggerMainWindowController controller = fxmlLoader.<DebuggerMainWindowController>getController();
//DebuggerMain controller = fxmlLoader.<DebuggerMain>getController();
Scene scene = new Scene(root);
primaryStage.setOnCloseRequest(event -> Platform.exit());
scene.getStylesheets().addAll(
......@@ -58,8 +57,9 @@ public class ProofScriptDebugger extends Application {
//logger.error("sfklsajflksajfsdajfsdalfjsdaf", new IllegalAccessError("dlfsdalfjsadflj"));
} catch (IOException e) {
} catch (Exception e) {
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.speclang.Contract;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.scene.control.*;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import lombok.Getter;
import java.awt.event.KeyEvent;
import java.util.List;
/**
......
package edu.kit.formal.gui.controller;
package edu.kit.formal.psdb.gui.controller;
import com.google.common.eventbus.EventBus;
import de.uka.ilkd.key.logic.PosInOccurrence;
import de.uka.ilkd.key.rule.TacletApp;
import edu.kit.formal.gui.controls.ScriptArea;
import edu.kit.formal.proofscriptparser.ast.CallStatement;
import edu.kit.formal.psdb.gui.controls.ScriptArea;
import edu.kit.formal.psdb.parser.ast.CallStatement;
import lombok.Data;
import lombok.RequiredArgsConstructor;
......
package edu.kit.formal.gui.controller;
import edu.kit.formal.interpreter.HistoryListener;
import edu.kit.formal.interpreter.Interpreter;
import edu.kit.formal.interpreter.data.GoalNode;
import edu.kit.formal.interpreter.data.KeyData;
import edu.kit.formal.interpreter.data.State;
import edu.kit.formal.proofscriptparser.DefaultASTVisitor;
import edu.kit.formal.proofscriptparser.Visitor;
import edu.kit.formal.proofscriptparser.ast.*;
package edu.kit.formal.psdb.gui.controller;
import edu.kit.formal.psdb.interpreter.HistoryListener;
import edu.kit.formal.psdb.interpreter.Interpreter;
import edu.kit.formal.psdb.interpreter.data.GoalNode;
import edu.kit.formal.psdb.interpreter.data.KeyData;
import edu.kit.formal.psdb.interpreter.data.State;
import edu.kit.formal.psdb.parser.DefaultASTVisitor;
import edu.kit.formal.psdb.parser.Visitor;
import edu.kit.formal.psdb.parser.ast.*;
import javafx.application.Platform;
import javafx.beans.property.SimpleObjectProperty;
......
package edu.kit.formal.gui.controls;
package edu.kit.formal.psdb.gui.controls;
import org.antlr.v4.runtime.Lexer;
import org.antlr.v4.runtime.Token;
......
package edu.kit.formal.gui.controls;
package edu.kit.formal.psdb.gui.controls;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.MapProperty;
......
package edu.kit.formal.gui.controls;
package edu.kit.formal.psdb.gui.controls;
import com.sun.javafx.scene.control.skin.TabPaneSkin;
import javafx.scene.Node;
......
package edu.kit.formal.gui.controls;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView;
import edu.kit.formal.gui.controller.Events;
import edu.kit.formal.gui.model.MainScriptIdentifier;
import javafx.beans.property.*;
import javafx.beans.value.ObservableStringValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
package edu.kit.formal.psdb.gui.controls;
import edu.kit.formal.psdb.gui.controller.Events;
import edu.kit.formal.psdb.gui.model.MainScriptIdentifier;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.event.EventHandler;
import javafx.scene.control.*;
import javafx.scene.input.MouseButton;
import javafx.scene.control.Control;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
import javafx.stage.Modality;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.appender.AbstractAppender;
import org.apache.logging.log4j.core.layout.PatternLayout;
import org.controlsfx.control.StatusBar;
import java.util.Date;
import java.util.LinkedList;
/**
* Created by weigl on 09.06.2017.
* Created on 09.06.2017
*
* @author Alexander Weigl
*/
public class DebuggerStatusBar extends StatusBar {
private static final Logger LOGGER = LogManager.getLogger(DebuggerStatusBar.class);
private final Appender loggerHandler = createAppender();
private final ContextMenu contextMenu = createContextMenu();
//private final Dialog<Void> loggerDialog = createDialog();
//private final ContextMenu contextMenu = createContextMenu();
//private final Appender loggerHandler = createAppender();
//private LogCatchHandlerFX logCatchHandler = new LogCatchHandlerFX();
private ObjectProperty<MainScriptIdentifier> mainScriptIdentifier = new SimpleObjectProperty<>();
private Label lblCurrentNodes = new Label("#nodes: %s");
private Label lblMainscript = new Label();
private ProgressIndicator progressIndicator = new ProgressIndicator();
private LogCatchHandlerFX logCatchHandler = new LogCatchHandlerFX();
private final Dialog<Void> loggerDialog = createDialog();
private EventHandler<MouseEvent> toolTipHandler = event -> {
publishMessage(((Control) event.getTarget()).getTooltip().getText());
};
public DebuggerStatusBar() {
listenOnField("psdbg");
//listenOnField("psdbg");
getRightItems().addAll(
lblMainscript,
......@@ -53,11 +42,11 @@ public class DebuggerStatusBar extends StatusBar {
progressIndicator
);
setOnMouseClicked(event -> {
/*setOnMouseClicked(event -> {
if (event.getButton() == MouseButton.SECONDARY) {
contextMenu.show(this, event.getScreenX(), event.getScreenY());
}
});
});*/
mainScriptIdentifier.addListener((ov, o, n) -> {
......@@ -84,9 +73,9 @@ public class DebuggerStatusBar extends StatusBar {
Events.fire(new Events.FocusScriptArea(area));
}
});
}
/*
private Appender createAppender() {
PatternLayout layout = PatternLayout.createDefaultLayout();
return new AbstractAppender("", null, layout) {
......@@ -95,7 +84,7 @@ public class DebuggerStatusBar extends StatusBar {
publishMessage(event.getMessage().getFormattedMessage());
}
};
}
}*/
public void publishMessage(String format, Object... args) {
String msg = String.format(format, args);
......@@ -106,22 +95,24 @@ public class DebuggerStatusBar extends StatusBar {
return toolTipHandler;
}
/*
public void listenOnField(ObservableStringValue value) {
value.addListener((observable, oldValue, newValue) -> {
publishMessage(newValue);
});
}
}*/
/*
public void listenOnField(Logger logger) {
org.apache.logging.log4j.core.Logger plogger = ((org.apache.logging.log4j.core.Logger) logger); // Bypassing the public API
plogger.addAppender(loggerHandler);
plogger.addAppender(logCatchHandler);
logger.info("Listener added");
}
}*/
public void listenOnField(String loggerCategory) {
/*public void listenOnField(String loggerCategory) {
listenOnField(LogManager.getLogger(loggerCategory));
}
}*/
public void indicateProgress() {
progressIndicator.setProgress(-1);
......@@ -131,14 +122,14 @@ public class DebuggerStatusBar extends StatusBar {
progressIndicator.setProgress(100);
}
public ContextMenu createContextMenu() {
/*public ContextMenu createContextMenu() {
ContextMenu cm = new ContextMenu();
Menu viewOptions = new Menu("View Options");
MenuItem showLog = new MenuItem("Show Log", new MaterialDesignIconView(MaterialDesignIcon.FORMAT_LIST_BULLETED));
showLog.setOnAction(this::showLog);
cm.getItems().addAll(viewOptions, showLog);
return cm;
}
}*/
public MainScriptIdentifier getMainScriptIdentifier() {
return mainScriptIdentifier.get();
......@@ -151,12 +142,14 @@ public class DebuggerStatusBar extends StatusBar {
public ObjectProperty<MainScriptIdentifier> mainScriptIdentifierProperty() {
return mainScriptIdentifier;
}
}
/*
private void showLog(ActionEvent actionEvent) {
loggerDialog.show();
}
}*/
public Dialog<Void> createDialog() {
/*public Dialog<Void> createDialog() {
final TableView<LogEvent> recordView = new TableView<>(logCatchHandler.recordsProperty());
recordView.setEditable(false);
recordView.setSortPolicy(param -> false);
......@@ -180,30 +173,21 @@ public class DebuggerStatusBar extends StatusBar {
messageColumn.setCellValueFactory(
param -> {
return new SimpleStringProperty(param.getValue().getMessage().getFormattedMessage());
/*String s = formatter.formatMessage(param.getValue());
if (param.getValue().getThrown() != null) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
pw.println();
param.getValue().getThrown().printStackTrace(pw);
pw.close();
s += "\n" + sw.toString();
}
return new SimpleStringProperty(s);*/
}
}
);
Dialog<Void> dialog = new Dialog<>();
Dialog<Void> dialog=new Dialog<>();
dialog.setResizable(true);
dialog.initModality(Modality.NONE);
dialog.setHeaderText("Logger Records");
DialogPane dpane = dialog.getDialogPane();
DialogPane dpane=dialog.getDialogPane();
dpane.setContent(new BorderPane(recordView));
dpane.getButtonTypes().setAll(ButtonType.CLOSE);
return dialog;
}
}*/
/*
public static class LogCatchHandlerFX extends AbstractAppender {
private ListProperty<LogEvent> records = new SimpleListProperty<>(FXCollections.observableList(
new LinkedList<>() //remove of head
......@@ -243,6 +227,6 @@ public class DebuggerStatusBar extends StatusBar {
this.maxRecords = maxRecords;
}
}
}
}*/
package edu.kit.formal.gui.controls;
package edu.kit.formal.psdb.gui.controls;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import edu.kit.formal.interpreter.data.KeyData;
import edu.kit.formal.psdb.interpreter.data.KeyData;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.fxml.FXML;
......
package edu.kit.formal.gui.controls;
package edu.kit.formal.psdb.gui.controls;
import edu.kit.formal.gui.model.InspectionModel;
import edu.kit.formal.interpreter.data.GoalNode;
import edu.kit.formal.interpreter.data.KeyData;
import edu.kit.formal.psdb.gui.model.InspectionModel;
import edu.kit.formal.psdb.interpreter.data.GoalNode;
import edu.kit.formal.psdb.interpreter.data.KeyData;
import javafx.beans.Observable;
import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
......
package edu.kit.formal.gui.controls;
package edu.kit.formal.psdb.gui.controls;
import javafx.beans.property.SimpleMapProperty;
import javafx.collections.FXCollections;
......@@ -8,7 +8,7 @@ import org.dockfx.DockNode;
/**
* This controller manages a list of {@link InspectionView} and the associated {@link DockNode}s.
*
* Espeically, this class holds the active tab, which is connected with the {@link edu.kit.formal.interpreter.graphs.ProofTreeController},
* Espeically, this class holds the active tab, which is connected with the {@link edu.kit.formal.psdb.interpreter.graphs.ProofTreeController},
* and shows the current interpreter state.
*
* @author weigl
......
package edu.kit.formal.gui.controls;
package edu.kit.formal.psdb.gui.controls;
import antlrgrammars.Java8Lexer;
import javafx.beans.property.SimpleSetProperty;
......
package edu.kit.formal.gui.controls;
package edu.kit.formal.psdb.gui.controls;
import java.util.ArrayList;
import java.util.List;
......
package edu.kit.formal.gui.controls;
package edu.kit.formal.psdb.gui.controls;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIcon;
import de.jensd.fx.glyphs.materialdesignicons.MaterialDesignIconView;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.BorderPane;
/**
......
package edu.kit.formal.psdb.gui.controls;
import de.uka.ilkd.key.proof.Node;
import de.uka.ilkd.key.proof.Proof;
import de.uka.ilkd.key.proof.ProofTreeEvent;
import de.uka.ilkd.key.proof.ProofTreeListener;
import javafx.beans.InvalidationListener;
import javafx.beans.property.MapProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleMapProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.TreeCell;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.control.cell.TextFieldTreeCell;
import javafx.scene.layout.BorderPane;
import javafx.util.StringConverter;
import java.util.stream.Collectors;
public class ProofTree extends BorderPane {
private ObjectProperty<Proof> proof = new SimpleObjectProperty<>();
private ObjectProperty<Node> root = new SimpleObjectProperty<>();
private MapProperty colorOfNodes = new SimpleMapProperty<>(FXCollections.observableHashMap());
@FXML
private TreeView<Node> treeProof;
private ProofTreeListener proofTreeListener = new ProofTreeListener() {
@Override
public void proofExpanded(ProofTreeEvent proofTreeEvent) {
treeProof.refresh();
}
@Override
public void proofIsBeingPruned(ProofTreeEvent proofTreeEvent) {
}
@Override
public void proofPruned(ProofTreeEvent proofTreeEvent) {
treeProof.refresh();
}
@Override
public void proofStructureChanged(ProofTreeEvent proofTreeEvent) {
treeProof.refresh();
}
@Override
public void proofClosed(ProofTreeEvent proofTreeEvent) {
treeProof.refresh();
}
@Override
public void proofGoalRemoved(ProofTreeEvent proofTreeEvent) {
treeProof.refresh();
}
@Override
public void proofGoalsAdded(ProofTreeEvent proofTreeEvent) {
treeProof.refresh();
}
@Override
public void proofGoalsChanged(ProofTreeEvent proofTreeEvent) {
treeProof.refresh();
}
@Override
public void smtDataUpdate(ProofTreeEvent proofTreeEvent) {
}
@Override
public void notesChanged(ProofTreeEvent proofTreeEvent) {
}
};
public ProofTree() {
Utils.createWithFXML(this);
treeProof.setCellFactory(this::cellFactory);
root.addListener(o -> init());
proof.addListener((prop, old, n) -> {
if (old != null) {
old.removeProofTreeListener(proofTreeListener);
}
n.addProofTreeListener(proofTreeListener);
});
init();
}
private TreeCell<Node> cellFactory(TreeView<Node> nodeTreeView) {
TextFieldTreeCell<Node> tftc = new TextFieldTreeCell<>();
tftc.setConverter(new StringConverter<Node>() {
@Override
public String toString(Node object) {
return object.sequent().toString();
}
@Override
public Node fromString(String string) {
return null;
}
});
tftc.itemProperty().addListener((p, o, n) -> repaint(tftc));
colorOfNodes.addListener((InvalidationListener) o -> repaint(tftc));
return tftc;
}
private void repaint(TextFieldTreeCell<Node> tftc) {
Node n = tftc.getItem();
tftc.setStyle("");
if (n != null) {
if (n.isClosed()) {
tftc.setStyle("-fx-background-color: greenyellow");
}
if (colorOfNodes.contai