Skip to main content


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: 130
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.
MS
Previous Topic:new import section mechanism
Next Topic:Removing tests plugin
Goto Forum:
  


Current Time: Sat Apr 27 01:08:06 GMT 2024

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

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

Back to the top