问题描述
给定一个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中的语法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!