Skip to content
Snippets Groups Projects
Commit 36e81792 authored by dgelessus's avatar dgelessus
Browse files

Make type check error messages a bit more helpful

parent d14634fe
No related branches found
No related tags found
No related merge requests found
Pipeline #106354 passed
......@@ -94,11 +94,10 @@ public class VOTypeChecker extends DepthFirstAdapter {
private PersistentHashSet<AnimatorState> visitIdentifierNode(AIdentifierVo node, PersistentHashSet<AnimatorState> animatorState) {
final String id = node.getIdentifierLiteral().getText();
if (!voParser.getTasks().containsKey(id)) {
throw new VOTypeCheckException("Scope error in VO");
throw new VOTypeCheckException("Unknown validation task identifier: " + id);
}
VTType type = voParser.getTasks().get(id);
PersistentHashSet<AnimatorState> newAnimatorState = animatorState;
boolean valid = true;
switch (type) {
case RELOAD:
newAnimatorState = newAnimatorState.cons(AnimatorState.TRACE);
......@@ -112,23 +111,26 @@ public class VOTypeChecker extends DepthFirstAdapter {
newAnimatorState = newAnimatorState.disjoin(AnimatorState.STATE_SPACE);
break;
case TRACE:
valid = newAnimatorState.contains(AnimatorState.TRACE);
if (!newAnimatorState.contains(AnimatorState.TRACE)) {
throw new VOTypeCheckException("Validation task " + id + " requires a trace");
}
break;
case STATE_SPACE:
valid = newAnimatorState.contains(AnimatorState.STATE_SPACE);
if (!newAnimatorState.contains(AnimatorState.STATE_SPACE)) {
throw new VOTypeCheckException("Validation task " + id + " requires a state space");
}
newAnimatorState = newAnimatorState.disjoin(AnimatorState.TRACE);
newAnimatorState = newAnimatorState.disjoin(AnimatorState.STATE_SPACE);
break;
case EXPLORE:
valid = newAnimatorState.contains(AnimatorState.TRACE);
if (!newAnimatorState.contains(AnimatorState.TRACE)) {
throw new VOTypeCheckException("Validation task " + id + " requires a trace");
}
newAnimatorState = newAnimatorState.disjoin(AnimatorState.TRACE);
break;
default:
break;
}
if(!valid) {
throw new VOTypeCheckException("Type error in VO");
}
return newAnimatorState;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment