### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: formatter/org/eclipse/jdt/internal/formatter/Scribe.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java,v retrieving revision 1.208 diff -u -r1.208 Scribe.java --- formatter/org/eclipse/jdt/internal/formatter/Scribe.java 6 May 2010 09:30:57 -0000 1.208 +++ formatter/org/eclipse/jdt/internal/formatter/Scribe.java 6 May 2010 14:24:19 -0000 @@ -3173,11 +3173,13 @@ FormatJavadocBlock inlinedBlock = (FormatJavadocBlock)node; if (isImmutableNode) { text = (FormatJavadocText) inlinedBlock.getLastNode(); - length += inlinedBlock.tagEnd - inlinedBlock.sourceStart + 1; // tag length - if (nodeStart > (previousEnd+1)) { - length++; // include space between nodes - } - this.scanner.resetTo(text.sourceStart , node.sourceEnd); + if (text != null) { + length += inlinedBlock.tagEnd - inlinedBlock.sourceStart + 1; // tag length + if (nodeStart > (previousEnd+1)) { + length++; // include space between nodes + } + this.scanner.resetTo(text.sourceStart , node.sourceEnd); + } } } if (text != null) { #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.65 diff -u -r1.65 FormatterCommentsBugsTest.java --- src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 6 May 2010 09:27:33 -0000 1.65 +++ src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java 6 May 2010 14:24:21 -0000 @@ -6753,4 +6753,48 @@ ); } +/** + * @bug 311864: [formatter] NPE with empty {@code } + * @test Ensure that no NPE occurs while formatting an empty code inline tag. + * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=311864" + */ +public void testBug0311864() throws JavaModelException { + this.formatterPrefs.use_tags = true; + String source = + "public class Test {\n" + + "\n" + + "/**\n" + + "* Compares two property values. For font or color the description of\n" + + "* the resource, {@link FontData} or {@link RGB}, is used for comparison.\n" + + "*\n" + + "* @param value1\n" + + "* first property value\n" + + "* @param value2\n" + + "* second property value\n" + + "* @return {@code true} if the values are equals; otherwise {@code}\n" + + "*/\n" + + "boolean foo(int value1, int value2) {\n" + + " return value1 > value2;\n" + + "}\n" + + "}\n"; + formatSource(source, + "public class Test {\n" + + "\n" + + " /**\n" + + " * Compares two property values. For font or color the description of\n" + + " * the resource, {@link FontData} or {@link RGB}, is used for comparison.\n" + + " * \n" + + " * @param value1\n" + + " * first property value\n" + + " * @param value2\n" + + " * second property value\n" + + " * @return {@code true} if the values are equals; otherwise {@code}\n" + + " */\n" + + " boolean foo(int value1, int value2) {\n" + + " return value1 > value2;\n" + + " }\n" + + "}\n" + ); +} + }