How to use dynamic file names in Eclipse editor extension point="org.eclipse.ui.editors"?

34 Views Asked by At

Currently, in my Xtext project, I have an INI file in my xtext.ui plugin. My editor extension looks like this:

<extension point="org.eclipse.ui.editors">
<editor
    class="com.*INIExecutableExtensionFactory:org.eclipse.xtext.ui.editor.XtextEditor"
    contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor"
    default="true"
    filenames="XYZ.ini"
    id="com.abc"
    name="INI Editor">
</editor>

The Xtext INI highlighter works for XYZ.ini, but in real scenarios, my INI file can have any name, like abc.ini. For abc.ini, the highlighter and other Xtext features do not work. I want to add dynamic file names to achieve this.

Description: I'm working on an Xtext project where the INI file's name can vary. The current setup specifies a static file name (XYZ.ini) in the editor extension point, which causes issues when the file name is dynamic (e.g., abc.ini). I need to make the editor extension dynamic to support any INI file name, ensuring that the Xtext features work correctly for all INI files within my project. What changes do I need to make to achieve this dynamic file name handling in the editor extension point?

1

There are 1 best solutions below

0
mahesh bhagirath On

Thanks @greg

I have added the extension "org.eclipse.core.contenttype.contentTypes" and my issue got resolved

 <extension
   point="org.eclipse.core.contenttype.contentTypes">
<file-association
      content-type="com.abc.xtext.ui.iniContentType"
      file-extensions="ini">
</file-association>
<content-type
      base-type="org.eclipse.core.runtime.text"
      file-extensions="ini"
      file-patterns="*.ini"
      id="com.abc.xtext.ui.iniContentType"
      name="MyINI Editor"
      priority="normal">
</content-type>