Commit 3e566e4a authored by sarah.grebing's avatar sarah.grebing

Merge branch 'luong_workbranch' into 'master'

Luong workbranch

See merge request !20
parents 83df2985 a19583e8
Pipeline #22444 passed with stages
in 3 minutes and 31 seconds
...@@ -14,7 +14,7 @@ public class ASTDiff extends DefaultASTVisitor<ASTNode> { ...@@ -14,7 +14,7 @@ public class ASTDiff extends DefaultASTVisitor<ASTNode> {
newScript.setSignature(proofScript.getSignature()); newScript.setSignature(proofScript.getSignature());
other = ((ProofScript) other).getBody(); other = ((ProofScript) other).getBody();
newScript.setBody(visit(newScript.getBody())); newScript.setBody(visit(proofScript.getBody()));
return newScript; return newScript;
} }
...@@ -61,12 +61,13 @@ public class ASTDiff extends DefaultASTVisitor<ASTNode> { ...@@ -61,12 +61,13 @@ public class ASTDiff extends DefaultASTVisitor<ASTNode> {
int i = 0; int i = 0;
for (; i < statements.size(); i++) { for (; i < statements.size(); i++) {
if (statements.get(i).eq(other.get(i))) { if (!statements.get(i).isSame(other.get(i))) {
break; System.out.println("Alter Script wurde verändert");
return null;
} }
} }
for (int j = i; j < other.size(); j++) { for (; i < other.size(); i++) {
s.add(other.get(i)); s.add(other.get(i));
} }
......
...@@ -167,6 +167,11 @@ public abstract class ASTNode<T extends ParserRuleContext> ...@@ -167,6 +167,11 @@ public abstract class ASTNode<T extends ParserRuleContext>
return Objects.hash(getRuleContext()); return Objects.hash(getRuleContext());
} }
//TODO: param + class
public boolean isSame(ASTNode other) {
return this.getNodeName().equals(other.getNodeName());
}
public int getSyntaxWidth() { public int getSyntaxWidth() {
if (ruleContext != null) { if (ruleContext != null) {
return ruleContext.stop.getStopIndex() return ruleContext.stop.getStopIndex()
......
...@@ -225,9 +225,10 @@ public class InterpreterBuilder { ...@@ -225,9 +225,10 @@ public class InterpreterBuilder {
public InterpreterBuilder setProblemPath(File path){ public InterpreterBuilder setProblemPath(File path){
Map<String, CommandHandler<KeyData>> builtinsnew = this.bich.getBuiltins(); Map<String, CommandHandler<KeyData>> builtinsnew = this.bich.getBuiltins();
SaveCommand sc = new SaveCommand(path);
builtinsnew.put(SaveCommand.SAVE_COMMAND_NAME, sc); builtinsnew.put(SaveCommand.SAVE_COMMAND_NAME, new SaveCommand(path));
this.bich.setBuiltins(builtinsnew); this.bich.setBuiltins(builtinsnew);
return this; return this;
} }
......
...@@ -63,7 +63,8 @@ public class SaveCommand implements CommandHandler<KeyData> { ...@@ -63,7 +63,8 @@ public class SaveCommand implements CommandHandler<KeyData> {
Semaphore semaphore = new Semaphore(0); Semaphore semaphore = new Semaphore(0);
Platform.runLater(() -> { Platform.runLater(() -> {
Alert a = new Alert(Alert.AlertType.CONFIRMATION); Alert a = new Alert(Alert.AlertType.CONFIRMATION);
a.setTitle("Foo"); a.setTitle("Overwrite proof file");
a.setContentText("Overwrite existing proof file \"" + sp.getName()+"\" (line "+ sp.getLineNumber() +") ?");
Optional<ButtonType> buttonType = a.showAndWait(); Optional<ButtonType> buttonType = a.showAndWait();
if(buttonType.isPresent() && buttonType.get() == ButtonType.OK){ if(buttonType.isPresent() && buttonType.get() == ButtonType.OK){
execute.set(true); execute.set(true);
...@@ -86,10 +87,7 @@ public class SaveCommand implements CommandHandler<KeyData> { ...@@ -86,10 +87,7 @@ public class SaveCommand implements CommandHandler<KeyData> {
} }
@Override
public boolean isUninterpretedParams(CallStatement call) {
return true;
}
} }
......
...@@ -599,7 +599,7 @@ public class Interpreter<T> extends DefaultASTVisitor<Object> ...@@ -599,7 +599,7 @@ public class Interpreter<T> extends DefaultASTVisitor<Object>
private VariableAssignment evaluateParametersStateLess(Parameters parameters) { private VariableAssignment evaluateParametersStateLess(Parameters parameters) {
VariableAssignment va = new VariableAssignment(); VariableAssignment va = new VariableAssignment();
Evaluator<T> evaluator = createEvaluator(null, null); Evaluator<T> evaluator = new Evaluator<>(null, null);
parameters.entrySet().forEach(entry -> { parameters.entrySet().forEach(entry -> {
try { try {
......
...@@ -110,7 +110,7 @@ public class InteractiveModeController { ...@@ -110,7 +110,7 @@ public class InteractiveModeController {
*/ */
public void undo(javafx.event.ActionEvent actionEvent) { public void undo(javafx.event.ActionEvent actionEvent) {
if (savepointslist.isEmpty()) { if (savepointslist.isEmpty()) {
Debug.log("Kein vorheriger Zustand."); //TODO: events fire Debug.log("Kein vorheriger Zustand.");
return; return;
} }
......
...@@ -8,7 +8,9 @@ import edu.kit.iti.formal.psdbg.interpreter.KeYProofFacade; ...@@ -8,7 +8,9 @@ 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.SavePoint; import edu.kit.iti.formal.psdbg.interpreter.data.SavePoint;
import edu.kit.iti.formal.psdbg.interpreter.dbg.Breakpoint; import edu.kit.iti.formal.psdbg.interpreter.dbg.Breakpoint;
import edu.kit.iti.formal.psdbg.parser.ASTDiff;
import edu.kit.iti.formal.psdbg.parser.Facade; import edu.kit.iti.formal.psdbg.parser.Facade;
import edu.kit.iti.formal.psdbg.parser.ast.ASTNode;
import edu.kit.iti.formal.psdbg.parser.ast.ProofScript; import edu.kit.iti.formal.psdbg.parser.ast.ProofScript;
import edu.kit.iti.formal.psdbg.parser.ast.Statements; import edu.kit.iti.formal.psdbg.parser.ast.Statements;
import javafx.scene.control.Alert; import javafx.scene.control.Alert;
...@@ -160,5 +162,10 @@ public class ScriptExecutionController { ...@@ -160,5 +162,10 @@ public class ScriptExecutionController {
} }
private ASTNode calculateDiff (ASTDiff dff) {
return null;
}
} }
...@@ -29,11 +29,9 @@ import javafx.scene.control.cell.TextFieldTreeCell; ...@@ -29,11 +29,9 @@ import javafx.scene.control.cell.TextFieldTreeCell;
import javafx.scene.layout.BorderPane; import javafx.scene.layout.BorderPane;
import javafx.util.StringConverter; import javafx.util.StringConverter;
import lombok.*; import lombok.*;
import sun.reflect.generics.tree.Tree;
import java.util.HashMap; import java.util.*;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer; import java.util.function.Consumer;
...@@ -327,12 +325,14 @@ public class ProofTree extends BorderPane { ...@@ -327,12 +325,14 @@ public class ProofTree extends BorderPane {
} }
@AllArgsConstructor @AllArgsConstructor
private static class TreeNode { private static class TreeNode {
String label; String label;
Node node; Node node;
} }
class TreeTransformationKey { class TreeTransformationKey {
public TreeItem<TreeNode> create(Proof proof) { public TreeItem<TreeNode> create(Proof proof) {
...@@ -414,6 +414,7 @@ public class ProofTree extends BorderPane { ...@@ -414,6 +414,7 @@ public class ProofTree extends BorderPane {
} }
@RequiredArgsConstructor @RequiredArgsConstructor
class TreeTransformationScript extends TreeTransformationKey { class TreeTransformationScript extends TreeTransformationKey {
final ProofTreeManager<KeyData> manager; final ProofTreeManager<KeyData> manager;
...@@ -472,5 +473,44 @@ public class ProofTree extends BorderPane { ...@@ -472,5 +473,44 @@ public class ProofTree extends BorderPane {
TreeItem<TreeNode> ti = new TreeItem<>(new TreeNode(lbl, n)); TreeItem<TreeNode> ti = new TreeItem<>(new TreeNode(lbl, n));
return ti; return ti;
} }
//TODO: Reverse ArrayList in the end or nah?
@Deprecated
public ArrayList<String> getBranchLabels (TreeNode node) {
TreeItem<TreeNode> proofTree = create(proof.get());
ArrayList<String> branchlabels = new ArrayList<>();
int i = 0;
branchlabels.set(0, node.label);
while (node != null) {
if(!branchlabels.get(i).equals(node.label)) {
i++;
branchlabels.set(i, node.label);
}
//TODO: node = node.parent
}
return branchlabels;
}
public ArrayList<String> getBranchLabels (Node node) {
ArrayList<String> branchlabels = new ArrayList<>();
int i = 0;
//TODO: branchlabel = all branchlabels or only next one
branchlabels.set(0, node.getNodeInfo().getBranchLabel());
Node n = node.parent();
while (n != null) {
if(!branchlabels.get(i).equals(n.getNodeInfo().getBranchLabel())) {
i++;
branchlabels.set(i, n.getNodeInfo().getBranchLabel());
}
n = n.parent();
}
return branchlabels;
}
} }
} }
...@@ -9,7 +9,10 @@ import edu.kit.iti.formal.psdbg.gui.actions.acomplete.Suggestion; ...@@ -9,7 +9,10 @@ import edu.kit.iti.formal.psdbg.gui.actions.acomplete.Suggestion;
import edu.kit.iti.formal.psdbg.gui.actions.inline.InlineActionSupplier; import edu.kit.iti.formal.psdbg.gui.actions.inline.InlineActionSupplier;
import edu.kit.iti.formal.psdbg.gui.controller.Events; import edu.kit.iti.formal.psdbg.gui.controller.Events;
import edu.kit.iti.formal.psdbg.gui.model.MainScriptIdentifier; import edu.kit.iti.formal.psdbg.gui.model.MainScriptIdentifier;
import edu.kit.iti.formal.psdbg.interpreter.data.KeyData;
import edu.kit.iti.formal.psdbg.interpreter.data.SavePoint;
import edu.kit.iti.formal.psdbg.interpreter.dbg.Breakpoint; import edu.kit.iti.formal.psdbg.interpreter.dbg.Breakpoint;
import edu.kit.iti.formal.psdbg.interpreter.dbg.PTreeNode;
import edu.kit.iti.formal.psdbg.lint.LintProblem; import edu.kit.iti.formal.psdbg.lint.LintProblem;
import edu.kit.iti.formal.psdbg.lint.LinterStrategy; import edu.kit.iti.formal.psdbg.lint.LinterStrategy;
import edu.kit.iti.formal.psdbg.parser.Facade; import edu.kit.iti.formal.psdbg.parser.Facade;
...@@ -388,6 +391,10 @@ public class ScriptArea extends BorderPane { ...@@ -388,6 +391,10 @@ public class ScriptArea extends BorderPane {
} }
} }
public void underlineSavepoint(SavePoint sp){
codeArea.setStyle(sp.getLineNumber() -1, Collections.singleton("underlinesave"));
}
private void highlightNonExecutionArea() { private void highlightNonExecutionArea() {
if (hasExecutionMarker()) { if (hasExecutionMarker()) {
LOGGER.debug("getExecutionMarkerPosition() = " + getExecutionMarkerPosition()); LOGGER.debug("getExecutionMarkerPosition() = " + getExecutionMarkerPosition());
...@@ -455,11 +462,12 @@ public class ScriptArea extends BorderPane { ...@@ -455,11 +462,12 @@ public class ScriptArea extends BorderPane {
} }
private void underline(int linenumber) { public void setAlertMarker(int lineNumber) {
gutter.getLineAnnotation(lineNumber - 1).setAlert(true);
} }
private boolean hasExecutionMarker() { private boolean hasExecutionMarker() {
return getText().contains(EXECUTION_MARKER); return getText().contains(EXECUTION_MARKER);
} }
...@@ -646,6 +654,10 @@ public class ScriptArea extends BorderPane { ...@@ -646,6 +654,10 @@ public class ScriptArea extends BorderPane {
MaterialDesignIcon.CONTENT_SAVE, "12" MaterialDesignIcon.CONTENT_SAVE, "12"
); );
private MaterialDesignIconView iconSkippedSave = new MaterialDesignIconView(
MaterialDesignIcon.ALERT, "12"
);
private Label lineNumber = new Label("not set"); private Label lineNumber = new Label("not set");
public GutterView(GutterAnnotation ga) { public GutterView(GutterAnnotation ga) {
...@@ -676,6 +688,8 @@ public class ScriptArea extends BorderPane { ...@@ -676,6 +688,8 @@ public class ScriptArea extends BorderPane {
if (getAnnotation().isMainScript()) getChildren().add(iconMainScript); if (getAnnotation().isMainScript()) getChildren().add(iconMainScript);
else if (getAnnotation().isSavepoint()) getChildren().add(iconSavepoint); else if (getAnnotation().isSavepoint()) getChildren().add(iconSavepoint);
else addPlaceholder(); else addPlaceholder();
if (getAnnotation().isAlert()) getChildren().add(iconSkippedSave);
else addPlaceholder();
if (getAnnotation().isBreakpoint()) if (getAnnotation().isBreakpoint())
getChildren().add(getAnnotation().getConditional() getChildren().add(getAnnotation().getConditional()
? iconConditionalBreakPoint ? iconConditionalBreakPoint
...@@ -717,6 +731,21 @@ public class ScriptArea extends BorderPane { ...@@ -717,6 +731,21 @@ public class ScriptArea extends BorderPane {
private SimpleBooleanProperty savepoint = new SimpleBooleanProperty(); private SimpleBooleanProperty savepoint = new SimpleBooleanProperty();
//for now specifically for skipped saved commands
private SimpleBooleanProperty alert = new SimpleBooleanProperty();
public boolean isAlert() {
return alert.get();
}
public SimpleBooleanProperty alertProperty() {
return alert;
}
public void setAlert(boolean alert) {
this.alert.set(alert);
}
public String getText() { public String getText() {
return text.get(); return text.get();
} }
......
...@@ -88,6 +88,8 @@ public class ScriptController { ...@@ -88,6 +88,8 @@ public class ScriptController {
if (o != null) if (o != null)
o.getScriptArea().textProperty().removeListener(a -> updateSavePoints()); o.getScriptArea().textProperty().removeListener(a -> updateSavePoints());
n.getScriptArea().textProperty().addListener(a -> updateSavePoints()); n.getScriptArea().textProperty().addListener(a -> updateSavePoints());
updateSavePoints(); updateSavePoints();
}); });
...@@ -95,48 +97,30 @@ public class ScriptController { ...@@ -95,48 +97,30 @@ public class ScriptController {
} }
private void updateSavePoints() { private void updateSavePoints() {
try{ try {
Optional<ProofScript> ms = getMainScript().find(getCombinedAST()); Optional<ProofScript> ms = getMainScript().find(getCombinedAST());
if (ms.isPresent()) { if (ms.isPresent()) {
List<SavePoint> list = ms.get().getBody().stream() List<SavePoint> list = ms.get().getBody().stream()
.filter(SavePoint::isSaveCommand) .filter(SavePoint::isSaveCommand)
.map(a -> (CallStatement) a) .map(a -> (CallStatement) a)
.map(SavePoint::new) .map(SavePoint::new)
.collect(Collectors.toList()); .collect(Collectors.toList());
mainScriptSavePoints.setAll(list);
// loggerConsole.info("Found savepoints: " + list); mainScriptSavePoints.setAll(list);
}}catch (Exception e){}
//set alert gutter annotations
} List<SavePoint> noForceSp = mainScriptSavePoints.stream()
.filter(a -> a.getForce().equals(SavePoint.ForceOption.NO))
/* .collect(Collectors.toList());
public int getLineOfSavepoint(SavePoint sp) { noForceSp.forEach(e -> getMainScript().getScriptArea().setAlertMarker(e.getLineNumber()));
Optional<ProofScript> ms = getMainScript(). find(getCombinedAST());
loggerConsole.info("Found savepoints: " + list);
if(ms.isPresent()) {
List<CallStatement> list = ms.get().getBody().stream()
.filter(SavePoint::isSaveCommand)
.map(a -> (CallStatement) a).
collect(Collectors.toList());
if(!list.isEmpty()) {
for(int i = 0; i < list.size(); i++) {
if(true) {
Parameters param = list.get(i).getParameters();
String splistname = ((StringLiteral) param.get(new Variable("#2"))).getText();
if(splistname.equals(sp.getName())) {
int index = ms.get().getBody().indexOf(list.get(i));
return ms.get().getBody().get(index).getStartPosition().getLineNumber();
}
}
}
} }
} } catch (Exception e) {
return -1;
}
} }
*/
private void addDefaultInlineActions() { private void addDefaultInlineActions() {
actionSuppliers.add(new FindLabelInGoalList()); actionSuppliers.add(new FindLabelInGoalList());
...@@ -373,6 +357,7 @@ public class ScriptController { ...@@ -373,6 +357,7 @@ public class ScriptController {
} }
public void setMainScript(ProofScript proofScript) { public void setMainScript(ProofScript proofScript) {
MainScriptIdentifier msi = new MainScriptIdentifier(); MainScriptIdentifier msi = new MainScriptIdentifier();
msi.setLineNumber(proofScript.getStartPosition().getLineNumber()); msi.setLineNumber(proofScript.getStartPosition().getLineNumber());
msi.setScriptName(proofScript.getName()); msi.setScriptName(proofScript.getName());
......
...@@ -251,6 +251,15 @@ ...@@ -251,6 +251,15 @@
</tooltip> </tooltip>
</Button>--> </Button>-->
<Button disable="false">
<graphic>
<MaterialDesignIconView glyphName="KEYBOARD_BACKSPACE" size="24.0"/>
</graphic>
<tooltip>
<Tooltip text="Prune to savepoint"/>
</tooltip>
</Button>
<Button onAction="#continueAfterRun" disable="${controller.executeNotPossible}"> <Button onAction="#continueAfterRun" disable="${controller.executeNotPossible}">
<graphic> <graphic>
<MaterialDesignIconView glyphName="PLAY_CIRCLE_OUTLINE" size="24.0"/> <MaterialDesignIconView glyphName="PLAY_CIRCLE_OUTLINE" size="24.0"/>
......
...@@ -115,6 +115,13 @@ ...@@ -115,6 +115,13 @@
-fx-underline: true; -fx-underline: true;
} }
.underlinesave {
-rtfx-underline-cap: butt;
-rtfx-underline-color: @cyan;
-rtfx-underline-width: 2px;
-fx-underline: true;
}
.line-highlight-postmortem { .line-highlight-postmortem {
// -rtfx-background-color: @cyan; // -rtfx-background-color: @cyan;
-rtfx-background-color: @screenShotMarkerBase; -rtfx-background-color: @screenShotMarkerBase;
......
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