eclipse插件 - 将非java扩展文件视为java文件

2022-01-16 00:00:00 eclipse-plugin java

我们正在开发一个 Eclipse 插件,我们有一个类似.xyz"的扩展名,但它实际上包含java代码.JavaCore.createCompilationUnitFrom() 只接受扩展名为.java"的文件.JavaCore 有 JAVA_SOURCE_CONTENT_TYPE ,它返回它视为的扩展Java 源文件.

We are developing an eclipse plugin and we have an extension like say, ".xyz" but it actually contains java code. JavaCore.createCompilationUnitFrom() accepts only files with extension ".java". JavaCore has JAVA_SOURCE_CONTENT_TYPE which returns the extensions that it treats as Java source files.

我的问题是如何将.xyz"添加到此列表中?我希望 JavaCore 将.xyz"扩展名的文件视为 java 源文件.

My questions is How do I add ".xyz" to this list ? I want JavaCore to treat files of ".xyz" extension as java source files.

任何指针都会很有帮助.

Any pointers would be very helpful.

推荐答案

错误 71460 在 eclipse3.1 中引入了对类 java 源的不同扩展的支持.
bug 121715 提到 eclipse3.2,(用于支持 .aj 文件作为包含 Java 源):

The bug 71460 has introduced support for different extension for java-like sources in eclipse3.1.
The bug 121715 mentions for eclipse3.2, (for supporting .aj files as containing Java source):

<content-type id="ajSource" name="AspectJ Source File" 
              base-type="org.eclipse.jdt.core.javaSource"
              file-extensions="aj"/>

相关文章