微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在 Eclipse 源视图编辑器中实现标记?

如何解决在 Eclipse 源视图编辑器中实现标记?

如何在 Eclipse 源代码视图编辑器中实现蓝色标记标记注解)?

enter image description here

解决方法

标记存在于磁盘上,这是一个注解(一些注解是基于标记创建的)。那就是所谓的范围指示器。特殊之处在于您无需在注释模型中添加和删除它,您只需使用 org.eclipse.jface.text.source#ISourceViewer.setRangeIndication(int,int,boolean) 使其与选择更改保持同步。

,
public static final String MARKER_ID = "com.test.marker";

@param res=file full path line= line number in file you want to show the marker

public static IMarker createMarker(IResource res,int line) throws CoreException {

    IMarker marker = null;
    // note: you use the id that is defined in your plugin.xml

    if (res != null) {
        marker = res.createMarker(MARKER_ID);
        marker.setAttribute(IMarker.PRIORITY,IMarker.PRIORITY_HIGH);
        marker.setAttribute(IMarker.MESSAGE,marker.setAttribute(IMarker.LINE_NUMBER,line);
        marker.setAttribute(IMarker.SEVERITY,IMarker.SEVERITY_ERROR);
    }
    return marker;

}

插件.xml

使用这个扩展点

<extension
     point="org.eclipse.ui.editors.annotationTypes">
  <type
        markerType="com.ashling.comrv.marker"
        name="com.test.marker">
  </type>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。