Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Validation of a document (How to get the validation errors programmatically?)
Validation of a document [message #832049] Thu, 29 March 2012 17:52 Go to next message
Wladimir Schamai is currently offline Wladimir SchamaiFriend
Messages: 53
Registered: May 2010
Member
Hi all,

I want to detect errors in my document programmatically. I am using the following code sofar:

public boolean hasErrors() {
		IXtextDocument xtextDocument = sourceViewerHandle.getDocument();
		return (xtextDocument.readOnly(new IUnitOfWork<Boolean, XtextResource>() {
			public Boolean exec(XtextResource state) throws Exception {
				IParseResult parseResult = state.getParseResult();
				return !state.getErrors().isEmpty() || parseResult == null;
			}
		}));
	} 


However, it only detects parsing errors, and not the validation errors. Is there a way to retrieve the validation status to see if there are errors?

Thanks in advance!
Wladimir
Re: Validation of a document [message #832056 is a reply to message #832049] Thu, 29 March 2012 18:02 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14669
Registered: July 2009
Senior Member
hi,

what about

http://www.eclipse.org/Xtext/documentation/2_1_0/060-validation.php#validation_4

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: Validation of a document [message #832140 is a reply to message #832056] Thu, 29 March 2012 20:38 Go to previous message
Wladimir Schamai is currently offline Wladimir SchamaiFriend
Messages: 53
Registered: May 2010
Member
Hi,

yes, that works.
Thanks, I overseen that one.

Wladimir
Previous Topic:Unhandled event loop exception
Next Topic:Extending grammar - NoClassDefFoundError
Goto Forum:
  


Current Time: Sat Apr 27 02:20:52 GMT 2024

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

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

Back to the top