I want to check the type of an feature inside my Xtend validator.
The Xtext grammar looks like the following:
Element:
'Element' name=ID
'feature' feature=DOUBLE
'end' 'Element'
;
This is how it is used:
Element MyElement
feature 2.5
end Element
If trying to use a INTEGER
value instead of DOUBLE
for feature
, the editor shows the error:
mismatched input '84900' expecting RULE_DOUBLE
I would like to overwrite the message. Therefore I've created a validation method inside my validator. In the method I would like to check the type of the feature. This is what I am trying to do:
@Check
def checkFeatureType(Element element) {
if (element.feature instanceof Double) {
// shows error!
}
}
The instanceof
check shows the following error:
Incompatible conditional operand types double or Double and Double or double
How can I perform a type check or is there a better way to override the standard message mentioned above?