Eclipse PDE:跳转到第X行并突出显示它

时间:2010-05-20 12:58:35

标签: eclipse-pde eclipse-api

关于Eclipse PDE开发的问题:我为Eclipse编写了一个小插件,并有以下内容 * org.eclipse.ui.texteditor.ITextEditor *行号

如何自动跳转到该行并标记?遗憾的是,API似乎只支持文档中的偏移量(参见:ITextEditor.selectAndReveal()),但没有行号。

最好的是 - 尽管这不起作用:

ITextEditor editor = (ITextEditor)IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file, true );
editor.goto(line);
editor.markLine(line);

这有可能以某种方式吗?我找不到解决方案

2 个答案:

答案 0 :(得分:5)

答案 1 :(得分:1)

即使org.eclipse.ui.texteditor.ITextEditor处理了偏移量,它也应该能够使用selectAndReveal()方法获取您的行号。

请参阅this threadthis thread

  

尝试以下方面的内容:

((ITextEditor)org.eclipse.jdt.ui.JavaUI.openInEditor(compilationUnit)).selectAndReveal(int, int);