SemanticAdaptationValidator.xtend 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*******************************************************************************
  2. * Copyright (c) 2015 itemis AG (http://www.itemis.eu) and others.
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * http://www.eclipse.org/legal/epl-v10.html
  7. *******************************************************************************/
  8. package be.uantwerpen.ansymo.semanticadaptation.validation
  9. /**
  10. * Custom validation rules.
  11. *
  12. * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation
  13. */
  14. class SemanticAdaptationValidator extends AbstractSemanticAdaptationValidator {
  15. // @Inject Interpreter interpreter
  16. //
  17. // @Check
  18. // def checkDivByZero(Div div) {
  19. // val bigDecimal = interpreter.evaluate(div.right)
  20. // if (bigDecimal.doubleValue()==0.0)
  21. // error("Division by zero detected.", DIV__RIGHT)
  22. // }
  23. //
  24. // public static val String NORMALIZABLE = "normalizable-expression"
  25. //
  26. // @Check
  27. // def void checkNormalizable(Expression expr) {
  28. // // ignore literals
  29. // if (expr instanceof NumberLiteral || expr instanceof FunctionCall)
  30. // return;
  31. // // ignore evaluations
  32. // if (EcoreUtil2.getContainerOfType(expr, Evaluation)!=null)
  33. // return;
  34. //
  35. // val contents = expr.eAllContents
  36. // while(contents.hasNext()) {
  37. // val next = contents.next()
  38. // if (next instanceof FunctionCall)
  39. // return
  40. // }
  41. // val decimal = interpreter.evaluate(expr)
  42. // if (decimal.toString().length()<=8) {
  43. // warning(
  44. // "Expression could be normalized to constant '"+decimal+"'",
  45. // null,
  46. // ValidationMessageAcceptor.INSIGNIFICANT_INDEX,
  47. // NORMALIZABLE,
  48. // decimal.toString())
  49. // }
  50. // }
  51. }