我正在通过下面编写的代码向 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$
}