Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Check if EObject is fully parsed
Check if EObject is fully parsed [message #1730928] Fri, 29 April 2016 21:57 Go to next message
tly . is currently offline tly .Friend
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? Smile

[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 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
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
Re: Check if EObject is fully parsed [message #1730934 is a reply to message #1730928] Sat, 30 April 2016 05:44 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Check at least eObject.eResource().getErrors(), and to be sure all
Resources in the ResourceSet and getWarnings() too.

Regards

Ed Willink

On 29/04/2016 22:57, tly. wrote:
> 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?
Re: Check if EObject is fully parsed [message #1731571 is a reply to message #1730932] Fri, 06 May 2016 22:32 Go to previous message
tly . is currently offline tly .Friend
Messages: 8
Registered: August 2014
Junior Member
this is what i needed, thanks Smile
Previous Topic:no content assist proposal for XExpression
Next Topic:Disambiguate between reference and ValidID
Goto Forum:
  


Current Time: Thu Apr 25 10:20:58 GMT 2024

Powered by FUDForum. Page generated in 0.03204 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top