【问题标题】:Multi markers messages presented in one line when hover over eclipse verticalRuler将鼠标悬停在 Eclipse VerticalRuler 上时,多标记消息显示在一行中
【发布时间】:2013-11-04 21:02:56
【问题描述】:

我正在通过下面编写的代码向 Eclipse 中的垂直标尺添加标记。 问题是,当同一编辑器的行上有多个标记时,它们的消息在编辑器垂直标尺上的悬停弹出窗口中显示在一行(连接)中。 这种消息格式对用户不友好,因为最终用户无法理解一条消息何时结束而另一条消息何时开始。在 Eclipse 的 Java 编辑器中,在编辑器中同一行的多标记处,标记的消息在垂直标尺悬停弹出窗口中被拆分到不同的行。

当标记是从我的编辑器行中的同一行代码发出时,如何在verticalRuler悬停弹出窗口内的不同行中放置不同的标记消息?

提前感谢您的帮助

    try {
        final IMarker marker = file.createMarker(MARKER_TYPE);

        marker.setAttribute(IMarker.MESSAGE, issue.getMessage());
        marker.setAttribute(IMarker.SEVERITY, issue.getSeverity().ordinal());
        int lineNumber = issue.getLine();
        if (lineNumber == -1) {
            lineNumber = 1;
        }
        marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
        marker.setAttribute(IMarker.LOCATION, MessageFormat.format(Messages.FILE_TYPE_PLACEHOLDER, Integer.toString(lineNumber)));
        marker.setAttribute(IMarker.CHAR_START, issue.getOffset());
        int charEnd = issue.getOffset() + issue.getLength();
        final String sourceStr = mEditor.getDocumentProvider().getDocument(mEditor.getEditorInput()).get();
        if (charEnd > sourceStr.length()) {
            charEnd = -1;
        }
        marker.setAttribute(IMarker.CHAR_END, charEnd);

    } catch (CoreException e) {
        Activator.getEditorLog().logError("Could not add marker", e); //$NON-NLS-1$
    }

【问题讨论】:

    标签: eclipse editor eclipse-rcp eclipse-plugin


    【解决方案1】:

    看起来这是在JavaEditor.createAnnotationRulerColumn 中设置的。这会创建一个AnnotationRulerColumn,然后调用AnnotationRulerColumn.setHover,指定JavaExpandHover 的一个实例。

    JavaExpandHover 使用了许多 JDT 内部类来构造悬停数据,但这些都实现了标准接口,因此可以复制(但代码太长了!)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-02
      • 1970-01-01
      • 2013-12-22
      • 1970-01-01
      • 1970-01-01
      • 2017-11-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多