|
Re: I can "know" the error in my editor [message #1063657 is a reply to message #1062101] |
Thu, 13 June 2013 11:42  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.05905 seconds