Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. /*
  2. * generated by Xtext 2.15.0
  3. */
  4. package mars.rover.validation
  5.  
  6. import org.eclipse.xtext.validation.Check
  7. import mars.rover.dSL.Mission
  8. import mars.rover.dSL.FindLakes
  9. import mars.rover.dSL.PushBricks
  10.  
  11. /**
  12. * This class contains custom validation rules.
  13. *
  14. * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation
  15. */
  16. class DSLValidator extends AbstractDSLValidator {
  17.  
  18. @Check
  19. def checkTimeout(Mission root) {
  20. val globalTimeout = root.duration.dl
  21. for (task: root.tasks){
  22. try{
  23. val lakeType = task.name as FindLakes
  24. if(lakeType !== null && lakeType instanceof FindLakes){
  25. if(lakeType.duration.dl > globalTimeout){
  26. error("FindLakes timeout cannot be greater than global timeout", null)
  27. }
  28. }
  29. } catch (Exception e){
  30.  
  31. }
  32.  
  33. try{
  34. val brickType = task.name as PushBricks
  35. if(brickType !== null && brickType instanceof PushBricks){
  36. if(brickType.duration.dl > globalTimeout){
  37. error("PushBricks timeout cannot be greater than global timeout", null)
  38. }
  39. }
  40. } catch (Exception e){
  41.  
  42. }
  43. }
  44. }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement