View | Details | Raw Unified | Return to bug 294618
Collapse All | Expand All

(-)formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java (-2 / +2 lines)
Lines 211-224 Link Here
211
			}
211
			}
212
			// If we have a text after another text, keep the same level to append
212
			// If we have a text after another text, keep the same level to append
213
			if (lastTextCanHaveChildren || (htmlDepth == 0 && !lastText.isHtmlTag() && text != null && !text.isHtmlTag())) {
213
			if (lastTextCanHaveChildren || (htmlDepth == 0 && !lastText.isHtmlTag() && text != null && !text.isHtmlTag())) {
214
				if (textHierarchy == null) textHierarchy = new FormatJavadocText[MAX_TAG_HIERARCHY];
214
				if (textHierarchy == null) textHierarchy = new FormatJavadocText[htmlDepth+1];
215
				textHierarchy[ptr] = lastText;
215
				textHierarchy[ptr] = lastText;
216
				return textHierarchy;
216
				return textHierarchy;
217
			}
217
			}
218
			// Last text cannot have children, so return the built hierarchy
218
			// Last text cannot have children, so return the built hierarchy
219
			return textHierarchy;
219
			return textHierarchy;
220
		}
220
		}
221
		if (textHierarchy == null) textHierarchy = new FormatJavadocText[MAX_TAG_HIERARCHY];
221
		if (textHierarchy == null) textHierarchy = new FormatJavadocText[htmlDepth+1];
222
		textHierarchy[ptr++] = lastText;
222
		textHierarchy[ptr++] = lastText;
223
		lastNode = lastText.htmlNodes[lastText.htmlNodesPtr];
223
		lastNode = lastText.htmlNodes[lastText.htmlNodesPtr];
224
	}
224
	}
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java (+119 lines)
Lines 1644-1649 Link Here
1644
}
1644
}
1645
1645
1646
/**
1646
/**
1647
 * @bug 294618: [formatter] The formatter takes two passes to format a common sequence of html tags
1648
 * @test Verify that the specific sequence of html tags is well formatted in one pass
1649
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=294618"
1650
 */
1651
public void testBug294618a() {
1652
	String source =
1653
		"package wkps3;\n" + 
1654
		"\n" + 
1655
		"/**\n" + 
1656
		" * The formatter was not able to format the current comment:\n" + 
1657
		" * \n" + 
1658
		" * <ol>\n" + 
1659
		" *   <li><p> First item\n" + 
1660
		" *\n" + 
1661
		" *   <li><p> Second item\n" + 
1662
		" *\n" + 
1663
		" *   <li><p> First paragraph of third item\n" + 
1664
		" *\n" + 
1665
		" *   <p> Second paragraph of third item\n" + 
1666
		" *\n" + 
1667
		" *   <blockquote><table cellpadding=0 cellspacing=0 summary=\"layout\">\n" + 
1668
		" *   <tr><td><tt>::255.255.0.d</tt><td></tr>\n" + 
1669
		" *   </table></blockquote>\n" + 
1670
		" *   </li>\n" + 
1671
		" * </ol>\n" + 
1672
		" */\n" + 
1673
		"public class X01 {\n" + 
1674
		"\n" + 
1675
		"}\n";
1676
	formatSource(source,
1677
		"package wkps3;\n" + 
1678
		"\n" + 
1679
		"/**\n" + 
1680
		" * The formatter was not able to format the current comment:\n" + 
1681
		" * \n" + 
1682
		" * <ol>\n" + 
1683
		" * <li>\n" + 
1684
		" * <p>\n" + 
1685
		" * First item\n" + 
1686
		" * \n" + 
1687
		" * <li>\n" + 
1688
		" * <p>\n" + 
1689
		" * Second item\n" + 
1690
		" * \n" + 
1691
		" * <li>\n" + 
1692
		" * <p>\n" + 
1693
		" * First paragraph of third item\n" + 
1694
		" * \n" + 
1695
		" * <p>\n" + 
1696
		" * Second paragraph of third item\n" + 
1697
		" * \n" + 
1698
		" * <blockquote>\n" + 
1699
		" * <table cellpadding=0 cellspacing=0 summary=\"layout\">\n" + 
1700
		" * <tr>\n" + 
1701
		" * <td><tt>::255.255.0.d</tt>\n" + 
1702
		" * <td>\n" + 
1703
		" * </tr>\n" + 
1704
		" * </table>\n" + 
1705
		" * </blockquote></li>\n" + 
1706
		" * </ol>\n" + 
1707
		" */\n" + 
1708
		"public class X01 {\n" + 
1709
		"\n" + 
1710
		"}\n"
1711
	);
1712
}
1713
public void testBug294618b() {
1714
	String source =
1715
		"/**\n" + 
1716
		" * Verify deep html tag nesting:\n" + 
1717
		" * \n" + 
1718
		" * <ol>\n" + 
1719
		" *   <li><p> First item\n" + 
1720
		" *   <li><p> Second item\n" + 
1721
		" *   <ul>\n" + 
1722
		" *     <li><p> First item of second item\n" + 
1723
		" *       <blockquote><table cellpadding=0 cellspacing=0 summary=\"layout\">\n" + 
1724
		" *       <tr><td><tt><i><b>::255.255.0.d</b></i></tt></td></tr>\n" + 
1725
		" *       </table></blockquote>\n" + 
1726
		" *     </li>\n" + 
1727
		" *   </ul>\n" + 
1728
		" *   </li>\n" + 
1729
		" * </ol>\n" + 
1730
		" */\n" + 
1731
		"public class X02 {\n" + 
1732
		"\n" + 
1733
		"}\n";
1734
	formatSource(source,
1735
		"/**\n" + 
1736
		" * Verify deep html tag nesting:\n" + 
1737
		" * \n" + 
1738
		" * <ol>\n" + 
1739
		" * <li>\n" + 
1740
		" * <p>\n" + 
1741
		" * First item\n" + 
1742
		" * <li>\n" + 
1743
		" * <p>\n" + 
1744
		" * Second item\n" + 
1745
		" * <ul>\n" + 
1746
		" * <li>\n" + 
1747
		" * <p>\n" + 
1748
		" * First item of second item <blockquote>\n" + 
1749
		" * <table cellpadding=0 cellspacing=0 summary=\"layout\">\n" + 
1750
		" * <tr>\n" + 
1751
		" * <td><tt><i><b>::255.255.0.d</b></i></tt></td>\n" + 
1752
		" * </tr>\n" + 
1753
		" * </table>\n" + 
1754
		" * </blockquote></li>\n" + 
1755
		" * </ul>\n" + 
1756
		" * </li>\n" + 
1757
		" * </ol>\n" + 
1758
		" */\n" + 
1759
		"public class X02 {\n" + 
1760
		"\n" + 
1761
		"}\n"
1762
	);
1763
}
1764
1765
/**
1647
 * @bug 294631: [formatter] The formatter takes two passes to format a common sequence of html tags
1766
 * @bug 294631: [formatter] The formatter takes two passes to format a common sequence of html tags
1648
 * @test Verify that the specific sequence of html tags is well formatted in one pass
1767
 * @test Verify that the specific sequence of html tags is well formatted in one pass
1649
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=294631"
1768
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=294631"

Return to bug 294618