Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #3156 #3157

Merged
merged 1 commit into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package de.uka.ilkd.key.proof;

import java.util.Optional;

import de.uka.ilkd.key.java.Position;

public class SVInstantiationParserException extends SVInstantiationExceptionWithPosition {
Expand All @@ -18,27 +20,31 @@ public SVInstantiationParserException(String instantiation, Position position, S
this.detail = (detail == null) ? "" : detail;
}

private String space(int i) {
StringBuilder res = new StringBuilder();
for (int j = 0; j < i; j++) {
res.append(" ");
private Optional<String> getInstantiationRow() {
if (getPosition().column() <= 0) {
return Optional.empty();
}
String[] rows = instantiation.split("\n");
var line = getPosition().line() - 1;
if (!(line < rows.length)) {
return Optional.empty();
}
return res.toString();
return Optional.of(rows[line]);
}

public String getMessage() {
int column = getPosition().column();

String msg = super.getMessage();
// needs non-prop font: msg +="\n"+inst;
if (column > 0) {
Optional<String> row = getInstantiationRow();
if (row.isPresent()) {
// needs non-prop font: msg +="\n"+space(column-1)+"^";
String[] rows = instantiation.split("\n");
StringBuilder sb = new StringBuilder(rows[getPosition().line() - 1]);
var sb = new StringBuilder(row.get());
sb.insert(column - 1, " ~~> ");
msg += "\noccurred at: " + sb;
} else {
msg += "\noccurred in:" + instantiation;
msg += "\noccurred in: " + instantiation;
}

msg += "\nDetail:\n" + detail;
Expand Down
3 changes: 2 additions & 1 deletion key.core/src/main/java/de/uka/ilkd/key/rule/TacletApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,8 @@ public TacletApp addCheckedInstantiation(SchemaVariable sv, Term term, Services

if (newMC == null) {
throw new IllegalInstantiationException(
"Instantiation " + term + " of " + sv + "does not satisfy the variable conditions");
"Instantiation " + term + " of " + sv
+ " does not satisfy the variable conditions");
}

SVInstantiations svInst = newMC.getInstantiations();
Expand Down