I'm trying to programmatically retrieve the associated file extensions for a specific editor from within my (DLTK based) Eclipse plugin. The reason for it is that I only want to index files that are associated to my editor, and I need to avoid hardcoding the extensions as users are able to associate any file extension to the editor via the Eclipse preferences.
Example code:
public boolean isValidPluginFile(ISourceModule sourceModule) {
// currently:
if (sourceModule.getUnderlyingResource().getFileExtension().equals("twig")) {
return true;
}
return false;
// what i would need instead (pseudocode):
List extensions = Somehow.Retrieve.AssociatedExtensionsFor('MyEditorID');
for (String extension : extensions) {
if (sourceModule.getUnderlyingResource().getFileExtension().equals(extension)) {
return true;
}
}
return false;
}
You can get all the file editor mappings
and then select only associated to your editorId.