Skip to content

Commit 697ab8b

Browse files
Kirill GolubevKirill Golubev
authored andcommitted
expected invocation, got LogEleemnt fixed
1 parent efcaaf1 commit 697ab8b

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

liquidjava-umbrella/liquidjava-verifier/src/main/java/liquidjava/logging/LogElement.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import liquidjava.processor.context.PlacementInCode;
44
import spoon.reflect.code.CtComment;
5+
import spoon.reflect.code.CtInvocation;
56
import spoon.reflect.cu.SourcePosition;
67
import spoon.reflect.declaration.CtAnnotation;
78
import spoon.reflect.declaration.CtElement;
@@ -13,10 +14,8 @@
1314

1415
import java.lang.annotation.Annotation;
1516
import java.lang.annotation.ElementType;
16-
import java.util.Iterator;
17-
import java.util.List;
18-
import java.util.Map;
19-
import java.util.Set;
17+
import java.util.*;
18+
import java.util.function.Function;
2019
import java.util.stream.Collectors;
2120

2221
public class LogElement {
@@ -169,4 +168,10 @@ public LogElement strippedElement() {
169168
public String toString() {
170169
return elem.toString();
171170
}
171+
172+
public Optional<String> inspectInvocation(Function<CtInvocation<?>, String> insperctor){
173+
return elem instanceof CtInvocation<?> ?
174+
Optional.of(insperctor.apply((CtInvocation<?>) elem)) :
175+
Optional.empty();
176+
}
172177
}

liquidjava-umbrella/liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker/VCChecker.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -300,17 +300,14 @@ public void printSameStateError(LogElement element, Predicate expectedType, Stri
300300

301301
private void printError(Exception e, Predicate premisesBeforeChange, Predicate expectedType, LogElement element,
302302
HashMap<String, PlacementInCode> map) {
303-
String s = null;
304-
if (element instanceof CtInvocation) {
305-
CtInvocation<?> ci = (CtInvocation<?>) element;
303+
String s = element.inspectInvocation( ci -> {
306304
String totalS = ci.getExecutable().toString();
307305
if (ci.getTarget() != null) {
308306
int targetL = ci.getTarget().toString().length();
309307
totalS = ci.toString().substring(targetL + 1);
310308
}
311-
s = "Method invocation " + totalS + " in:";
312-
System.out.println();
313-
}
309+
return "Method invocation " + totalS + " in:";
310+
}).orElse(null);
314311

315312
Predicate etMessageReady = expectedType;// substituteByMap(expectedType, map);
316313
Predicate cSMTMessageReady = premisesBeforeChange;// substituteByMap(premisesBeforeChange, map);

0 commit comments

Comments
 (0)