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

(-)formatter/org/eclipse/jdt/internal/formatter/Scribe.java (-5 / +7 lines)
Lines 3173-3183 Link Here
3173
				FormatJavadocBlock inlinedBlock = (FormatJavadocBlock)node;
3173
				FormatJavadocBlock inlinedBlock = (FormatJavadocBlock)node;
3174
				if (isImmutableNode) {
3174
				if (isImmutableNode) {
3175
					text = (FormatJavadocText) inlinedBlock.getLastNode();
3175
					text = (FormatJavadocText) inlinedBlock.getLastNode();
3176
		    		length += inlinedBlock.tagEnd - inlinedBlock.sourceStart + 1;  // tag length
3176
					if (text != null) {
3177
			    	if (nodeStart > (previousEnd+1)) {
3177
			    		length += inlinedBlock.tagEnd - inlinedBlock.sourceStart + 1;  // tag length
3178
			    		length++; // include space between nodes
3178
				    	if (nodeStart > (previousEnd+1)) {
3179
			    	}
3179
				    		length++; // include space between nodes
3180
					this.scanner.resetTo(text.sourceStart , node.sourceEnd);
3180
				    	}
3181
						this.scanner.resetTo(text.sourceStart , node.sourceEnd);
3182
					}
3181
				}
3183
				}
3182
			}
3184
			}
3183
	    	if (text != null) {
3185
	    	if (text != null) {
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java (+44 lines)
Lines 6753-6756 Link Here
6753
	);
6753
	);
6754
}
6754
}
6755
6755
6756
/**
6757
 * @bug 311864: [formatter] NPE with empty {@code }
6758
 * @test Ensure that no NPE occurs while formatting an empty code inline tag.
6759
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=311864"
6760
 */
6761
public void testBug0311864() throws JavaModelException {
6762
	this.formatterPrefs.use_tags = true;
6763
	String source =
6764
		"public class Test {\n" + 
6765
		"\n" + 
6766
		"/**\n" + 
6767
		"* Compares two property values. For font or color the <i>description</i> of\n" + 
6768
		"* the resource, {@link FontData} or {@link RGB}, is used for comparison.\n" + 
6769
		"*\n" + 
6770
		"* @param value1\n" + 
6771
		"* first property value\n" + 
6772
		"* @param value2\n" + 
6773
		"* second property value\n" + 
6774
		"* @return {@code true} if the values are equals; otherwise {@code}\n" + 
6775
		"*/\n" + 
6776
		"boolean foo(int value1, int value2) {\n" + 
6777
		"	return value1 > value2;\n" + 
6778
		"}\n" + 
6779
		"}\n";
6780
	formatSource(source,
6781
		"public class Test {\n" + 
6782
		"\n" + 
6783
		"	/**\n" + 
6784
		"	 * Compares two property values. For font or color the <i>description</i> of\n" + 
6785
		"	 * the resource, {@link FontData} or {@link RGB}, is used for comparison.\n" + 
6786
		"	 * \n" + 
6787
		"	 * @param value1\n" + 
6788
		"	 *            first property value\n" + 
6789
		"	 * @param value2\n" + 
6790
		"	 *            second property value\n" + 
6791
		"	 * @return {@code true} if the values are equals; otherwise {@code}\n" + 
6792
		"	 */\n" + 
6793
		"	boolean foo(int value1, int value2) {\n" + 
6794
		"		return value1 > value2;\n" + 
6795
		"	}\n" + 
6796
		"}\n"
6797
	);
6798
}
6799
6756
}
6800
}

Return to bug 311864