Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » I can "know" the error in my editor(In my code..)
I can "know" the error in my editor [message #1062101] Thu, 06 June 2013 01:56 Go to next message
Yoandri Saavedra is currently offline Yoandri SaavedraFriend
Messages: 24
Registered: February 2013
Junior Member

How I can know the error in my xtext editor from my code...for example I can say ???
if (MyEditor.isError ) 

this is my pseudolanguage..
Re: I can "know" the error in my editor [message #1063657 is a reply to message #1062101] Thu, 13 June 2013 15:42 Go to previous message
Michel Simeon is currently offline Michel SimeonFriend
Messages: 128
Registered: December 2009
Senior Member
There might be a better way, by I did the following for my own application:

First I would get the current Xtext document:

IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart editor = activePage.getActiveEditor();
IXtextDocument xtextDocument = ( (XtextEditor) editor).getDocument();

Then I'll get a read-only version of the current Mydsl model (XtextResource) :

String someResult = xtextDocument.readOnly(new IUnitOfWork<String,XtextResource>() {
public String exec(XtextResource resource) throws Exception {

And finally I'll get a resource validator and use it to get the current list of errors :

IResourceValidator validator = resource.getResourceServiceProvider().getResourceValidator();
Boolean edErrors = (validator.validate(resource, CheckMode.ALL, null).size()>0); // testing size of List<Issue>
if (edErrors) {
showError("Errors in editor\nCorrect and Re-Run");
return null;

Hope this helps.
Previous Topic:new import section mechanism
Next Topic:Removing tests plugin
Goto Forum:

Current Time: Mon Apr 23 00:16:26 GMT 2018

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

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