From 6739d37676da766cc48b88f4955ca6995742f1e8 Mon Sep 17 00:00:00 2001 From: sougandhs Date: Thu, 21 Aug 2025 11:09:36 +0530 Subject: [PATCH 1/2] Provide constants for Markdown formatter This commit provides constant and fields for markdown formatting enablement & Enable markdown formatting via setDefaultSettings() & setJavaConventionsSettings() partial fix : https://github.com/eclipse-jdt/eclipse.jdt.core/issues/4335 --- .../formatter/DefaultCodeFormatterConstants.java | 13 +++++++++++++ .../formatter/DefaultCodeFormatterOptions.java | 8 ++++++++ 2 files changed, 21 insertions(+) diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java index a61d640159a..49098094452 100644 --- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java +++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java @@ -1510,6 +1510,19 @@ public class DefaultCodeFormatterConstants { */ public final static String FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT = "org.eclipse.jdt.core.formatter.comment.format_javadoc_comments"; //$NON-NLS-1$ + /** + *
+	 * FORMATTER / Option to control whether markdown comments are formatted
+	 *     - option id:         "org.eclipse.jdt.core.formatter.comment.format_markdown_comments"
+	 *     - possible values:   { TRUE, FALSE }
+	 *     - default:           TRUE
+	 * 
+ * @see #TRUE + * @see #FALSE + * @since 3.43 + */ + public final static String FORMATTER_COMMENT_FORMAT_MARKDOWN_COMMENT = "org.eclipse.jdt.core.formatter.comment.format_markdown_comments"; //$NON-NLS-1$ + /** *
 	 * FORMATTER / Option to control whether the header comment of a Java source file is formatted
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java
index ba287c35099..04ca7bf0201 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java
@@ -238,6 +238,7 @@ public static DefaultCodeFormatterOptions getJavaConventionsSettings() {
 	public boolean comment_new_lines_at_javadoc_boundaries;
 	public boolean comment_javadoc_do_not_separate_block_tags;
 	public boolean comment_format_javadoc_comment;
+	public boolean comment_format_markdown_comment;
 	public boolean comment_format_line_comment;
 	public boolean comment_format_line_comment_starting_on_first_column;
 	public boolean comment_format_block_comment;
@@ -667,6 +668,7 @@ public Map getMap() {
 		options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HEADER, this.comment_format_header ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
 		options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_HTML, this.comment_format_html ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
 		options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT, this.comment_format_javadoc_comment ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+		options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_MARKDOWN_COMMENT, this.comment_format_markdown_comment ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
 		options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT, this.comment_format_line_comment ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
 		options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_LINE_COMMENT_STARTING_ON_FIRST_COLUMN, this.comment_format_line_comment_starting_on_first_column ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
 		options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_SOURCE, this.comment_format_source ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
@@ -1570,6 +1572,10 @@ public void set(Map settings) {
 		if (commentFormatJavadocCommentOption != null) {
 			this.comment_format_javadoc_comment = DefaultCodeFormatterConstants.TRUE.equals(commentFormatJavadocCommentOption);
 		}
+		final Object commentFormatMarkdownCommentOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_MARKDOWN_COMMENT);
+		if (commentFormatMarkdownCommentOption != null) {
+			this.comment_format_markdown_comment = DefaultCodeFormatterConstants.TRUE.equals(commentFormatMarkdownCommentOption);
+		}
 		final Object commentFormatBlockCommentOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT);
 		if (commentFormatBlockCommentOption != null) {
 			this.comment_format_block_comment = DefaultCodeFormatterConstants.TRUE.equals(commentFormatBlockCommentOption);
@@ -3063,6 +3069,7 @@ public void setDefaultSettings() {
 		this.comment_clear_blank_lines_in_javadoc_comment = false;
 		this.comment_format_block_comment = true;
 		this.comment_format_javadoc_comment = true;
+		this.comment_format_markdown_comment = true;
 		this.comment_format_line_comment = true;
 		this.comment_format_line_comment_starting_on_first_column = true;
 		this.comment_format_header = false;
@@ -3468,6 +3475,7 @@ public void setJavaConventionsSettings() {
 		this.comment_clear_blank_lines_in_javadoc_comment = false;
 		this.comment_format_block_comment = true;
 		this.comment_format_javadoc_comment = true;
+		this.comment_format_markdown_comment = true;
 		this.comment_format_line_comment = true;
 		this.comment_format_line_comment_starting_on_first_column = false;
 		this.comment_format_header = false;

From d7463b58fdfbc778dc809cfdf48327cd608511ba Mon Sep 17 00:00:00 2001
From: sougandhs 
Date: Thu, 11 Sep 2025 15:52:10 +0530
Subject: [PATCH 2/2] Fix build errors

---
 org.eclipse.jdt.core/.settings/.api_filters               | 8 --------
 org.eclipse.jdt.core/META-INF/MANIFEST.MF                 | 2 +-
 .../jdt/core/formatter/DefaultCodeFormatterConstants.java | 2 +-
 org.eclipse.jdt.core/pom.xml                              | 2 +-
 4 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/org.eclipse.jdt.core/.settings/.api_filters b/org.eclipse.jdt.core/.settings/.api_filters
index c2585475019..f9c56a5b6fc 100644
--- a/org.eclipse.jdt.core/.settings/.api_filters
+++ b/org.eclipse.jdt.core/.settings/.api_filters
@@ -1,13 +1,5 @@
 
 
-    
-        
-            
-                
-                
-            
-        
-    
     
         
             
diff --git a/org.eclipse.jdt.core/META-INF/MANIFEST.MF b/org.eclipse.jdt.core/META-INF/MANIFEST.MF
index 3653c75a3b3..ddd26cefc7f 100644
--- a/org.eclipse.jdt.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.jdt.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %pluginName
 Bundle-SymbolicName: org.eclipse.jdt.core; singleton:=true
-Bundle-Version: 3.43.100.qualifier
+Bundle-Version: 3.44.0.qualifier
 Bundle-Activator: org.eclipse.jdt.core.JavaCore
 Bundle-Vendor: %providerName
 Bundle-Localization: plugin
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java
index 49098094452..023bea9493d 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java
@@ -1519,7 +1519,7 @@ public class DefaultCodeFormatterConstants {
 	 * 
* @see #TRUE * @see #FALSE - * @since 3.43 + * @since 3.44 */ public final static String FORMATTER_COMMENT_FORMAT_MARKDOWN_COMMENT = "org.eclipse.jdt.core.formatter.comment.format_markdown_comments"; //$NON-NLS-1$ diff --git a/org.eclipse.jdt.core/pom.xml b/org.eclipse.jdt.core/pom.xml index 9f31673ac20..f0201b985ea 100644 --- a/org.eclipse.jdt.core/pom.xml +++ b/org.eclipse.jdt.core/pom.xml @@ -17,7 +17,7 @@ 4.38.0-SNAPSHOT org.eclipse.jdt.core - 3.43.100-SNAPSHOT + 3.44.0-SNAPSHOT eclipse-plugin