自定义CEditor Eclipse CDT无法识别

时间:2015-11-28 15:44:50

标签: eclipse editor eclipse-cdt

如何选择使用我的CEditor实现而不是内置?

<extension
  id="highlighter.CustomEditor1"
  point="org.eclipse.ui.editors">
  <editor
     default="true"
     name="CustomCHighlightEditor"
     extensions="c,cusc"
     icon="icons/c_file_obj.gif"
     class="highlighter.CustomEditor"
     contributorClass="org.eclipse.cdt.internal.ui.editor.CEditorActionContributor"
     symbolicFontName="org.eclipse.cdt.ui.editors.textfont"
     id="highlighter.CustomEditorC">
  </editor>

不工作(没有错误,没有变化)。如果我打开一个C文件,它仍然用旧编辑器打开。

编辑:

尝试更改默认编辑器时,如下图所示:

.c and .cusc editor

它只能在我看到的创建的cusc扩展程序中识别出来:

cusc extension

所以必须有一些东西阻止覆盖文件关联?

在两种文件类型中也缺少像折叠这样的ceditor功能: - /

编辑:现在有效,有一些偏好错误

1 个答案:

答案 0 :(得分:1)

专业化内容类型

如果您希望默认为某些特定C文件打开编辑器,则需要定义自己的内容类型,然后将编辑器与该专用内容类型相关联。

例如Ant extends基本xml内容类型,用于定义特定于Ant的内容类型。

<extension 
        point="org.eclipse.core.contenttype.contentTypes"> 
        <content-type  
            id="antBuildFile" 
            name="%antBuildFileContentType.name" 
            base-type="org.eclipse.core.runtime.xml"
            file-names="build.xml"
            file-extensions="macrodef,ent,xml,ant"
            priority="normal"> 
            <describer 
                class="org.eclipse.ant.internal.core.contentDescriber.AntBuildfileContentDescriber">
            </describer> 
        </content-type> 
    </extension>

关键是ant文件可以是.xml个文件,但关于其内容的一些内容会使它与众不同。查看AntBuildfileContentDescriber以了解Ant如何将构建文件与普通xml文件区分开来。

如果您再查看ant用户界面的plug-in XML,您会发现与专门内容类型相关联的编辑器。

更改默认编辑器

如果您只想更改C文件默认使用的编辑器,并且有多个编辑器可用,请转到首选项 - &gt; 一般 - &gt; 编辑 - &gt; 文件关联并选择所需的文件(* .c)并更改默认编辑器。

相关问题