eclipse xtext:我怎么知道文件是否包含错误

时间:2016-09-01 06:54:18

标签: java eclipse compiler-errors xtext

我正在用Java实现一个Eclipse插件。我想编写一个函数,对于文件的给定路径(例如file.myDSL),返回文件是否有错误或者是合法文件。

1 个答案:

答案 0 :(得分:0)

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);