答案 0 :(得分:1)
要获得此类彩色背景,您需要使用标记和 MarkerAnnotationSpecification 。您将在此处找到如何使用它们:http://cubussapiens.hu/2011/05/custom-markers-and-annotations-the-bright-side-of-eclipse/
至于如何找到私有,公共字段,您需要使用JDT插件和AST解析器来解析Java文件并查找所有信息你要。我正在添加一个小代码片段,以帮助您开始这个。
ASTParser parser = ASTParser.newParser(AST_LEVEL);
parser.setSource(cmpUnit);
parser.setResolveBindings(true);
CompilationUnit astRoot = (CompilationUnit) parser.createAST(null);
AST ast = astRoot.getAST();
TypeDeclaration javaType = null;
Object type = astRoot.types().get(0);
if (type instanceof TypeDeclaration) {
javaType = ((TypeDeclaration) type);
}
List<FieldDeclarationInfo> fieldDeclarations = new ArrayList<FieldDeclarationInfo>();
// Get the field info
for (FieldDeclaration fieldDeclaration : javaType.getFields()) {
// From this object you can recover all the information that you want about the fields.
}
此处cmpUnit
是Java文件的ICompilationUnit
。