Commit 0c62d6a5 authored by dgelessus's avatar dgelessus
Browse files

Use new ProB 2 APIs for getting visualization commands by name

parent a654e73e
Pipeline #50947 passed with stage
in 7 minutes and 24 seconds
......@@ -101,11 +101,12 @@ public final class DotCommand implements Command {
}
final Trace trace = this.animationSelector.getCurrentTrace();
final DotVisualizationCommand dotCommand = DotVisualizationCommand.getAll(trace.getCurrentState())
.stream()
.filter(i -> command.equals(i.getCommand()))
.findAny()
.orElseThrow(() -> new UserErrorException("No such dot command: " + command));
final DotVisualizationCommand dotCommand;
try {
dotCommand = DotVisualizationCommand.getByName(command, trace.getCurrentState());
} catch (final IllegalArgumentException e) {
throw new UserErrorException("No such dot command: " + command, e);
}
// Provide source code (if any) to error highlighter
final Supplier<String> execute = () -> dotCommand.visualizeAsSvgToString(dotCommandArgs);
......
......@@ -73,11 +73,7 @@ public final class TableCommand implements Command {
final String code = kernel.insertLetVariables(args.get(EXPRESSION_PARAM));
final IEvalElement formula = CommandUtils.withSourceCode(code, () -> kernel.parseFormula(code, FormulaExpand.EXPAND));
final TableData table = TableVisualizationCommand.getAll(trace.getCurrentState())
.stream()
.filter(c -> "expr_as_table".equals(c.getCommand()))
.findAny()
.orElseThrow(AssertionError::new)
final TableData table = TableVisualizationCommand.getByName(TableVisualizationCommand.EXPRESSION_AS_TABLE_NAME, trace.getCurrentState())
.visualize(Collections.singletonList(formula));
final StringBuilder sbPlain = new StringBuilder();
......
Supports Markdown
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