### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java,v retrieving revision 1.13 diff -u -r1.13 FormatJavadocBlock.java --- formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java 2 Mar 2010 18:28:48 -0000 1.13 +++ formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java 22 Jun 2010 14:37:05 -0000 @@ -187,7 +187,7 @@ if (lastText.depth == htmlDepth || // found same html tag level => use it lastText.htmlNodesPtr == -1) { // no more sub-levels => add one // Text breakage - if (lastText.isHtmlTag() && text != null) { + if (lastText.isHtmlTag()) { // Set some lines before if previous was specific html tag // The added text is concerned if the parent has no child yet or is top level and closing html tag boolean setLinesBefore = lastText.separatorsPtr == -1 || (ptr == 0 && lastText.isClosingHtmlTag()); @@ -202,19 +202,19 @@ if (setLinesBefore) { switch (lastText.getHtmlTagID()) { case JAVADOC_CODE_TAGS_ID: - if (text.linesBefore < 2) { - text.linesBefore = 2; + if (node.linesBefore < 2) { + node.linesBefore = 2; } break; case JAVADOC_SEPARATOR_TAGS_ID: case JAVADOC_SINGLE_BREAK_TAG_ID: - if (text.linesBefore < 1) { - text.linesBefore = 1; + if (node.linesBefore < 1) { + node.linesBefore = 1; } } } // If adding an html tag on same html tag, then close previous one and leave - if (text.isHtmlTag() && !text.isClosingHtmlTag() && text.getHtmlTagIndex() == lastText.getHtmlTagIndex() && !lastText.isClosingHtmlTag()) { + if (text != null && text.isHtmlTag() && !text.isClosingHtmlTag() && text.getHtmlTagIndex() == lastText.getHtmlTagIndex() && !lastText.isClosingHtmlTag()) { lastText.closeTag(); return textHierarchy; } #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java,v retrieving revision 1.67 diff -u -r1.67 FormatterCommentsBugsTest.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 22 Jun 2010 14:20:59 -0000 1.67 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 22 Jun 2010 14:37:08 -0000 @@ -6798,6 +6798,29 @@ } /** + * @bug 315577: [formatter] NullPointerException (always) on inserting a custom template proposal into java code when "Use code formatter" is on + * @test Ensure that no NPE occurs when inserting the custom template + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=315577" + */ +public void testBug315577() throws JavaModelException { + String source = + "public class C {\n" + + "\n" + + " /**\n" + + " * aaaa aaa aaa.
\n" + + " * {@link C}: aaaa.
\n" + + " * {@link C}: aaaa.
\n" + + " * aaa {@link C}: aaaa.
\n" + + " * {@link C}: aaaa
\n" + + " * {@link C}: aaaa.
\n" + + " */\n" + + " public C() {\n" + + " }\n" + + "}\n"; + formatSource(source); +} + +/** * @bug 315732: [formatter] NullPointerException (always) on inserting a custom template proposal into java code when "Use code formatter" is on * @test Ensure that no NPE occurs when inserting the custom template * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=315732"