Eclipse插件开发:如何突出texteditor中的语法? [英] Eclipse Plugin Development: How to highlight syntax in texteditor?

查看:309
本文介绍了Eclipse插件开发:如何突出texteditor中的语法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个java方法名称,我想在TextEditor中突出显示它。我参考了ITextEditor中的texteditor。

解决方案

您可以创建一个 IMarker 对象在Java编辑器将显示的文件上。

  IFile file = ...文件标记

IMarker marker = file.createMarker(IMarker.TASK);

marker.setAttribute(IMarker.CHAR_START,start);
marker.setAttribute(IMarker.CHAR_END,end);

我在这个例子中使用了一个任务标记,但你可以使用 org.eclipse.core.resources.markers 扩展点来定义你自己的标记。




org.eclipse.ui.editors.markerAnnotationSpecification 扩展点可用于定义用于显示标记的颜色和样式。



可以使用 org.eclipse.ui.editors.markerUpdaters 扩展点来定义标记如何更新编辑文件的编辑器。


Given a java method name, i want to highlight it in the TextEditor. I have reference to the texteditor in ITextEditor.

解决方案

You can create an IMarker object on a file which the Java editor will show.

IFile file = ... file to mark

IMarker marker = file.createMarker(IMarker.TASK); 

marker.setAttribute(IMarker.CHAR_START, start);
marker.setAttribute(IMarker.CHAR_END, end);

I have used a task marker in this example, but you can use the org.eclipse.core.resources.markers extension point to define your own marker.

The org.eclipse.ui.editors.markerAnnotationSpecification extension point can be used to define the colors and style used to show the markers.

The org.eclipse.ui.editors.markerUpdaters extension point can be used to define how markers are updated in an editor as the file is edited.

这篇关于Eclipse插件开发:如何突出texteditor中的语法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆