diff --git a/key.core/src/main/java/de/uka/ilkd/key/proof/SVInstantiationParserException.java b/key.core/src/main/java/de/uka/ilkd/key/proof/SVInstantiationParserException.java index aeb857edfbd..e6f50ea16a6 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/proof/SVInstantiationParserException.java +++ b/key.core/src/main/java/de/uka/ilkd/key/proof/SVInstantiationParserException.java @@ -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 { @@ -18,12 +20,16 @@ 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 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() { @@ -31,14 +37,14 @@ public String getMessage() { String msg = super.getMessage(); // needs non-prop font: msg +="\n"+inst; - if (column > 0) { + Optional 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; diff --git a/key.core/src/main/java/de/uka/ilkd/key/rule/TacletApp.java b/key.core/src/main/java/de/uka/ilkd/key/rule/TacletApp.java index aaa1cb926ea..5aa3f59ea75 100644 --- a/key.core/src/main/java/de/uka/ilkd/key/rule/TacletApp.java +++ b/key.core/src/main/java/de/uka/ilkd/key/rule/TacletApp.java @@ -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();