查找eclipse项目中的错误数量 [英] Finding number of errors in an eclipse project
本文介绍了查找eclipse项目中的错误数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
有两个主要的步骤:
-
您需要访问Eclipse API - 为Eclipse编写自己的插件,或使用脚本插件,如 Groovy Monkey
-
使用Eclipse API get您所关注的资源的问题标记 - 请检查此链接:如何使用资源标记
如果要检索只有JDT错误标记你应该写这样的东西:
public static IMarker [] calculateCompilationErrorMarkers(IProject project)
{
ArrayList< IMarker> result = new ArrayList< IMarker>();
IMarker [] markers = null;
markers = project.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER,true,IResource.DEPTH_INFINITE); $ IM $($)
{
Integer severityType =(Integer)marker.getAttribute(IMarker.SEVERITY);
if(severityType.intValue()== IMarker.SEVERITY_ERROR)
result.add(marker);
}
return result.toArray(new IMarker [result.size()]);
}
How to find the number of errors(marked in red) in an eclipse project programmatically?
解决方案
There are two major steps:
You need an access to Eclipse API - write your own plugin for Eclipse or use a scripting plugin like Groovy Monkey
Using Eclipse API get problem markers for resource you intrested in - check this link: How to work with resource markers
If you want to retrieve only JDT error markers you should write something like this:
public static IMarker[] calculateCompilationErrorMarkers(IProject project)
{
ArrayList <IMarker> result = new ArrayList <IMarker>();
IMarker[] markers = null;
markers = project.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
for (IMarker marker: markers)
{
Integer severityType = (Integer) marker.getAttribute(IMarker.SEVERITY);
if (severityType.intValue() == IMarker.SEVERITY_ERROR)
result.add(marker);
}
return result.toArray(new IMarker[result.size()]);
}
这篇关于查找eclipse项目中的错误数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文