如何在“问题”选项卡中添加错误?

我正在尝试创建一个外部构建器,该构建器将在构建Java项目并对源文件进行一些处理之前运行,然后需要将错误添加到“问题”选项卡中。

最佳答案

您需要将IMarker添加到IFile资源。就像是:

IMarker marker = file.createMarker(IMarker.PROBLEM);

marker.setAttribute(IMarker.LINE_NUMBER, line number of the error);
marker.setAttribute(IMarker.MESSAGE, "your error message");
marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);


此代码需要在Eclipse插件中运行。

10-06 09:35