Community
Participate
Working Groups
Currently, a comment like this: | <= margin /* this is a multi-line comment about nothing in * particular, blah blah. */ Gets reformatted to: /* * this is a multi-line comment about * nothing in particular, blah blah. */ A two-line comment is now four lines. I think this is a waste of space. I'd prefer that it look like this after reformatting: /* this is a multi-line comment about * nothing in particular, blah blah. */
This is bugging me as well. The comments added to new methods after using the Override/Implement Methods action will get reformatted and expand to swallow four lines instead of two.
Created attachment 19489 [details] Patch for improving clear blank line behavior of formatter in multi-line comments This patch allows the code formatter to remove the initial blank line in multi-line comments if the formatter preference "org.eclipse.jdt.core.formatter.comment.clear_blank_lines" is true.
Created attachment 19490 [details] Patch to test improved formatter behavior in multi-line comments
This set of patches is for 3.1M6. JDT UI might want to change the formatter preference page for comments to include a multi-line comment. The initial blank line in the default "Overriding Methods" code template should also be removed if you want to stay consistent with the default formatter preferences.
>The initial blank >line in the default "Overriding Methods" code template should also be removed if >you want to stay consistent with the default formatter preferences. The template is: /* (non-Javadoc) * ${see_to_overridden} */ I don't see an initial blank line.
I would not expect that my comment: /* * A * * B */ Would be formatted into /* A * B */ or even /* A * B */ if I selected to clear blank lines. Instead I'd expect to see: /* * A * B */ It is common in Java to use an initial /* (see also Code Conventions for the Java Programming Language, 5.5.1).
Ah, I had previously changed my template to get rid of the "(non-javadoc)", I find it uselessly redundant. As for comment 6, I guess this is where my tastes differ from the code conventions, but I can understand why block comments are formatted the way they are. I would not expect /* * A * * B */ to be formatted to /* A * B */ either, I don't think the patch does this. It does format the former to /* A * B */ ,though. How would you be willing to accept this patch? Is it too late to add a new (maybe only changed through preferences.ini) preference to control this behavior?
I think the correct way to resolve this bug is to add a new option (e.g. "Compact comments"). The question is whether we would also apply this to Javadoc: /** This is a Javadoc * comment. */ Feature work is mostly done and all API changes have to be approved by the PMC.
I like the sound of that, compact comments. On the other hand, my only intention was to get rid of the initial blank line in block comments. I would not want my Javadoc comments compacted this way. I'm also not fond of the closing comment tag '*/' being moved to the end of the last line, I find that it makes the comment less readable. Still, one could imagine a "Compact multi-line comments" checkbox that enables these child checkboxes: "Compact Javadoc comments", "Compact block comments", "Close block comments on last comment line". This may be more than what PMC wants to approve though, and I'm not sure about the usefulness of compacting a Javadoc comment at all. I can also see how closing comments on the last line could be useful, though only when the original is not using any content prefix. In any case, I'd like to help out if I can in implementing what you think is acceptable at this point in the project plan if you don't have any cycles.
>usefulness of compacting a Javadoc comment at all The problem is that it might also depend on what code you write: E.g. a simple field comment could look like: /** x coordinate. */ But if more is added it turns into: /** * X coordinate. * @since 3.1 */ This will not make it into 3.1. The number of PMC requests should be kept to a minimum and for critical / must-have API changes.
Ownership changed.
Block comment formatting can be disabled in 3.3. Is this good enough?
It's not ideal, though still better than past behavior. Thanks.
Ownership has changed for the formatter, but I surely will not have enough time to fix your bug during the 3.5 development process, hence set its priority to P5. Please finalize the posted patch if you definitely need the bug to be fixed in this version and I'll have a look at it... TIA
Looks like bug 270209 was a duplicate of this. It was fixed, so this one can be closed as well.
*** This bug has been marked as a duplicate of bug 270209 ***