我想以编程方式跳至文本编辑器中的某个位置并突出显示代码。
我无法获得Andrew在Eclipse 3.7中工作的答案。编译器给出此错误:
类型为AbstractTextEditor的方法getSourceViewer()不可见。
但是,我能够使其与该selectAndReveal()
方法一起使用:
IFile myfile = ...
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
ITextEditor editor = (ITextEditor) IDE.openEditor(page, myfile);
editor.selectAndReveal(offset, length);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句