Java EclipseIDE-通过通用文本编辑器扩展点突出显示Costum语言语法

Java EclipseIDE-通过通用文本编辑器扩展点突出显示Costum语言语法,java,eclipse,eclipse-plugin,Java,Eclipse,Eclipse Plugin,我一直在尝试为EclipseIDE编写一个插件,为自定义通用语言进行语法突出显示和代码完成 在oxygen项目版本(v4.7)change notes中,使用扩展点发布了一种据称是新的、简单的方法,可以使用通用文本编辑器并使用所需功能对其进行扩展。甚至还提供了代码片段: 有了这个新的编辑器,现在更容易充实一个新的通用编辑器,这样您就可以相对容易地添加对新语言的支持。它正在重用现有的Eclipse编辑器基础结构,但是使用通用编辑器,您不需要实现编辑器来为新的文件内容类型提供功能。相反,您通过扩展点

我一直在尝试为EclipseIDE编写一个插件,为自定义通用语言进行语法突出显示和代码完成

在oxygen项目版本(v4.7)change notes中,使用扩展点发布了一种据称是新的、简单的方法,可以使用通用文本编辑器并使用所需功能对其进行扩展。甚至还提供了代码片段:

有了这个新的编辑器,现在更容易充实一个新的通用编辑器,这样您就可以相对容易地添加对新语言的支持。它正在重用现有的Eclipse编辑器基础结构,但是使用通用编辑器,您不需要实现编辑器来为新的文件内容类型提供功能。相反,您通过扩展点使通用编辑器更智能。 以下示例显示了如何通过扩展向通用编辑器提供功能:

(原始来源:)

我已经打开了一个新的插件项目,并且已经实现了通用文本编辑器。自动生成的plugin.xml文件已经包含上面引用的第一个代码块(即扩展点定义,如果我没有弄错的话)

我对Eclipse插件非常陌生,对Java也不是很坚定。因此,我还没有弄清楚将第二个代码块中的代码放在哪里,以便在编辑器中实际实现更改,以及如何将其与扩展点连接起来

任何指向某个方向的指针,或指向进一步阅读(理想情况下是非常基础的)或白痴级教程的链接都非常感谢!
谢谢。

这里是一篇相关的博客文章,其中还包括一个幻灯片分享平台:

Eclipse发行说明中的示例代码似乎类似于此showcase插件中的
GradlePresentationReconciler

我在showcase的基础上实现了语法高亮部分

<extension point="org.eclipse.ui.genericeditor.contentAssistProcessors">
   <contentAssistProcessor
         class="org.eclipse.ui.genericeditor.examples.dotproject.NaturesAndProjectsContentAssistProcessor"
         contentType="org.eclipse.ui.genericeditor.examples.dotproject">
   </contentAssistProcessor>
</extension>
<extension point="org.eclipse.ui.genericeditor.hoverProviders">
   <hoverProvider
         class="org.eclipse.ui.genericeditor.examples.dotproject.NatureLabelHoverProvider"
         contentType="org.eclipse.ui.genericeditor.examples.dotproject"
         id="natureLabelHoverProvider">
   </hoverProvider>
</extension>
<extension point="org.eclipse.ui.genericeditor.presentationReconcilers">
   <presentationReconciler
         class="org.eclipse.ui.genericeditor.examples.dotproject.BlueTagsPresentationReconciler"
         contentType="org.eclipse.ui.genericeditor.examples.dotproject">
   </presentationReconciler>
</extension>
public class GradlePR extends PresentationReconciler {

    private IToken quoteToken = new Token(new TextAttribute(new Color(Display.getCurrent(), new RGB(139, 69, 19))));
    private IToken numberToken = new Token(new TextAttribute(new Color(Display.getCurrent(), new RGB(0, 0, 255))));
    private IToken commentToken = new Token(new TextAttribute(new Color(Display.getCurrent(), new RGB(0, 100, 0))));

    public GradlePR() {
        RuleBasedScanner scanner = new RuleBasedScanner();

        IRule[] rules = new IRule[5];
        rules[0] = new SingleLineRule("'", "'", quoteToken);
        rules[1] = new SingleLineRule("\"","\"", quoteToken);
        rules[2] = new PatternRule("//", null, commentToken, (char)0, true);
        rules[3] = new NumberRule(numberToken);

        rules[4] = new GradleWordRule();

        scanner.setRules(rules);

        DefaultDamagerRepairer dr = new DefaultDamagerRepairer(scanner);
        this.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
        this.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
    }

}