4 package robots.missions.validation
6 import java.util.LinkedList
8 import org.eclipse.xtext.validation.Check
9 import robots.missions.taskDSL.Action
10 import robots.missions.taskDSL.Behaviour
11 import robots.missions.taskDSL.Mission
12 import robots.missions.taskDSL.Robot
14 //import org.eclipse.xtext.validation.Check
16 * This class contains custom validation rules.
18 * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation
20 class TaskDSLValidator extends AbstractTaskDSLValidator {
22 def checkRobot(Robot r){
24 warning("Acceleration set to zero, this could lead to non moving robot", null);
27 warning("Acceleration set to zero, this could lead to non moving robot", null);
32 def checkBehavioursl(Mission m) {
33 var List<String> empty = new LinkedList<String>();
34 var List<String> all = new LinkedList<String>();
35 var List<String> warned = new LinkedList<String>();
36 for(Behaviour b : m.behaviours){
40 if(all.contains(b.name) && !warned.contains(b.name)){
41 warning("Behaviour '" + b.name + "' multiple times in the behaviourlist.", null);
47 warning("Multiple behaviours without takeControl predicate. You might want to remove some of: " + empty.toString(), null);
52 def checkActions(Action a) {
53 if(a.turnType != null && a.turnType.turnDir == null){
54 if(a.turnType.start == a.turnType.end){
55 error("Start and end cannot be the same", null);
56 } else if(a.turnType.start > a.turnType.end){
57 error("Start should be smaller then end", null);