Check if EObject is fully parsed [message #1730928] |
Fri, 29 April 2016 21:57 |
tly . Messages: 8 Registered: August 2014 |
Junior Member |
|
|
I use a Switch<T> to visit an expression inside a method of the Validator class, that is annotated with '@Check'.
My problem is, that the method is called, although there are syntax errors in the parsed file.
My rule looks sth like that:
Definition:
type = Type def = VariableName ('=' val = Expression)? ';'
If the parsed file only contains "Int ; ", the Definition object is still generated, but with "null" inside its 'def' property.
Can I check somehow whether the used "EObject" is fully parsed?
Edit: I may know why this happens: I use a standalone setup and call
Diagnostician.INSTANCE.validate(model)
to validate my model. Is there a better way to call the validation outside the normal editor?
[Updated on: Fri, 29 April 2016 22:07] Report message to a moderator
|
|
|
Re: Check if EObject is fully parsed [message #1730932 is a reply to message #1730928] |
Sat, 30 April 2016 05:46 |
|
you can check the models resource for syntax errors
Iterable<INode> errors = ((XtextResource) root.eResource()).getParseResult().getSyntaxErrors();
or you write a little logic that applys this logic to your node only
by retrieving the objects composite node, traverse it and ask the (child)nodes for a syntaxerrormessage != null
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03204 seconds