Community
Participate
Working Groups
Is it possible to avoid formating simple comments, not JavaDoc? I often comment big pieces of code using /* */ pair, but when I format code, it breaks structure of code inside of comments. :-( In same time, I would like to have JavaDoc comments formated, because they start with /**. Is it possible to have additional switch for this? Or, if it is already exists, please point on it. ;-)
Move to JDT/UI. This is related to formatting comments.
Note: Comment formatting does not depend on old/new Java code formatter.
Ownership changed.
Created attachment 58077 [details] Proposed fix This fix also cleans up some code in the code formatter.
Created attachment 58078 [details] Proposed fix for the JDT/UI side Benno, This patch contains all the changes on the UI side. Please review them and tell me if this is fine for you. I reorganize a bit the comment formatting preference page. If everything is fine, I would release it tomorrow. Then you could work on the Cleanup wizard related issue.
Created attachment 58079 [details] Regression tests updated
This does not seam to work: 1. Enable formatting all comment styles 2. Uncheck 'Enable Line Comment Formatting' Is: !ENTRY org.eclipse.jdt.ui 4 10001 2007-02-02 10:32:24.864 !MESSAGE Internal Error !STACK 0 org.eclipse.text.edits.MalformedTreeException: End position lies outside document range at org.eclipse.text.edits.TextEditProcessor.checkIntegrityDo(TextEditProcessor.java:170) at org.eclipse.text.edits.TextEdit.dispatchCheckIntegrity(TextEdit.java:740) at org.eclipse.text.edits.TextEditProcessor.performEdits(TextEditProcessor.java:149) at org.eclipse.text.edits.TextEdit.apply(TextEdit.java:708) at org.eclipse.text.edits.TextEdit.apply(TextEdit.java:732) at org.eclipse.jdt.internal.ui.text.comment.CommentFormattingStrategy.format(CommentFormattingStrategy.java:78) at org.eclipse.jface.text.formatter.MultiPassContentFormatter.formatSlave(MultiPassContentFormatter.java:221) at org.eclipse.jface.text.formatter.MultiPassContentFormatter.formatSlaves(MultiPassContentFormatter.java:268) at org.eclipse.jface.text.formatter.MultiPassContentFormatter.format(MultiPassContentFormatter.java:144) at org.eclipse.jdt.internal.ui.preferences.formatter.CompilationUnitPreview.doFormatPreview(CompilationUnitPreview.java:60) at org.eclipse.jdt.internal.ui.preferences.formatter.JavaPreview.update(JavaPreview.java:164) at org.eclipse.jdt.internal.ui.preferences.formatter.CommentsTabPage.doUpdatePreview(CommentsTabPage.java:233) at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage$1.update(ModifyDialogTabPage.java:70) at java.util.Observable.notifyObservers(Observable.java:142) at java.util.Observable.notifyObservers(Observable.java:98) at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage$ButtonPreference.checkboxChecked(ModifyDialogTabPage.java:193) at org.eclipse.jdt.internal.ui.preferences.formatter.ModifyDialogTabPage$2.widgetSelected(ModifyDialogTabPage.java:185) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:215) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3465) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3079) at org.eclipse.jface.window.Window.runEventLoop(Window.java:820) at org.eclipse.jface.window.Window.open(Window.java:796) at org.eclipse.jdt.internal.ui.preferences.formatter.ProfileConfigurationBlock$ButtonController.modifyButtonPressed(ProfileConfigurationBlock.java:174) at org.eclipse.jdt.internal.ui.preferences.formatter.ProfileConfigurationBlock$ButtonController.widgetSelected(ProfileConfigurationBlock.java:160) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:215) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3465) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3079) at org.eclipse.jface.window.Window.runEventLoop(Window.java:820) at org.eclipse.jface.window.Window.open(Window.java:796) at org.eclipse.ui.internal.OpenPreferencesAction.run(OpenPreferencesAction.java:65) at org.eclipse.jface.action.Action.runWithEvent(Action.java:499) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:545) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:490) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:402) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:938) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3465) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3079) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2099) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2063) at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:1969) at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:456) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:228) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:451) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:101) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:146) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:106) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:76) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:169) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:476) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:416) at org.eclipse.equinox.launcher.Main.run(Main.java:1124) at org.eclipse.equinox.launcher.Main.main(Main.java:1099)
Also: 1. Enable only line comment formatting Is: Line width group is not enabled. But it looks like in the preview that the line width setting is has also an effect on the single line formatting? Same for block comment formatting. The line width setting must either be part of javadoc group if it is only affecting javadoc formatting or be enabled if any comment style is enabled. Also: Disable all comment formatting styles does result in painting the javadoc group text gray, but not the 'javadoc and block' and line width. This groups must be disabled as well. Also: If possible I would like to have two 'Clear blank lines in comments' check boxes, one for javadoc and one for block comments: -- Javadoc comment settings ------- [ ] Format header comment [ ] ... ... [ ] New line after @param tags [ ] Remove blank lines -- Block comment settings ---------- [ ] Remove blank lines -- Line width ---------------------- .... This would make the ui code easier and IMHO make the ui easier to understand. Plus it would allow to add new block comment settings in the future without problems.
Btw, if you want too I can take care of the first two UI issues.
(In reply to comment #8) > If possible I would like to have two 'Clear blank lines in comments' check > boxes, one for javadoc and one for block comments: This means that we need to split the existing option for clearing blank lines in comment in two different options. - one for the javadoc comment - one for the block comment I'll take care of this. I'll add a new patch for the UI side as well that you could modify.
Created attachment 58113 [details] New patch new patch that also splits the option for clearing blank lines inside comments.
Released for 3.3M5
I missed some backward compatibility changes on the core side. Old preferences also need to be support at the code level in order not to break existing code formatter profile. This is for users that target directly the code formatter without going through the compatibility layer in the UI.
Verified for 3.3 M5 using build I20070205-0009
*** Bug 88570 has been marked as a duplicate of this bug. ***
*** Bug 94024 has been marked as a duplicate of this bug. ***
*** Bug 52115 has been marked as a duplicate of this bug. ***