Community
Participate
Working Groups
3.4 RC1. According to Benno's findings (see bug 232768 and the attached JUnit test case) there are some regressions when formatting edited lines on save. Benno, please add more details here i.e. what worked and what's now broken. We either need to do something in JDT Core or in JDT Text to get more accurate results.
I20080520-2000 Given: package test; public class E01 { /** * Javadoc * comment */ /* * block * comment */ // single line comment } 1. Enable 'Format edited lines' on the Save Actions preference page, use the Eclipse built-in formatter profile 2. Add a space somewhere inside Javadoc, Save Is: Javadoc is formatted into one line 3. Add a space somewhere inside block comment, Save Is: No formatting Should and was in M6: Block comment is formatted into one line 4. Add a space somewhere inside single line comment, Save Is: No formatting Should and was in M6: format comment
Frederic? I've verified, that I'm passing in the correct regions (size of the comment partitions) to the formatter. I'm calling the formatter in CodeFormatFix line 82 with CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS complete source of compilation unit 0 indentation \r\n as line delimiter
(In reply to comment #2) > Frederic? I've verified, that I'm passing in the correct regions (size of the > comment partitions) to the formatter. I'm calling the formatter in > CodeFormatFix line 82 with > CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS > complete source of compilation unit > 0 indentation > \r\n as line delimiter > Are the regions limited to the modified text only or do they include the entire text of the modified comments? If the former answer is true, then this explains the bug as the current comment formatter cannot handle such a case (see detailed explanation in bug 231093 comment 2). In this case, I would consider this bug as a duplicate of bug 232054. If the latter answer is true, then I have to investigate further...
(In reply to comment #3) > (In reply to comment #2) > > Frederic? I've verified, that I'm passing in the correct regions (size of the > > comment partitions) to the formatter. I'm calling the formatter in > > CodeFormatFix line 82 with > > CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS > > complete source of compilation unit > > 0 indentation > > \r\n as line delimiter > > > Are the regions limited to the modified text only or do they include the entire > text of the modified comments? They include the entire text of the modified comment (the size of the comment partition). > If the former answer is true, then this explains the bug as the current comment > formatter cannot handle such a case (see detailed explanation in bug 231093 > comment 2). In this case, I would consider this bug as a duplicate of bug > 232054. I'm aware of the bug 232054, and I do work around it in CodeFormatFix.adaptRegions(IRegion[], ICompilationUnit) > If the latter answer is true, then I have to investigate further... Thank you. You can easily try this out with the format selection action, if your selection _starts outside a comment region_ then the entire cu is formatted with F_INCLUDE_COMMENTS. In order to format the block and single line comment in the example from comment 1 it is required to select the class body including { and }. Any smaller selection does not seem to format the block and single line comment.
We can consider this bug as a duplicate of bug 232768 as the patch applied for that bug also fixes this one... *** This bug has been marked as a duplicate of bug 232768 ***
Verified for 3.4RC4 using build I20080530-0100