Bug 294618 - [formatter] The formatter fails to format a compilation unit with deep nesting of html tags
Summary: [formatter] The formatter fails to format a compilation unit with deep nestin...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.6   Edit
Hardware: All All
: P1 normal (vote)
Target Milestone: 3.6 M4   Edit
Assignee: Frederic Fusier CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-11-09 10:05 EST by Frederic Fusier CLA
Modified: 2009-12-08 03:43 EST (History)
3 users (show)

See Also:


Attachments
Proposed patch (5.39 KB, patch)
2009-11-10 16:34 EST, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Frederic Fusier CLA 2009-11-09 10:05:53 EST
Build 3.6M3 but exist since 3.4.

Consider the following test case:
package wkps3;

/**
 * The formatter is not able to format the current comment:
 * 
 * <ol>
 *   <li><p> First item
 *
 *   <li><p> Second item
 *
 *   <li><p> First paragraph of third item
 *
 *   <p> Second paragraph of third item
 *
 *   <blockquote><table cellpadding=0 cellspacing=0 summary="layout">
 *   <tr><td><tt>::255.255.0.d</tt><td></tr>
 *   </table></blockquote>
 *   </li>
 * </ol>
 */
public class X03b {

}

Nothing happen when trying to format it although there's no MalformedTreeExcetion...

Using 3.3.2, the format output is:
package wkps3;

/**
 * The formatter was not able to format the current comment:
 * 
 * <ol>
 * <li>
 * <p>
 * First item
 * 
 * <li>
 * <p>
 * Second item
 * 
 * <li>
 * <p>
 * First paragraph of third item
 * 
 * <p>
 * Second paragraph of third item
 * 
 * <blockquote><table cellpadding=0 cellspacing=0 summary="layout">
 * <tr>
 * <td><tt>::255.255.0.d</tt>
 * <td></tr>
 * </table></blockquote> </li>
 * </ol>
 */
public class X03b {

}

So this is a regression introduced when rewrote the comments formatter...
Comment 1 Frederic Fusier CLA 2009-11-09 10:07:45 EST
This issue was found while testing patch for bug 294500, I'll investigate as soon as after having released the patch for that bug...
Comment 2 Olivier Thomann CLA 2009-11-09 10:15:15 EST
This is not really a regression since in 3.3.2 the comment formatting with incomplete tags was also far from being perfect.
Comment 3 Frederic Fusier CLA 2009-11-10 11:35:57 EST
In fact this is not the invalid sequence which cause the grief to the formatter, but rather the deep nesting. E.g. the following correct html tags also failed to be formatted:
/**
 * Verify deep html tag nesting:
 * 
 * <ol>
 *   <li><p> First item
 *   <li><p> Second item
 *   <ul>
 *     <li><p> First item of second item
 *       <blockquote><table cellpadding=0 cellspacing=0 summary="layout">
 *       <tr><td><tt><i><b>::255.255.0.d</b></i></tt></td></tr>
 *       </table></blockquote>
 *     </li>
 *   </ul>
 *   </li>
 * </ol>
 */
public class X {
}
Comment 4 Frederic Fusier CLA 2009-11-10 16:34:15 EST
Created attachment 151887 [details]
Proposed patch

The tags hierarchy stack didn't have enough room for comments with nested depth over 10 items. Just resize it to the maximum possible depth...
Comment 5 Frederic Fusier CLA 2009-11-10 16:35:41 EST
Released for 3.6M4 in HEAD stream.
Comment 6 Satyam Kandula CLA 2009-12-08 01:26:07 EST
Verified for 3.6M4 using I20091207-1800