用于将文件扩展名关联到 HTML 编辑器的 Eclipse 插件

Eclipse plugin to associate a file extension to the HTML editor

我有一个自定义文件扩展名 (.apg),我想将其关联到标准 Eclipse HTML 编辑器,因此当文件打开时,它将在 HTML 编辑器中打开,这就是我所拥有的,首先我为文件扩展名创建了一个内容类型:

<extension
    point="org.eclipse.core.contenttype.contentTypes">
    <content-type
        base-type="org.eclipse.core.runtime.text"
        file-extensions="apg"
        default-charset="UTF-8"
        id="com.test.my.type"
        name="My Custom Content Type"
        priority="high">
    </content-type>
</extension>

然后我使用以下扩展点尝试将该内容类型关联到 HTML 编辑器:

<extension
    point="org.eclipse.ui.editors">
    <editorContentTypeBinding
        contentTypeId="com.test.my.type"
        editorId="org.eclipse.wst.html.core.htmlsource.source">
    </editorContentTypeBinding>
</extension>

我在 Git 存储库中搜索了提供 HTML 编辑器的插件,还检查了插件 jar 以找到 HTML 编辑器的 ID,如下所示是吗:org.eclipse.wst.html.core.htmlsource.source 但是当我尝试 运行 应用程序时,我在控制台中收到此错误:

!MESSAGE Plugin com.my.test, extension org.eclipse.ui.editors: Unknown editor with id: org.eclipse.wst.html.core.htmlsource.source

对于任何感兴趣的人,我只需要使我的内容类型成为 HTML 内容类型的子类型,如下所示:

<extension
    point="org.eclipse.core.contenttype.contentTypes">
    <content-type
        base-type="org.eclipse.wst.html.core.htmlsource"
        file-extensions="apg"
        default-charset="UTF-8"
        id="com.test.my.type"
        name="My Custom Content Type"
        priority="high">
    </content-type>
</extension>

然后带有我的自定义 .apg 文件扩展名的文件链接到 HTML 编辑器并自动在其中打开。