Parameters in error() using the Xtext/Xtend validation [message #1712065] |
Wed, 21 October 2015 07:57 |
John Cole Messages: 66 Registered: June 2013 |
Member |
|
|
Hello everyone,
this is an extract of my DSL:
Element:
'Element' name=ID
('firstValue' firstValue=DOUBLE firstValueUnit=UNIT)? &
'end' 'Element'
;
enum UNIT:
mm='mm' |
cm='cm' |
m='m' |
;
And this is how I use it in my editor:
Element MyElement
firstValue -3.536 cm
end Element
I now would like to use the validator, which is generated automatically by Xtext. This is how it looks like:
class MyLanguageValidator extends AbstractMyLanguageValidator {
@Check
def unitCheck(Element element) {
val firstValueUnit = element.firstValueUnit;
if (firstValueUnit != null) {
if (!firstValueUnit.equals("m")) {
// TODO: show warning at right position!
}
}
}
}
The problem is, that the parameters are dubious to me. I tried to google EStructuralFeature but I haven't found useful information, what is expected at this point.
I would like to show an error message "firstValue must be defined in m" at the corresponding line.
I tried to use this:
error("firstValue must be defined in m", null, MyLanguagePackage.ELEMENT__FIRSTVALUE_UNIT);
Unfortunately it marks the complete Element block and also shows this warning, even if firstElement is defined in m.
How do I define a correct error message at the right position, based on the given example?
Greets,
John
[Updated on: Wed, 21 October 2015 07:57] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04160 seconds