Commit a552cb5d authored by Lulu Luong's avatar Lulu Luong

Bugfixes made:

- script execution not considering multiple goals - userinformation added
- Execution Marker removed
- new java problem loadable after one was already loaded
- java problem -> reload -> execute script throws ex "could not clear env exeption" -> but still works
parent 6ede00a5
Pipeline #27613 passed with stages
in 113 minutes and 16 seconds
......@@ -14,6 +14,7 @@ import edu.kit.iti.formal.psdbg.interpreter.data.KeyData;
import edu.kit.iti.formal.psdbg.interpreter.data.State;
import edu.kit.iti.formal.psdbg.interpreter.data.VariableAssignment;
import edu.kit.iti.formal.psdbg.parser.ast.CallStatement;
import javafx.scene.control.Alert;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.commons.io.IOUtils;
......@@ -22,6 +23,8 @@ import org.apache.logging.log4j.Logger;
import org.key_project.util.collection.ImmutableList;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Method;
import java.net.URISyntaxException;
import java.net.URL;
......@@ -62,7 +65,26 @@ public class ProofScriptCommandBuilder implements CommandHandler<KeyData> {
VariableAssignment params, KeyData data) {
ProofScriptCommand c = commands.get(call.getCommand());
State<KeyData> state = interpreter.getCurrentState();
//multiple goals exist
if(state.getGoals().size() > 1) {
throw new IllegalStateException("Multiple open goals: Please use a selector.");
/*
//TODO: Utils showWarning
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Multiple open Goals");
alert.setHeaderText("Multiple open Goals");
alert.setContentText("There are multiple open goals so its undefined on which goal the command " + call.getCommand() +" should be applied. Please use a selector.");
alert.setWidth(400);
alert.setHeight(400);
alert.setHeight(600);
alert.setWidth(400);
alert.showAndWait();
*/
}
GoalNode<KeyData> expandedNode = state.getSelectedGoalNode();
KeyData kd = expandedNode.getData();
Map<String, Object> map = new HashMap<>();
params.asMap().forEach((k, v) -> {
......
......@@ -807,6 +807,7 @@ public class DebuggerMain implements Initializable {
if (javaFile != null) {
model.setJavaFile(javaFile);
model.setInitialDirectory(javaFile.getParentFile());
contractLoaderService.reset();
contractLoaderService.start();
}
}
......@@ -1166,7 +1167,6 @@ public class DebuggerMain implements Initializable {
} else {
throw new RuntimeException("Something went wrong when reloading");
}
}
/* public void handle(Events.TacletApplicationEvent tap){
......@@ -1408,7 +1408,31 @@ public class DebuggerMain implements Initializable {
protected void succeeded() {
statusBar.publishMessage("Contract loaded");
List<Contract> contracts = getValue();
ContractChooser cc = new ContractChooser(FACADE.getService(), contracts);
/*
String javaFile = model.getJavaFile().getName();
List<Contract> filteredContracts = new ArrayList<>();
for (Contract contract : contracts) {
String contractFile = contract.getKJT().getFullName();
if (javaFile == contractFile) {
filteredContracts.add(contract);
}
}
if (filteredContracts.size() == 0) {
Utils.showInfoDialog("No loadable contract", "No loadable contract",
"There's no loadable contract for the chosen java file.");
return;
}
*/
ContractChooser cc = null;
try {
cc = new ContractChooser(FACADE.getService(), FACADE.getContractsForJavaFile(model.getJavaFile()));
} catch (ProblemLoaderException e) {
e.printStackTrace();
}
cc.showAndWait().ifPresent(result -> {
model.setChosenContract(result);
......
......@@ -66,9 +66,8 @@ public class ScriptExecutionController {
mainCtrl.FACADE.reload(mainCtrl.getModel().getKeyFile());
} catch (ProofInputException | ProblemLoaderException e) {
LOGGER.error(e);
Utils.showExceptionDialog("Loading Error", "Could not clear Environment", "There was an error when clearing old environment",
e
);
// Utils.showExceptionDialog("Loading Error", "Could not clear Environment", "There was an error when clearing old environment", e );
}
}
......
......@@ -88,7 +88,6 @@ import static org.fxmisc.wellbehaved.event.InputMap.*;
public class ScriptArea extends BorderPane {
public static final Logger LOGGER = LogManager.getLogger(ScriptArea.class);
public static final Logger CONSOLE_LOGGER = LogManager.getLogger(ScriptArea.class);
public static final String EXECUTION_MARKER = "\u2316";
public static final FileReloadingService FILE_RELOADING_SERVICE = new FileReloadingService();
......@@ -467,11 +466,12 @@ public class ScriptArea extends BorderPane {
}
@Deprecated
private boolean hasExecutionMarker() {
return getText().contains(EXECUTION_MARKER);
}
@Deprecated
public int getExecutionMarkerPosition() {
return getText().lastIndexOf(EXECUTION_MARKER);
}
......@@ -587,11 +587,13 @@ public class ScriptArea extends BorderPane {
return dirty;
}
@Deprecated
public void removeExecutionMarker() {
setText(getTextWithoutMarker());
//Events.unregister(this);
}
@Deprecated
private String getTextWithoutMarker() {
return getText().replace("" + EXECUTION_MARKER, "");
}
......@@ -601,6 +603,7 @@ public class ScriptArea extends BorderPane {
*
* @param pos
*/
@Deprecated
public void insertExecutionMarker(int pos) {
LOGGER.debug("ScriptArea.insertExecutionMarker");
Events.register(this);
......@@ -971,6 +974,7 @@ public class ScriptArea extends BorderPane {
}*/
}
@Deprecated
public void setExecutionMarker(ActionEvent event) {
LOGGER.debug("ScriptAreaContextMenu.setExecutionMarker");
int pos = codeArea.getCaretPosition();
......
......@@ -10,7 +10,8 @@
<MenuItem text="Show post mortem" onAction="#showPostMortem"/>
<SeparatorMenuItem/>
<MenuItem text="Set Main Script" onAction="#setMainScript"/>
<MenuItem text="Set Execution Marker" onAction="#setExecutionMarker" accelerator="Ctrl+m"/>
<!--<MenuItem text="Set Execution Marker" onAction="#setExecutionMarker" accelerator="Ctrl+m"/>
-->
</items>
</fx:root>
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