Community
Participate
Working Groups
Build Identifier: 3.7.1 I've created Eclipse plug-in, which provides custom code formatter. When I switch from [built-in] to custom code formatter in "Code Style" option - my custom formatter is called and it can successfully format the "Preview Code". However, when I start using "CTRL + SHIFT + F" or "Source -> Format" to format any real source file in workspace, the [built-in] formatter is obviously called instead of mine. This was confirmed by debugging - my custom code formatter is never called on real source code files. Reproducible: Always Steps to Reproduce: 1. Create plug-in with "org.eclipse.cdt.core.CodeFormatter" extension; 2. Select your custom code formatter in "Code Style" option; 3. Try to format any real source code file.
This works for me. Just tried with the Astyle Eclipse plugin from http://astyleclipse.sourceforge.net/ Can you provide your custom formatter plugin?
(In reply to comment #1) > This works for me. Just tried with the Astyle Eclipse plugin from > http://astyleclipse.sourceforge.net/ > > Can you provide your custom formatter plugin? No problem, here you go: [http://dl.dropbox.com/u/43869765/ru.haroogan.astyle.rar] NOTE: ***Windows x86 only for now*** Instructions: 1. Open "Window -> Preferences -> AStyle Preference Page" and select "Options.txt" as "Options File"; 2. Go to "Window -> Preferences -> C/C++ -> Code Style" and switch to "AStyle Code Formatter"; 3. Test. I'm keen to learn what causes the issue! ;) P. S. One more thing to consider: [https://bugs.eclipse.org/bugs/show_bug.cgi?id=309787] Maybe CDT's CodeFormatter has the same fate?
(In reply to comment #2) > One more thing to consider: > [https://bugs.eclipse.org/bugs/show_bug.cgi?id=309787] > Maybe CDT's CodeFormatter has the same fate? There are no plans to deprecate this extension point. I tried your plugin, but there is a problem loading the DLL. It cannot find a few dependent libraries. Still I could verify that your formatter gets called both for the preview and also using Ctrl+Shift+F, because it throws this exception (which is a consequence of the DLL loading issue). java.lang.NoClassDefFoundError: Could not initialize class ru.haroogan.astyle.AStyleInterface at ru.haroogan.astyle.AStyleCodeFormatter.format(AStyleCodeFormatter.java:27) at org.eclipse.cdt.internal.corext.util.CodeFormatterUtil.format(CodeFormatterUtil.java:129) at org.eclipse.cdt.internal.ui.text.CFormattingStrategy.format(CFormattingStrategy.java:62) at org.eclipse.jface.text.formatter.MultiPassContentFormatter.formatMaster(MultiPassContentFormatter.java:193) at org.eclipse.jface.text.formatter.MultiPassContentFormatter.format(MultiPassContentFormatter.java:142) at org.eclipse.cdt.internal.ui.preferences.formatter.TranslationUnitPreview.doFormatPreview(TranslationUnitPreview.java:68) at org.eclipse.cdt.internal.ui.preferences.formatter.CPreview.update(CPreview.java:161) at org.eclipse.cdt.internal.ui.preferences.formatter.CodeFormatterConfigurationBlock$PreviewController.update(CodeFormatterConfigurationBlock.java:52)
Sorry for that, here you go, the dependencies: [http://dl.dropbox.com/u/43869765/Dependency.rar]
Sorry for that, please re-download: [http://dl.dropbox.com/u/43869765/ru.haroogan.astyle.rar] I have rebuilt DLL to mitigate dependencies. Hope this works now!
Update: I've noticed that it works, but only when I switch from [built-in] to custom formatter SPECIFICALLY in some project's "Code Style" settings. Therefore, now I have a reasonable question: why having custom formatter in global "Code Style" settings has no effect? - Actually, it looks like a bug.
(In reply to comment #6) > Update: I've noticed that it works, but only when I switch from [built-in] to > custom formatter SPECIFICALLY in some project's "Code Style" settings. > > Therefore, now I have a reasonable question: why having custom formatter in > global "Code Style" settings has no effect? - Actually, it looks like a bug. As soon as you specify project specific settings in your project properties, the workspace settings have no effect for that project. I think that's reasonable.
Works as designed.