Commit 32c4c671 authored by Sarah Grebing's avatar Sarah Grebing
Browse files

bug fix

parent 650ef727
Pipeline #12288 failed with stage
in 1 minute and 36 seconds
...@@ -158,6 +158,10 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -158,6 +158,10 @@ public class DebuggerMainWindowController implements Initializable {
scriptController.getDebugPositionHighlighter().highlight(newValue); scriptController.getDebugPositionHighlighter().highlight(newValue);
}); });
imodel.highlightedJavaLinesProperty().addListener((observable, oldValue, newValue) -> {
javaArea.enableCurrentLineHighlightingProperty();
});
Utils.addDebugListener(proofTreeController.currentGoalsProperty(), Utils::reprKeyDataList); Utils.addDebugListener(proofTreeController.currentGoalsProperty(), Utils::reprKeyDataList);
Utils.addDebugListener(proofTreeController.currentSelectedGoalProperty(), Utils::reprKeyData); Utils.addDebugListener(proofTreeController.currentSelectedGoalProperty(), Utils::reprKeyData);
Utils.addDebugListener(proofTreeController.currentHighlightNodeProperty()); Utils.addDebugListener(proofTreeController.currentHighlightNodeProperty());
...@@ -175,8 +179,14 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -175,8 +179,14 @@ public class DebuggerMainWindowController implements Initializable {
});*/ });*/
chosenContract.addListener(o -> { chosenContract.addListener(o -> {
javaCode.set(Utils.getJavaCode(chosenContract.get())); //javaCode.set(Utils.getJavaCode(chosenContract.get()));
try {
System.out.println(chosenContract.get().getHTMLText(getFacade().getService()));
String encoding = null; //encoding Plattform default
javaCode.set(FileUtils.readFileToString(javaFile.get(), encoding));
} catch (IOException e) {
e.printStackTrace();
}
showCodeDock(null); showCodeDock(null);
}); });
...@@ -186,12 +196,14 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -186,12 +196,14 @@ public class DebuggerMainWindowController implements Initializable {
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) { public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
try { try {
javaArea.setText(newValue); javaArea.setText(newValue);
javaArea.enableLineHighlightingProperty();
} catch (Exception e) { } catch (Exception e) {
LOGGER.catching(e); LOGGER.catching(e);
} }
} }
}); });
} }
...@@ -306,7 +318,7 @@ public class DebuggerMainWindowController implements Initializable { ...@@ -306,7 +318,7 @@ public class DebuggerMainWindowController implements Initializable {
@FXML @FXML
protected void loadKeYFile() { protected void loadKeYFile() {
File keyFile = openFileChooserOpenDialog("Select KeY File", "KeY Files", "key", "script"); File keyFile = openFileChooserOpenDialog("Select KeY File", "KeY Files", "key", "kps");
openKeyFile(keyFile); openKeyFile(keyFile);
} }
......
package edu.kit.formal.gui.controller; package edu.kit.formal.gui.controller;
import com.google.common.eventbus.EventBus; import com.google.common.eventbus.EventBus;
import de.uka.ilkd.key.logic.PosInOccurrence;
import de.uka.ilkd.key.rule.TacletApp; import de.uka.ilkd.key.rule.TacletApp;
import edu.kit.formal.gui.controls.ScriptArea; import edu.kit.formal.gui.controls.ScriptArea;
import lombok.Data; import lombok.Data;
...@@ -37,5 +38,6 @@ public class Events { ...@@ -37,5 +38,6 @@ public class Events {
@RequiredArgsConstructor @RequiredArgsConstructor
public static class TacletApplicationEvent { public static class TacletApplicationEvent {
private final TacletApp app; private final TacletApp app;
private final PosInOccurrence pio;
} }
} }
...@@ -6,6 +6,7 @@ import edu.kit.formal.interpreter.data.KeyData; ...@@ -6,6 +6,7 @@ import edu.kit.formal.interpreter.data.KeyData;
import javafx.beans.Observable; import javafx.beans.Observable;
import javafx.beans.property.ReadOnlyObjectProperty; import javafx.beans.property.ReadOnlyObjectProperty;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.control.ListCell; import javafx.scene.control.ListCell;
...@@ -45,19 +46,26 @@ public class InspectionView extends BorderPane { ...@@ -45,19 +46,26 @@ public class InspectionView extends BorderPane {
if (newValue != null && newValue.getData() != null) { if (newValue != null && newValue.getData() != null) {
getSequentView().setNode(newValue.getData().getNode()); getSequentView().setNode(newValue.getData().getNode());
getSequentView().setGoal(newValue.getData().getGoal()); getSequentView().setGoal(newValue.getData().getGoal());
// TODO weigl: get marked lines of the program, and set it // TODO weigl: get marked lines of the program, and set it
model.get().highlightedJavaLinesProperty().get() /*model.get().highlightedJavaLinesProperty().get()
.clear(); .clear();*/
model.get().setHighlightedJavaLines(FXCollections.observableSet(newValue.getData().constructLinesSet()));
System.out.println(newValue.getData().constructLinesSet());
} }
}); });
model.get().goalsProperty().bindBidirectional(goalView.itemsProperty()); model.get().goalsProperty().bindBidirectional(goalView.itemsProperty());
getGoalView().setCellFactory(GoalNodeListCell::new); getGoalView().setCellFactory(GoalNodeListCell::new);
Utils.addDebugListener(model.get().goalsProperty()); Utils.addDebugListener(model.get().goalsProperty());
Utils.addDebugListener(model.get().selectedGoalNodeToShowProperty()); Utils.addDebugListener(model.get().selectedGoalNodeToShowProperty());
Utils.addDebugListener(model.get().currentInterpreterGoalProperty()); Utils.addDebugListener(model.get().currentInterpreterGoalProperty());
Utils.addDebugListener(model.get().highlightedJavaLinesProperty());
/*TODO redefine CSS bases on selected mode /*TODO redefine CSS bases on selected mode
mode.addListener(o -> { mode.addListener(o -> {
...@@ -71,6 +79,7 @@ public class InspectionView extends BorderPane { ...@@ -71,6 +79,7 @@ public class InspectionView extends BorderPane {
*/ */
} }
public SequentView getSequentView() { public SequentView getSequentView() {
return sequentView; return sequentView;
} }
......
package edu.kit.formal.gui.controls; package edu.kit.formal.gui.controls;
import com.google.common.eventbus.Subscribe;
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.logic.SequentFormula;
import edu.kit.formal.gui.controller.Events;
import edu.kit.formal.gui.model.Breakpoint; import edu.kit.formal.gui.model.Breakpoint;
import edu.kit.formal.gui.model.MainScriptIdentifier; import edu.kit.formal.gui.model.MainScriptIdentifier;
import edu.kit.formal.proofscriptparser.Facade; import edu.kit.formal.proofscriptparser.Facade;
...@@ -378,6 +381,7 @@ public class ScriptArea extends CodeArea { ...@@ -378,6 +381,7 @@ public class ScriptArea extends CodeArea {
public void removeExecutionMarker() { public void removeExecutionMarker() {
setText(getTextWithoutMarker()); setText(getTextWithoutMarker());
//Events.unregister(this);
} }
private String getTextWithoutMarker() { private String getTextWithoutMarker() {
...@@ -386,10 +390,33 @@ public class ScriptArea extends CodeArea { ...@@ -386,10 +390,33 @@ public class ScriptArea extends CodeArea {
public void insertExecutionMarker(int pos) { public void insertExecutionMarker(int pos) {
LOGGER.debug("ScriptArea.insertExecutionMarker"); LOGGER.debug("ScriptArea.insertExecutionMarker");
Events.register(this);
String text = getText(); String text = getText();
setText(text.substring(0, pos) + EXECUTION_MARKER + text.substring(pos)); setText(text.substring(0, pos) + EXECUTION_MARKER + text.substring(pos));
} }
@Subscribe
public void handle(Events.TacletApplicationEvent tap) {
String tapName = tap.getApp().taclet().displayName();
SequentFormula seqForm = tap.getPio().sequentFormula();
System.out.println(tap.getPio().sequentFormula());
//String on = tap.getApp().ifFormulaInstantiations().toString();
String text = getText();
System.out.println(text);
int posExecMarker = this.getExecutionMarkerPosition();
setText(text.substring(0, posExecMarker) + "\n" + tapName + " on=\"" + seqForm + "\";\n" + text.substring(posExecMarker + 1));
Events.unregister(this);
//this.getMainScript().getScriptArea().insertText(this.getExecutionMarkerPosition(), tapName+" "+on+ ";");
}
public int getExecutionMarkerPosition() { public int getExecutionMarkerPosition() {
return getText().lastIndexOf(EXECUTION_MARKER); return getText().lastIndexOf(EXECUTION_MARKER);
} }
......
...@@ -130,7 +130,7 @@ public class SequentView extends CodeArea { ...@@ -130,7 +130,7 @@ public class SequentView extends CodeArea {
clear(); clear();
insertText(0, backend.getString()); insertText(0, backend.getString());
if (node.get().isClosed()) { if (node.get().isClosed()) {
this.setBorder(new Border(new BorderStroke(Color.RED, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT))); this.setBorder(new Border(new BorderStroke(Color.GREEN, BorderStrokeStyle.SOLID, CornerRadii.EMPTY, BorderWidths.DEFAULT)));
this.getStyleClass().add("closed-sequent-view"); this.getStyleClass().add("closed-sequent-view");
} }
} }
......
...@@ -9,10 +9,7 @@ import de.uka.ilkd.key.pp.AbbrevMap; ...@@ -9,10 +9,7 @@ import de.uka.ilkd.key.pp.AbbrevMap;
import de.uka.ilkd.key.pp.NotationInfo; import de.uka.ilkd.key.pp.NotationInfo;
import de.uka.ilkd.key.pp.PosInSequent; import de.uka.ilkd.key.pp.PosInSequent;
import de.uka.ilkd.key.proof.Goal; import de.uka.ilkd.key.proof.Goal;
import de.uka.ilkd.key.rule.BuiltInRule; import de.uka.ilkd.key.rule.*;
import de.uka.ilkd.key.rule.RuleSet;
import de.uka.ilkd.key.rule.Taclet;
import de.uka.ilkd.key.rule.TacletApp;
import edu.kit.formal.gui.controller.DebuggerMainWindowController; import edu.kit.formal.gui.controller.DebuggerMainWindowController;
import edu.kit.formal.gui.controller.Events; import edu.kit.formal.gui.controller.Events;
import edu.kit.formal.interpreter.KeYProofFacade; import edu.kit.formal.interpreter.KeYProofFacade;
...@@ -134,8 +131,8 @@ public class TacletContextMenu extends ContextMenu { ...@@ -134,8 +131,8 @@ public class TacletContextMenu extends ContextMenu {
*/ */
private static ImmutableList<TacletApp> removeRewrites( private static ImmutableList<TacletApp> removeRewrites(
ImmutableList<TacletApp> list) { ImmutableList<TacletApp> list) {
return list; // return list;
/*
ImmutableList<TacletApp> result = ImmutableSLList.<TacletApp>nil(); ImmutableList<TacletApp> result = ImmutableSLList.<TacletApp>nil();
Iterator<TacletApp> it = list.iterator(); Iterator<TacletApp> it = list.iterator();
...@@ -145,7 +142,7 @@ public class TacletContextMenu extends ContextMenu { ...@@ -145,7 +142,7 @@ public class TacletContextMenu extends ContextMenu {
result = (taclet instanceof RewriteTaclet ? result result = (taclet instanceof RewriteTaclet ? result
: result.prepend(tacletApp)); : result.prepend(tacletApp));
} }
return result;*/ return result;
} }
/** /**
...@@ -319,8 +316,8 @@ public class TacletContextMenu extends ContextMenu { ...@@ -319,8 +316,8 @@ public class TacletContextMenu extends ContextMenu {
((TacletMenuItem) event.getSource()).getTaclet(), goal, ((TacletMenuItem) event.getSource()).getTaclet(), goal,
pos.getPosInOccurrence());*/ pos.getPosInOccurrence());*/
System.out.println("event = [" + event + "]"); //System.out.println("event = [" + event + "]");
Events.fire(new Events.TacletApplicationEvent(event)); Events.fire(new Events.TacletApplicationEvent(event, pos.getPosInOccurrence()));
} }
/** /**
......
...@@ -23,8 +23,8 @@ public class InspectionModel { ...@@ -23,8 +23,8 @@ public class InspectionModel {
private final ObjectProperty<GoalNode<KeyData>> currentInterpreterGoal = new SimpleObjectProperty<>(this, "currentInterpreterGoal"); private final ObjectProperty<GoalNode<KeyData>> currentInterpreterGoal = new SimpleObjectProperty<>(this, "currentInterpreterGoal");
private final MapProperty<GoalNode, Color> colorofEachGoalNodeinListView = new SimpleMapProperty<>(FXCollections.observableHashMap()); private final MapProperty<GoalNode, Color> colorofEachGoalNodeinListView = new SimpleMapProperty<>(FXCollections.observableHashMap());
//private final StringProperty javaString = new SimpleStringProperty(); //private final StringProperty javaString = new SimpleStringProperty();
private final SetProperty<Integer> highlightedJavaLines = new SimpleSetProperty<>(FXCollections.observableSet()); private final SetProperty<Integer> highlightedJavaLines = new SimpleSetProperty<>(FXCollections.observableSet(), "highlightedJavaLines");
private final BooleanProperty closable = new SimpleBooleanProperty(); private final BooleanProperty closable = new SimpleBooleanProperty(this, "INspectionViewClosableProperty");
private final BooleanProperty isInterpreterTab = new SimpleBooleanProperty(); private final BooleanProperty isInterpreterTab = new SimpleBooleanProperty();
private ObjectProperty<Mode> mode = new SimpleObjectProperty<>(); private ObjectProperty<Mode> mode = new SimpleObjectProperty<>();
......
package edu.kit.formal.interpreter.data; package edu.kit.formal.interpreter.data;
import de.uka.ilkd.key.control.KeYEnvironment; import de.uka.ilkd.key.control.KeYEnvironment;
import de.uka.ilkd.key.java.SourceElement;
import de.uka.ilkd.key.proof.Goal; import de.uka.ilkd.key.proof.Goal;
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;
import lombok.*; import lombok.*;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
/** /**
...@@ -20,6 +23,7 @@ import java.util.function.Function; ...@@ -20,6 +23,7 @@ import java.util.function.Function;
@RequiredArgsConstructor @RequiredArgsConstructor
public class KeyData { public class KeyData {
private static final String SEPARATOR = " // "; private static final String SEPARATOR = " // ";
private static final String RANGE_SEPARATOR = " -- ";
private final KeYEnvironment env; private final KeYEnvironment env;
private final Proof proof; private final Proof proof;
private Node node; private Node node;
...@@ -38,6 +42,7 @@ public class KeyData { ...@@ -38,6 +42,7 @@ public class KeyData {
this.proof = data.proof; this.proof = data.proof;
this.goal = node; this.goal = node;
this.node = goal.node(); this.node = goal.node();
} }
public KeyData(Goal g, KeYEnvironment environment, Proof proof) { public KeyData(Goal g, KeYEnvironment environment, Proof proof) {
...@@ -124,13 +129,21 @@ public class KeyData { ...@@ -124,13 +129,21 @@ public class KeyData {
/** /**
* Get lines of active statement * Get lines of active statement
* @return line of active satetment in orginal file (-1 if rewritten by KeY or not applicable) * @return line of active satetment in original file (-1 if rewritten by KeY or not applicable)
*/ */
public String getProgramLinesLabel() { public String getProgramLinesLabel() {
if (programLinesLabel == null) { if (programLinesLabel == null) {
programLinesLabel = constructLabel(n -> programLinesLabel = constructLabel(n -> {
Integer.toString(n.getNodeInfo().getActiveStatement().getPositionInfo().getStartPosition().getLine()) int startPos = n.getNodeInfo().getActiveStatement().getPositionInfo().getStartPosition().getLine();
); int endPos = n.getNodeInfo().getActiveStatement().getPositionInfo().getEndPosition().getLine();
if (startPos == endPos) {
return Integer.toString(startPos);
} else {
String start = Integer.toString(startPos);
String end = Integer.toString(endPos);
return start + RANGE_SEPARATOR + end;
}
});
} }
return programLinesLabel; return programLinesLabel;
} }
...@@ -157,4 +170,32 @@ public class KeyData { ...@@ -157,4 +170,32 @@ public class KeyData {
return node; return node;
//return getGoal().node(); //return getGoal().node();
} }
public Set<Integer> constructLinesSet() {
Set<Integer> set = new HashSet<>();
Node cur = getNode();
do {
SourceElement activeStatement = cur.getNodeInfo().getActiveStatement();
if (activeStatement != null) {
int startPos = activeStatement.getPositionInfo().getStartPosition().getLine();
int endPos = activeStatement.getPositionInfo().getEndPosition().getLine();
if (startPos != -1) {
if (startPos == endPos) {
set.add(startPos);
} else {
set.add(startPos);
set.add(endPos);
}
}
}
cur = cur.parent();
} while (cur != null);
return set;
}
} }
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