Search code examples
javaeclipsecompiler-errorsxtext

eclipse xtext: How can I know if file contain errors


I am implementing an Eclipse plugin in Java. I want to write a function that for a given path to a file (such as file.myDSL) returns whether the file has errors or it's a legal file.


Solution

  • IProject theProject = 
    ResourcePlugin.getWorkspace().getRoot().getProject("theProject");
    theProject.build(...); // or whatever operation to make sure Xtext checked the file
    IFile theFile = project.getFile("file.myDsl");
    theFile.getMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ZERO);