Ecplise CDT的索引器是否限于源和标头的通用文件类型? [英] Is Ecplise CDT's indexer limited to the common filetypes for sources and headers?

查看:159
本文介绍了Ecplise CDT的索引器是否限于源和标头的通用文件类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事一个涉及TOM文件(扩展名为.t)的项目,该文件被编译为.c文件.现在,我已经告诉我的Eclipse将它们像C源文件一样对待,但是CDT索引器似乎不想碰它们.是否可以告诉它考虑其他文件类型?

I'm working on a project while involves TOM files (.t extension), which get compiled into .c files. Now, I've told my Eclipse to treat them like C sources files, but the CDT indexer doesn't seem to want to touch them. Is it possible to tell it to consider additional filetypes?

注意:TOM文件看起来像C文件,但是带有一些附加的语法,就像在索引器的某些行上看起来像语法错误一样.

Note: TOM files look just like C files but with some additional syntax, which would just look like syntax errors on some lines to the indexer.

推荐答案

最简单的方法是定义一个新的关联.要在您的项目上执行此操作,请打开Project Properties-> C/C++ General-> File Types,然后选择Use Project Settings并定义新的扩展名:

The easiest way to do this is define a new association. To do this on your project, open Project Properties -> C/C++ General -> File Types, then select Use Project Settings and define a new extension:

您还可以在工作区级别Window-> Preferences-> C/C++-> File Types

You can also define this at the workspace level, Window -> Preferences -> C/C++ -> File Types

这应该为您提供大部分所需的东西.例如,(我实际上并不了解TOM),我有一个简单的项目,其中包含1个C文件,1个H文件和1个T文件.您想要并期望的所有功能正常工作:

This should give you most of what you want. For example, (I don't actually know TOM), I have a simple project with 1 C file, 1 H file and 1 T file. All the features you want and expect just work:

如果需要更多,可以做到这一点,但必须编写自己的Eclipse插件,该插件对*.t文件有所了解.幸运的是,它只需要几行XML.到此为止,您应该最终获得与上述基本相同的功能,但是您将拥有自己的TOM插件的起点.

If you want more, this can be done, but not without writing your own Eclipse plug-in that understands a little bit about *.t files. Fortunately, it takes only a few lines of XML. By the end of this you should end up with basically the same functionality as above, but you have a starting point for your very own TOM plug-in.

您需要做的是通过扩展org.eclipse.core.contenttype.contentTypes 通过运行)

What you need to do is define a Content type by extending the org.eclipse.core.contenttype.contentTypes extension point (there is also some older docs that gave a run through)

在您的plugin.xml中,该外观类似于:

In your plugin.xml this would look something like:

   <extension point="org.eclipse.core.contenttype.contentTypes">
      <!-- declares a content type for TOM source files -->
      <content-type id="tSource" name="TOM File"
         base-type="org.eclipse.core.runtime.text"
         file-extensions="t"
         priority="high"/>
    </extension>

您可能会考虑将base-type用作纯文本以外的其他内容,例如您可以将其设置为org.eclipse.cdt.core.cSource.

You might consider making the base-type something other than plain text, e.g. you could make it org.eclipse.cdt.core.cSource.

然后,您需要定义一种新的语言,出于我们的目的而被称为TOM语言.您可以使用org.eclipse.cdt.core.language

Then you need to define a new language, called for our purposes TOM Language. You do this with the org.eclipse.cdt.core.language extension point.

可能是这样的一个示例:

An example of what this might look like is:

   <extension
         point="org.eclipse.cdt.core.language">
      <language
            class="org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage"
            id="com.kichwacoders.tom.core.tomlanguage"
            name="TOM Language">
         <contentType
               id="com.kichwacoders.tom.core.tSource"></contentType>
      </language>
   </extension>

该类,GCCLanguage是标准的GCC之一.当然,如果您想进一步改善支持,可以选择添加或自定义解析器(以消除有关tom的语法错误),您可以扩展GCCLanguage或层次结构中的其他类之一.

The class, GCCLanguage is the standard GCC one. Of course if you want to further improve support, adding or customizing parser is an option (to remove those syntax errors about tom stuff) you could extend the GCCLanguage or one of the other classes in the hierarchy.

完成所有操作并将新插件添加到Eclipse安装后,您将获得TOM文件支持.

Once you have done all that and added your new plug-in to your Eclipse install, you will have TOM file support.

如果您读完了最后的书,可能会发现简单地分叉 https://github.com/jonahkichwacoders/com.kichwacoders.tom.core 其中包含上面的所有代码?

If you have read to the end, you might find it useful to simply fork https://github.com/jonahkichwacoders/com.kichwacoders.tom.core which contains all the code above?

这篇关于Ecplise CDT的索引器是否限于源和标头的通用文件类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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