Apply FlexPrettyPrintCommand.prefs outside Eclipse plugin
Brought to you by:
ernestpasour
Is it possible to apply the FlexPrettyPrintCommand.prefs file outside an Eclipse environment (e.g., command-line tool + IntelliJ)? I'm trying to make the tool format XML files, but I have yet to find a way to set this without relying on the Eclipse plugin.
Thanks,
-JC.Franco
Yes, in fact someone blogged about this a long while back.
https://sourceforge.net/apps/mediawiki/flexformatter/index.php?title=FormatterCommandLine
http://johnlindquist.blogspot.com/2011/05/using-flex-formatter-with-intellij_05.html
I already have the tool set up in IntelliJ, but haven't found out how to include XML files for formatting. Adding MXML.additionalXMLExtensions=xml to MyFormattingRules.properties does not seem to work.
After some digging around, I found out that this setting, along with others (e.g., format on save), are stored in [WORKSPACE].metadata.plugins\org.eclipse.core.runtime.settings\FlexPrettyPrintCommand.prefs, but the documentation does not mention anything about this preference file.
Is this preference file needed in order to format XML files or am I missing something?
Oh, sorry, I misunderstood your question.
Unfortunately, it does not look like the command line utility has a way to configure the file extensions honored: it ignores files that aren't .as or .mxml.
The setting you found is honored inside Eclipse but is separate from the formatting configuration.
The only option you have right now is ugly: rename target file to have extension .mxml, format, rename back.
Of course, it would not be hard to provide an extra command line option to allow extra extensions to be specified. Or to honor a property in the preferences file, but I don't know if I would want to do that.
How about an optional parameter that points to an external prefs file? This would allow the tool to behave similarly to the Eclipse plug-in by importing/applying the settings before formatting.
No promises, but I'll see if I can take a look this weekend. Shouldn't be a huge deal, but I have to find some motivation and remember how to build an update for the project :)
Thanks! :D
Okay, I put a new version at all the usual places (after having a bit of trouble remembering how to build the deployment) with support for adding that property to the property file. I decided that the other properties were too Eclipse environment specific, so I didn't want to add support for another property file. Adding MXML.additionalXMLExtensions=xml to your existing property file should now work.
Once again, thank you!