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

(-)formatter/org/eclipse/jdt/internal/formatter/FormatJavadocBlock.java (-6 / +6 lines)
Lines 187-193 Link Here
187
		if (lastText.depth == htmlDepth || // found same html tag level => use it
187
		if (lastText.depth == htmlDepth || // found same html tag level => use it
188
			lastText.htmlNodesPtr == -1) {	// no more sub-levels => add one
188
			lastText.htmlNodesPtr == -1) {	// no more sub-levels => add one
189
			// Text breakage
189
			// Text breakage
190
			if (lastText.isHtmlTag() && text != null) {
190
			if (lastText.isHtmlTag()) {
191
				// Set some lines before if previous was specific html tag
191
				// Set some lines before if previous was specific html tag
192
				// The added text is concerned if the parent has no child yet or is top level and closing html tag
192
				// The added text is concerned if the parent has no child yet or is top level and closing html tag
193
				boolean setLinesBefore = lastText.separatorsPtr == -1 || (ptr == 0 && lastText.isClosingHtmlTag());
193
				boolean setLinesBefore = lastText.separatorsPtr == -1 || (ptr == 0 && lastText.isClosingHtmlTag());
Lines 202-220 Link Here
202
				if (setLinesBefore) {
202
				if (setLinesBefore) {
203
					switch (lastText.getHtmlTagID()) {
203
					switch (lastText.getHtmlTagID()) {
204
						case JAVADOC_CODE_TAGS_ID:
204
						case JAVADOC_CODE_TAGS_ID:
205
							if (text.linesBefore < 2) {
205
							if (node.linesBefore < 2) {
206
								text.linesBefore = 2;
206
								node.linesBefore = 2;
207
							}
207
							}
208
							break;
208
							break;
209
						case JAVADOC_SEPARATOR_TAGS_ID:
209
						case JAVADOC_SEPARATOR_TAGS_ID:
210
				    	case JAVADOC_SINGLE_BREAK_TAG_ID:
210
				    	case JAVADOC_SINGLE_BREAK_TAG_ID:
211
							if (text.linesBefore < 1) {
211
							if (node.linesBefore < 1) {
212
								text.linesBefore = 1;
212
								node.linesBefore = 1;
213
							}
213
							}
214
					}
214
					}
215
				}
215
				}
216
				// If adding an html tag on same html tag, then close previous one and leave
216
				// If adding an html tag on same html tag, then close previous one and leave
217
				if (text.isHtmlTag() && !text.isClosingHtmlTag() && text.getHtmlTagIndex() == lastText.getHtmlTagIndex() && !lastText.isClosingHtmlTag()) {
217
				if (text != null && text.isHtmlTag() && !text.isClosingHtmlTag() && text.getHtmlTagIndex() == lastText.getHtmlTagIndex() && !lastText.isClosingHtmlTag()) {
218
					lastText.closeTag();
218
					lastText.closeTag();
219
					return textHierarchy;
219
					return textHierarchy;
220
				}
220
				}
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java (+23 lines)
Lines 6798-6803 Link Here
6798
}
6798
}
6799
6799
6800
/**
6800
/**
6801
 * @bug 315577: [formatter] NullPointerException (always) on inserting a custom template proposal into java code when "Use code formatter" is on
6802
 * @test Ensure that no NPE occurs when inserting the custom template
6803
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=315577"
6804
 */
6805
public void testBug315577() throws JavaModelException {
6806
	String source =
6807
		"public class C {\n" + 
6808
		"\n" + 
6809
		"	/**\n" + 
6810
		"	 * aaaa aaa aaa.<br>\n" + 
6811
		"	 * {@link C}: aaaa.<br>\n" + 
6812
		"	 * {@link C}: aaaa.<br>\n" + 
6813
		"	 * aaa {@link C}: aaaa.<br>\n" + 
6814
		"	 * {@link C}: aaaa<br>\n" + 
6815
		"	 * {@link C}: aaaa.<br>\n" + 
6816
		"	 */\n" + 
6817
		"	public C() {\n" + 
6818
		"	}\n" + 
6819
		"}\n";
6820
	formatSource(source);
6821
}
6822
6823
/**
6801
 * @bug 315732: [formatter] NullPointerException (always) on inserting a custom template proposal into java code when "Use code formatter" is on
6824
 * @bug 315732: [formatter] NullPointerException (always) on inserting a custom template proposal into java code when "Use code formatter" is on
6802
 * @test Ensure that no NPE occurs when inserting the custom template
6825
 * @test Ensure that no NPE occurs when inserting the custom template
6803
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=315732"
6826
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=315732"

Return to bug 315577