Eclipse plugin - handles extension file without java like java file

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

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

Any pointers would be very helpful.

+2


source to share


2 answers


bug 71460 introduced support for different extensions for java-like sources in eclipse3.1.
The error 121 715 referred to eclipse3.2 (to support files .aj

like containing Java source):



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

      

+2


source


I wrote an extension to handle files with different endings .xyz

You must define an editor that can open this file, and you must define a constructor that can create this file.

An editor implementation for files that includes the java source code, it could be that you redistribute from the eclipse java editor and implement the "org.eclipse.ui.editors" extension point. Add the file extension to the "extension" extension editor preference entry.

When you than open a particular file, the editor you added is used. I'm not right now if you can add an extra extension to the editor that is defined in the eclipse plugin. I think you should do it yourself.



If you want to create a specific file as usual in eclipse, you need to implement a new builder using "org.eclipse.core.resource.builders". I don't have an example, but the keyword is "nature" (org.eclipse.core.resources.natures). As far as I can now add these developers to define the project. I'm not sure if you can add these developers to existing projects like "Java plugin project".


When you just want to add an editor to a file extension, you can do so from the settings page

General - Editors - File Associations

0


source







All Articles