From b552b8dcc428db25fc4f721bcb038871abe7e5a5 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Thu, 21 Sep 2023 23:53:00 -0400 Subject: [PATCH] Fix Javadoc formatting when do not put block tags on separate line set (#1415) - fix problem with block tags not putting newline after closing tag - revert logic for handling
 tags
- fixes #1131
---
 .../formatter/CommentsPreparator.java         | 21 +++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CommentsPreparator.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CommentsPreparator.java
index 3ef9295126d..88d857a4542 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CommentsPreparator.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/CommentsPreparator.java
@@ -833,6 +833,11 @@ private void handleHtml(TagElement node) {
 					handleSeparateLineTag(startPos, endPos);
 				} else if (matcher.start(4) < matcher.end(4)) {
 					handleBreakBeforeTag(startPos, endPos, isOpeningTag);
+					if (this.options.comment_javadoc_do_not_separate_block_tags) {
+						if (!isOpeningTag) {
+							handleBreakAfterTag(startPos, endPos);
+						}
+					}
 				} else if (matcher.start(5) < matcher.end(5)) {
 					handleBreakAfterTag(startPos, endPos);
 				} else if (matcher.start(6) < matcher.end(6)) {
@@ -840,6 +845,9 @@ private void handleHtml(TagElement node) {
 				} else if (matcher.start(7) < matcher.end(7)) {
 					if (this.options.comment_javadoc_do_not_separate_block_tags) {
 						handleBreakBeforeTag(startPos, endPos, isOpeningTag);
+						if (!isOpeningTag) {
+							handleBreakAfterTag(startPos, endPos);
+						}
 					} else {
 						handleSeparateLineTag(startPos, endPos);
 					}
@@ -972,12 +980,8 @@ private void handleFormatCodeTag(TagElement tagElement, int startPos, int endPos
 			return;
 		}
 
-		if (this.options.comment_javadoc_do_not_separate_block_tags) {
-			handleBreakBeforeTag(startPos, endPos, isOpeningTag);
-		} else {
-			// add empty lines before opening and after closing token
-			handleSeparateLineTag(startPos, endPos);
-		}
+		// add empty lines before opening and after closing token
+		handleSeparateLineTag(startPos, endPos);
 
 		int startIndex = tokenStartingAt(startPos);
 		int endTagIndex = tokenEndingAt(endPos);
@@ -1045,6 +1049,11 @@ private void handleFormatCodeTag(TagElement tagElement, int startPos, int endPos
 			this.formatCodeOpenTagEndIndex = -1;
 			this.lastFormatCodeClosingTagIndex = this.ctm.findIndex(startPos, -1, true);
 		}
+//		if (!isOpeningTag) {
+//			if (this.options.comment_javadoc_do_not_separate_block_tags) {
+//				handleBreakAfterTag(startIndex, endTagIndex);
+//			}
+//		}
 	}
 
 	private void handleSnippet(TagElement node, int startIndex, int endIndex) {