HEAD - 270209 (change constants names)
diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java
index fee77be..0b4b20d 100644
--- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java
+++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java
@@ -5564,7 +5564,7 @@
* @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=270209"
*/
public void testBug270209_Block01() throws JavaModelException {
- this.formatterPrefs.comment_condensed_block_comment = true;
+ this.formatterPrefs.comment_new_lines_at_block_boundaries = false;
String source =
"public interface X01 {\n" +
"\n" +
@@ -5582,7 +5582,7 @@
);
}
public void testBug270209_Block02() throws JavaModelException {
- this.formatterPrefs.comment_condensed_block_comment = true;
+ this.formatterPrefs.comment_new_lines_at_block_boundaries = false;
String source =
"public interface X02 {\n" +
"\n" +
@@ -5602,7 +5602,7 @@
);
}
public void testBug270209_Block03() throws JavaModelException {
- this.formatterPrefs.comment_condensed_block_comment = true;
+ this.formatterPrefs.comment_new_lines_at_block_boundaries = false;
String source =
"public interface X03 {\n" +
"\n" +
@@ -5624,7 +5624,7 @@
);
}
public void testBug270209_Javadoc01() throws JavaModelException {
- this.formatterPrefs.comment_condensed_javadoc_comment = true;
+ this.formatterPrefs.comment_new_lines_at_javadoc_boundaries = false;
String source =
"public interface X01 {\n" +
"\n" +
@@ -5642,7 +5642,7 @@
);
}
public void testBug270209_Javadoc02() throws JavaModelException {
- this.formatterPrefs.comment_condensed_javadoc_comment = true;
+ this.formatterPrefs.comment_new_lines_at_javadoc_boundaries = false;
String source =
"public interface X02 {\n" +
"\n" +
@@ -5662,7 +5662,7 @@
);
}
public void testBug270209_Javadoc03() throws JavaModelException {
- this.formatterPrefs.comment_condensed_javadoc_comment = true;
+ this.formatterPrefs.comment_new_lines_at_javadoc_boundaries = false;
String source =
"public interface X03 {\n" +
"\n" +
diff --git a/org.eclipse.jdt.core/buildnotes_jdt-core.html b/org.eclipse.jdt.core/buildnotes_jdt-core.html
index 6d9a5f1..460f602 100644
--- a/org.eclipse.jdt.core/buildnotes_jdt-core.html
+++ b/org.eclipse.jdt.core/buildnotes_jdt-core.html
@@ -113,14 +113,14 @@
Added two new formatter preferences to condense block and javadoc comments.
<p>
These new preferences are controlled respectively with the options:</p>
-<code>DefaultCodeFormatterConstants.FORMATTER_COMMENT_CONDENSED_BLOCK_COMMENT</code><br>
-<code>DefaultCodeFormatterConstants.FORMATTER_COMMENT_CONDENSED_JAVADOC_COMMENT</code>
+<code>DefaultCodeFormatterConstants.FORMATTER_COMMENT_NEW_LINES_AT_BLOCK_BOUNDARIES</code><br>
+<code>DefaultCodeFormatterConstants.FORMATTER_COMMENT_NEW_LINES_AT_JAVADOC_BOUNDARIES</code>
<pre>
/**
- * FORMATTER / Option to control whether block comments are condensed or not
- * - option id: "org.eclipse.jdt.core.formatter.comment.condensed_block_comment"
+ * FORMATTER / Option to control whether block comments will have new lines at boundaries
+ * - option id: "org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries"
* - possible values: { TRUE, FALSE }
- * - default: FALSE
+ * - default: TRUE
*
* @see #TRUE
* @see #FALSE
@@ -128,10 +128,10 @@
*/
/**
- * FORMATTER / Option to control whether javadoc comments are condensed or not
- * - option id: "org.eclipse.jdt.core.formatter.comment.condensed_javadoc_comment"
+ * FORMATTER / Option to control whether javadoc comments will have new lines at boundaries
+ * - option id: "org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries"
* - possible values: { TRUE, FALSE }
- * - default: FALSE
+ * - default: TRUE
*
* @see #TRUE
* @see #FALSE
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 eaf0a8d..0e8bb11 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
@@ -616,32 +616,6 @@
/**
* <pre>
- * FORMATTER / Option to control whether block comments are condensed or not
- * - option id: "org.eclipse.jdt.core.formatter.comment.condensed_block_comment"
- * - possible values: { TRUE, FALSE }
- * - default: FALSE
- * </pre>
- * @see #TRUE
- * @see #FALSE
- * @since 3.6
- */
- public final static String FORMATTER_COMMENT_CONDENSED_BLOCK_COMMENT = "org.eclipse.jdt.core.formatter.comment.condensed_block_comment"; //$NON-NLS-1$
-
- /**
- * <pre>
- * FORMATTER / Option to control whether javadoc comments are condensed or not
- * - option id: "org.eclipse.jdt.core.formatter.comment.condensed_javadoc_comment"
- * - possible values: { TRUE, FALSE }
- * - default: FALSE
- * </pre>
- * @see #TRUE
- * @see #FALSE
- * @since 3.6
- */
- public final static String FORMATTER_COMMENT_CONDENSED_JAVADOC_COMMENT = "org.eclipse.jdt.core.formatter.comment.condensed_javadoc_comment"; //$NON-NLS-1$
-
- /**
- * <pre>
* FORMATTER / Option to control whether comments are formatted
* - option id: "org.eclipse.jdt.core.formatter.comment.format_comments"
* - possible values: { TRUE, FALSE }
@@ -798,6 +772,32 @@
/**
* <pre>
+ * FORMATTER / Option to control whether block comments will have new lines at boundaries
+ * - option id: "org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries"
+ * - possible values: { TRUE, FALSE }
+ * - default: TRUE
+ * </pre>
+ * @see #TRUE
+ * @see #FALSE
+ * @since 3.6
+ */
+ public final static String FORMATTER_COMMENT_NEW_LINES_AT_BLOCK_BOUNDARIES = "org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries"; //$NON-NLS-1$
+
+ /**
+ * <pre>
+ * FORMATTER / Option to control whether javadoc comments will have new lines at boundaries
+ * - option id: "org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries"
+ * - possible values: { TRUE, FALSE }
+ * - default: TRUE
+ * </pre>
+ * @see #TRUE
+ * @see #FALSE
+ * @since 3.6
+ */
+ public final static String FORMATTER_COMMENT_NEW_LINES_AT_JAVADOC_BOUNDARIES = "org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries"; //$NON-NLS-1$
+
+ /**
+ * <pre>
* FORMATTER / Option to compact else/if
* - option id: "org.eclipse.jdt.core.formatter.compact_else_if"
* - possible values: { TRUE, FALSE }
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 42c19f1..f2769bd 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
@@ -100,8 +100,8 @@
public boolean comment_clear_blank_lines_in_javadoc_comment;
public boolean comment_clear_blank_lines_in_block_comment;
- public boolean comment_condensed_block_comment;
- public boolean comment_condensed_javadoc_comment;
+ public boolean comment_new_lines_at_block_boundaries;
+ public boolean comment_new_lines_at_javadoc_boundaries;
public boolean comment_format_javadoc_comment;
public boolean comment_format_line_comment;
public boolean comment_format_block_comment;
@@ -371,8 +371,8 @@
options.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_SWITCH, this.brace_position_for_switch);
options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_BLOCK_COMMENT, this.comment_clear_blank_lines_in_block_comment ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CLEAR_BLANK_LINES_IN_JAVADOC_COMMENT, this.comment_clear_blank_lines_in_javadoc_comment ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CONDENSED_BLOCK_COMMENT, this.comment_condensed_block_comment ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
- options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CONDENSED_JAVADOC_COMMENT, this.comment_condensed_javadoc_comment ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_NEW_LINES_AT_BLOCK_BOUNDARIES, this.comment_new_lines_at_block_boundaries ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
+ options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_NEW_LINES_AT_JAVADOC_BOUNDARIES, this.comment_new_lines_at_javadoc_boundaries ? 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_LINE_COMMENT, this.comment_format_line_comment ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
options.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_FORMAT_BLOCK_COMMENT, this.comment_format_block_comment ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
@@ -1105,13 +1105,13 @@
this.comment_line_length = 80;
}
}
- final Object commentCondensedBlockCommentOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CONDENSED_BLOCK_COMMENT);
- if (commentCondensedBlockCommentOption != null) {
- this.comment_condensed_block_comment = DefaultCodeFormatterConstants.TRUE.equals(commentCondensedBlockCommentOption);
+ final Object commentNewLinesAtBlockBoundariesOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_NEW_LINES_AT_BLOCK_BOUNDARIES);
+ if (commentNewLinesAtBlockBoundariesOption != null) {
+ this.comment_new_lines_at_block_boundaries = DefaultCodeFormatterConstants.TRUE.equals(commentNewLinesAtBlockBoundariesOption);
}
- final Object commentCondensedJavadocCommentOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_CONDENSED_JAVADOC_COMMENT);
- if (commentCondensedJavadocCommentOption != null) {
- this.comment_condensed_javadoc_comment = DefaultCodeFormatterConstants.TRUE.equals(commentCondensedJavadocCommentOption);
+ final Object commentNewLinesAtJavadocBoundariesOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_COMMENT_NEW_LINES_AT_JAVADOC_BOUNDARIES);
+ if (commentNewLinesAtJavadocBoundariesOption != null) {
+ this.comment_new_lines_at_javadoc_boundaries = DefaultCodeFormatterConstants.TRUE.equals(commentNewLinesAtJavadocBoundariesOption);
}
final Object indentStatementsCompareToBlockOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_INDENT_STATEMENTS_COMPARE_TO_BLOCK);
if (indentStatementsCompareToBlockOption != null) {
@@ -2024,6 +2024,8 @@
this.comment_indent_root_tags = true;
this.comment_insert_empty_line_before_root_tags = true;
this.comment_insert_new_line_for_parameter = true;
+ this.comment_new_lines_at_block_boundaries = true;
+ this.comment_new_lines_at_javadoc_boundaries = true;
this.comment_line_length = 80;
this.continuation_indentation = 2;
this.continuation_indentation_for_array_initializer = 2;
@@ -2291,6 +2293,8 @@
this.comment_indent_root_tags = true;
this.comment_insert_empty_line_before_root_tags = true;
this.comment_insert_new_line_for_parameter = true;
+ this.comment_new_lines_at_block_boundaries = true;
+ this.comment_new_lines_at_javadoc_boundaries = true;
this.comment_line_length = 80;
this.continuation_indentation = 2;
this.continuation_indentation_for_array_initializer = 2;
diff --git a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java
index e5d4230..58eb4f8 100644
--- a/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java
+++ b/org.eclipse.jdt.core/formatter/org/eclipse/jdt/internal/formatter/Scribe.java
@@ -1628,7 +1628,7 @@
boolean firstWord = true;
boolean clearBlankLines = this.formatter.preferences.comment_clear_blank_lines_in_block_comment;
boolean joinLines = this.formatter.preferences.join_lines_in_comments;
- boolean condensed = this.formatter.preferences.comment_condensed_block_comment;
+ boolean newLinesAtBoundaries = this.formatter.preferences.comment_new_lines_at_block_boundaries;
int scannerLine = Util.getLineNumber(this.scanner.currentPosition, this.lineEnds, 0, this.maxLines);
int firstLine = scannerLine;
int lineNumber = scannerLine;
@@ -1688,7 +1688,7 @@
this.column += tokensBuffer.length();
}
// end of comment
- if (!condensed) {
+ if (newLinesAtBoundaries) {
if (multiLines || hasMultiLines) {
buffer.append(this.lineSeparator);
this.column = 1;
@@ -1739,7 +1739,7 @@
int max;
lineNumber = Util.getLineNumber(this.scanner.currentPosition, this.lineEnds, scannerLine>1 ? scannerLine-2 : 0, this.maxLines);
if (lastTextLine == -1) {
- linesGap = condensed ? 0 : lineNumber - firstLine;
+ linesGap = newLinesAtBoundaries ? lineNumber - firstLine : 0;
max = 0;
} else {
linesGap = lineNumber - lastTextLine;
@@ -1877,7 +1877,7 @@
}
private void printBlockCommentHeaderLine(StringBuffer buffer) {
- if (this.formatter.preferences.comment_condensed_block_comment) {
+ if (!this.formatter.preferences.comment_new_lines_at_block_boundaries) {
buffer.insert(0, ' ');
this.column++;
}
@@ -3283,7 +3283,7 @@
printJavadocBlock(previousBlock);
// format the header and footer empty spaces
- int newLines = (!this.formatter.preferences.comment_condensed_javadoc_comment && (this.line > currentLine || javadoc.isMultiLine())) ? 1 : 0;
+ int newLines = (this.formatter.preferences.comment_new_lines_at_javadoc_boundaries && (this.line > currentLine || javadoc.isMultiLine())) ? 1 : 0;
printJavadocGapLines(javadoc.textStart, firstBlockStart-1, newLines, this.formatter.preferences.comment_clear_blank_lines_in_javadoc_comment, false, null);
printJavadocGapLines(previousBlock.sourceEnd+1, javadoc.textEnd, newLines, this.formatter.preferences.comment_clear_blank_lines_in_javadoc_comment, true, null);
}