Skip to content

Commit 8c2598b

Browse files
committed
Provide constants for Markdown formatter
This commit provides constant and fields for markdown formatting enablement partial fix : #4335
1 parent 3e46a17 commit 8c2598b

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

org.eclipse.jdt.core/formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,19 @@ public class DefaultCodeFormatterConstants {
15101510
*/
15111511
public final static String FORMATTER_COMMENT_FORMAT_JAVADOC_COMMENT = "org.eclipse.jdt.core.formatter.comment.format_javadoc_comments"; //$NON-NLS-1$
15121512

1513+
/**
1514+
* <pre>
1515+
* FORMATTER / Option to control whether markdown comments are formatted
1516+
* - option id: "org.eclipse.jdt.core.formatter.comment.format_markdown_comments"
1517+
* - possible values: { TRUE, FALSE }
1518+
* - default: TRUE
1519+
* </pre>
1520+
* @see #TRUE
1521+
* @see #FALSE
1522+
* @since 3.3
1523+
*/
1524+
public final static String FORMATTER_COMMENT_FORMAT_MARKDOWN_COMMENT = "org.eclipse.jdt.core.formatter.comment.format_markdown_comments"; //$NON-NLS-1$
1525+
15131526
/**
15141527
* <pre>
15151528
* FORMATTER / Option to control whether the header comment of a Java source file is formatted

org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,7 @@ public static DefaultCodeFormatterOptions getJavaConventionsSettings() {
532532
public boolean wrap_before_assignment_operator;
533533
public boolean wrap_before_switch_case_arrow_operator;
534534
public boolean wrap_outer_expressions_when_nested;
535+
public boolean comment_format_markdown_comment;
535536

536537
public int initial_indentation_level;
537538
public String line_separator;
@@ -952,6 +953,7 @@ public Map<String, String> getMap() {
952953
options.put(DefaultCodeFormatterConstants.FORMATTER_JOIN_LINE_COMMENTS, this.join_line_comments ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
953954
options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, this.put_empty_statement_on_new_line ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
954955
options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, Integer.toString(this.page_width));
956+
options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_MARKDOWN_COMMENT, this.comment_format_markdown_comment ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
955957
switch(this.tab_char) {
956958
case SPACE :
957959
options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE);
@@ -1734,6 +1736,10 @@ else if (JavaCore.SPACE.equals(settings.get(DefaultCodeFormatterConstants.FORMAT
17341736
if (insertNewLineBeforeWhileInDoStatementOption != null) {
17351737
this.insert_new_line_before_while_in_do_statement = JavaCore.INSERT.equals(insertNewLineBeforeWhileInDoStatementOption);
17361738
}
1739+
final Object commentFormatMarkdownCommentOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_MARKDOWN_COMMENT);
1740+
if (commentFormatMarkdownCommentOption != null) {
1741+
this.comment_format_markdown_comment = DefaultCodeFormatterConstants.TRUE.equals(commentFormatMarkdownCommentOption);
1742+
}
17371743

17381744
setString(settings, DefaultCodeFormatterConstants.FORMATTER_KEEP_ANNOTATION_DECLARATION_ON_ONE_LINE, KEEP_ON_ONE_LINE_VALUES,
17391745
v -> this.keep_annotation_declaration_on_one_line = v);

0 commit comments

Comments
 (0)