Skip to main content



      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 13:52 Go to next message
Eclipse UserFriend
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 14:02 Go to previous messageGo to next message
Eclipse UserFriend
hi,

what about

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

~Christian
Re: Validation of a document [message #832140 is a reply to message #832056] Thu, 29 March 2012 16:38 Go to previous message
Eclipse UserFriend
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: Wed Jul 02 17:14:00 EDT 2025

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

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

Back to the top