Skip to content

Commit cad6b1b

Browse files
committed
Catch Errors in Visitors
1 parent be1a0f2 commit cad6b1b

File tree

3 files changed

+195
-107
lines changed

3 files changed

+195
-107
lines changed

liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker/ExternalRefinementTypeChecker.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@ public <T> void visitCtInterface(CtInterface<T> intrface) {
4848
diagnostics.add(new ExternalClassNotFoundWarning(intrface, message, prefix));
4949
return;
5050
}
51-
getRefinementFromAnnotation(intrface);
52-
handleStateSetsFromAnnotation(intrface);
51+
try {
52+
getRefinementFromAnnotation(intrface);
53+
handleStateSetsFromAnnotation(intrface);
54+
} catch (LJError e) {
55+
diagnostics.add(e);
56+
return;
57+
}
5358
super.visitCtInterface(intrface);
5459
}
5560
}
@@ -98,7 +103,12 @@ public <R> void visitCtMethod(CtMethod<R> method) {
98103
}
99104
}
100105
MethodsFunctionsChecker mfc = new MethodsFunctionsChecker(this);
101-
mfc.getMethodRefinements(method, prefix);
106+
try {
107+
mfc.getMethodRefinements(method, prefix);
108+
} catch (LJError e) {
109+
diagnostics.add(e);
110+
return;
111+
}
102112
super.visitCtMethod(method);
103113
}
104114

liquidjava-verifier/src/main/java/liquidjava/processor/refinement_checker/MethodsFirstChecker.java

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package liquidjava.processor.refinement_checker;
22

3-
import static liquidjava.diagnostics.Diagnostics.diagnostics;
4-
53
import java.util.ArrayList;
64
import java.util.List;
75

6+
import static liquidjava.diagnostics.Diagnostics.diagnostics;
7+
8+
import liquidjava.diagnostics.errors.LJError;
89
import liquidjava.processor.context.Context;
910
import liquidjava.processor.refinement_checker.general_checkers.MethodsFunctionsChecker;
1011
import spoon.reflect.declaration.CtClass;
@@ -49,8 +50,13 @@ public <T> void visitCtClass(CtClass<T> ctClass) {
4950
if (ct instanceof CtClass)
5051
visitCtClass((CtClass<?>) ct);
5152
}
52-
getRefinementFromAnnotation(ctClass);
53-
handleStateSetsFromAnnotation(ctClass);
53+
try {
54+
getRefinementFromAnnotation(ctClass);
55+
handleStateSetsFromAnnotation(ctClass);
56+
} catch (LJError e) {
57+
diagnostics.add(e);
58+
return;
59+
}
5460
super.visitCtClass(ctClass);
5561
}
5662

@@ -63,23 +69,38 @@ public <T> void visitCtInterface(CtInterface<T> intrface) {
6369
if (getExternalRefinement(intrface).isPresent())
6470
return;
6571

66-
getRefinementFromAnnotation(intrface);
67-
handleStateSetsFromAnnotation(intrface);
72+
try {
73+
getRefinementFromAnnotation(intrface);
74+
handleStateSetsFromAnnotation(intrface);
75+
} catch (LJError e) {
76+
diagnostics.add(e);
77+
return;
78+
}
6879
super.visitCtInterface(intrface);
6980
}
7081

7182
@Override
7283
public <T> void visitCtConstructor(CtConstructor<T> c) {
7384
context.enterContext();
74-
getRefinementFromAnnotation(c);
75-
mfc.getConstructorRefinements(c);
85+
try {
86+
getRefinementFromAnnotation(c);
87+
mfc.getConstructorRefinements(c);
88+
} catch (LJError e) {
89+
diagnostics.add(e);
90+
return;
91+
}
7692
super.visitCtConstructor(c);
7793
context.exitContext();
7894
}
7995

8096
public <R> void visitCtMethod(CtMethod<R> method) {
8197
context.enterContext();
82-
mfc.getMethodRefinements(method);
98+
try {
99+
mfc.getMethodRefinements(method);
100+
} catch (LJError e) {
101+
diagnostics.add(e);
102+
return;
103+
}
83104
super.visitCtMethod(method);
84105
context.exitContext();
85106
}

0 commit comments

Comments
 (0)