View | Details | Raw Unified | Return to bug 257906 | Differences between
and this patch

Collapse All | Expand All

(-)formatter/org/eclipse/jdt/core/formatter/DefaultCodeFormatterConstants.java (-4 / +69 lines)
Lines 3115-3128 Link Here
3115
	public static final String FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE = JavaCore.PLUGIN_ID + ".formatter.number_of_empty_lines_to_preserve";	//$NON-NLS-1$
3115
	public static final String FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE = JavaCore.PLUGIN_ID + ".formatter.number_of_empty_lines_to_preserve";	//$NON-NLS-1$
3116
	/**
3116
	/**
3117
	 * <pre>
3117
	 * <pre>
3118
	 * FORMATTER / Option to specify whether the formatter should preserve existing line breaks or not
3118
	 * FORMATTER / Option to specify whether the formatter can join wrapped lines or not
3119
	 *     - option id:         "org.eclipse.jdt.core.formatter.preserve_existing_line_breaks"
3119
	 * 
3120
	 * 		For example, the wrapped lines of method foo return statement in following test case:
3121
	 * 			class X {
3122
	 * 			String foo() {
3123
	 * 			return "select x "
3124
	 * 			       + "from y "
3125
	 * 			       + "where z=a";
3126
	 * 			}
3127
	 * 			}
3128
	 *
3129
	 * 		will be preserved by the formatter when the new preference is used
3130
	 * 		even if the maximum line width would give it enough space to join the lines.
3131
	 * 		Hence produces the following output:
3132
	 * 			class X {
3133
	 * 			    String foo() {
3134
	 * 			        return "select x "
3135
	 * 			                + "from y "
3136
	 * 			                + "where z=a";
3137
	 * 			    }
3138
	 * 			}
3139
	 *
3140
	 *     - option id:         "org.eclipse.jdt.core.formatter.join_wrapped_lines"
3120
	 *     - possible values:   { TRUE, FALSE }
3141
	 *     - possible values:   { TRUE, FALSE }
3121
	 *     - default:           FALSE
3142
	 *     - default:           TRUE
3143
	 * </pre>
3144
	 * @since 3.5
3145
	 */
3146
	public static final String FORMATTER_JOIN_WRAPPED_LINES = JavaCore.PLUGIN_ID + ".formatter.join_wrapped_lines";	//$NON-NLS-1$
3147
	/**
3148
	 * <pre>
3149
	 * FORMATTER / Option to specify whether the formatter can join text lines in comments or not
3150
	 * 
3151
	 * 		For example, the following comment:
3152
	 * 			/**
3153
	 * 			 * The foo method.
3154
	 * 			 * foo is a substitute for bar.
3155
	 * 			 *&#0047;
3156
	 * 			public class X {
3157
	 * 			}
3158
	 * 
3159
	 * 		will be unchanged by the formatter when this new preference is used,
3160
	 * 		even if the maximum line width would give it enough space to join the lines.
3161
	 *
3162
	 *     - option id:         "org.eclipse.jdt.core.formatter.join_lines_in_comments"
3163
	 *     - possible values:   { TRUE, FALSE }
3164
	 *     - default:           TRUE
3165
	 * </pre>
3166
	 * @since 3.5
3167
	 */
3168
	public static final String FORMATTER_JOIN_LINES_IN_COMMENTS = JavaCore.PLUGIN_ID + ".formatter.join_lines_in_comments";	//$NON-NLS-1$
3169
	/**
3170
	 * <pre>
3171
	 * FORMATTER / Option to specify whether the formatter can join existing text lines in javadoc comments or not
3172
	 * 
3173
	 * 		For example, the following javadoc comment:
3174
	 * 			/**
3175
	 * 			 * The foo method.
3176
	 * 			 * foo is a substitute for bar.
3177
	 * 			 *&#0047;
3178
	 * 			public class X {
3179
	 * 			}
3180
	 * 
3181
	 * 		will be unchanged by the formatter when this new preference is used,
3182
	 * 		even if the maximum line width would give it enough space to join the lines.
3183
	 *
3184
	 *     - option id:         "org.eclipse.jdt.core.formatter.join_existing_javadoc_comments_lines"
3185
	 *     - possible values:   { TRUE, FALSE }
3186
	 *     - default:           TRUE
3122
	 * </pre>
3187
	 * </pre>
3123
	 * @since 3.5
3188
	 * @since 3.5
3124
	 */
3189
	 */
3125
	public static final String FORMATTER_PRESERVE_EXISTING_LINE_BREAKS = JavaCore.PLUGIN_ID + ".formatter.preserve_existing_line_breaks";	//$NON-NLS-1$
3190
	public static final String FORMATTER_JOIN_EXISTING_JAVADOC_COMMENTS_LINES = JavaCore.PLUGIN_ID + ".formatter.join_existing_javadoc_comments_lines";	//$NON-NLS-1$
3126
	/**
3191
	/**
3127
	 * <pre>
3192
	 * <pre>
3128
	 * FORMATTER / Option to specify whether or not empty statement should be on a new line
3193
	 * FORMATTER / Option to specify whether or not empty statement should be on a new line
(-)buildnotes_jdt-core.html (-1 / +65 lines)
Lines 50-56 Link Here
50
<ul>
50
<ul>
51
<li>Added property to adjust the size of the openable cache: "org.eclipse.jdt.core.javamodelcache.ratio". For example, starting Eclipse as follows will increase the
51
<li>Added property to adjust the size of the openable cache: "org.eclipse.jdt.core.javamodelcache.ratio". For example, starting Eclipse as follows will increase the
52
     size of the openable cache by 50%: 
52
     size of the openable cache by 50%: 
53
     <pre>eclipse.exe -vmArgs -Dorg.eclipse.jdt.core.javamodelcache.ratio=1.5</pre></li>
53
     <pre>eclipse.exe -vmArgs -Dorg.eclipse.jdt.core.javamodelcache.ratio=1.5</pre>
54
</li>
55
<li>
56
As users may want to have different behavior in comments, the new formatter
57
preference to preserve line breaks is now controlled by two different options:
58
<ul>
59
<li>for the already wrapped code lines:<br>
60
<code>DefaultCodeFormatterConstants.FORMATTER_JOIN_WRAPPED_LINES</code>
61
<pre>
62
/**
63
 * FORMATTER / Option to specify whether the formatter can join wrapped lines or not
64
 * 
65
 * 		For example, the wrapped lines of method foo return statement in following test case:
66
 * 			class X {
67
 * 			String foo() {
68
 * 			return "select x "
69
 * 			       + "from y "
70
 * 			       + "where z=a";
71
 * 			}
72
 * 			}
73
 *
74
 * 		will be preserved by the formatter when the new preference is used
75
 * 		even if the maximum line width would give it enough space to join the lines.
76
 * 		Hence produces the following output:
77
 * 			class X {
78
 * 			    String foo() {
79
 * 			        return "select x "
80
 * 			                + "from y "
81
 * 			                + "where z=a";
82
 * 			    }
83
 * 			}
84
 *
85
 *     - option id:         "org.eclipse.jdt.core.formatter.join_wrapped_lines"
86
 *     - possible values:   { TRUE, FALSE }
87
 *     - default:           TRUE
88
 * 
89
 * @since 3.5
90
 */
91
</pre>
92
</li>
93
<li>for the lines in comments:<br>
94
<code>DefaultCodeFormatterConstants.FORMATTER_JOIN_LINES_IN_COMMENTS</code>
95
<pre>
96
/**
97
 * FORMATTER / Option to specify whether the formatter can join text lines in comments or not
98
 * 
99
 * 		For example, the following comment:
100
 * 			/**
101
 * 			 * The foo method.
102
 * 			 * foo is a substitute for bar.
103
 * 			 *&#0047;
104
 * 			public class X {
105
 * 			}
106
 * 
107
 * 		will be unchanged by the formatter when this new preference is used,
108
 * 		even if the maximum line width would give it enough space to join the lines.
109
 *
110
 *     - option id:         "org.eclipse.jdt.core.formatter.join_lines_in_comments"
111
 *     - possible values:   { TRUE, FALSE }
112
 *     - default:           TRUE
113
 *
114
 * @since 3.5
115
 */
116
</pre>
117
</li>
54
</ul>
118
</ul>
55
119
56
<h3>Problem Reports Fixed</h3>
120
<h3>Problem Reports Fixed</h3>
(-)formatter/org/eclipse/jdt/internal/formatter/Scribe.java (-11 / +11 lines)
Lines 936-942 Link Here
936
		if (count == 0) {
936
		if (count == 0) {
937
			// preserve line breaks in wrapping if specified
937
			// preserve line breaks in wrapping if specified
938
			// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=198074
938
			// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=198074
939
			if (this.currentAlignment != null && this.formatter.preferences.preserve_existing_line_breaks) {
939
			if (this.currentAlignment != null && !this.formatter.preferences.join_wrapped_lines) {
940
				int savedIndentation = this.indentationLevel;
940
				int savedIndentation = this.indentationLevel;
941
				StringBuffer buffer = new StringBuffer(getNewLine());
941
				StringBuffer buffer = new StringBuffer(getNewLine());
942
				this.indentationLevel = this.currentAlignment.breakIndentationLevel;
942
				this.indentationLevel = this.currentAlignment.breakIndentationLevel;
Lines 1427-1433 Link Here
1427
		int hasTextOnFirstLine = 0;
1427
		int hasTextOnFirstLine = 0;
1428
		boolean firstWord = true;
1428
		boolean firstWord = true;
1429
		boolean clearBlankLines = this.formatter.preferences.comment_clear_blank_lines_in_block_comment;
1429
		boolean clearBlankLines = this.formatter.preferences.comment_clear_blank_lines_in_block_comment;
1430
		boolean preserveBreakLines = this.formatter.preferences.preserve_existing_line_breaks;
1430
		boolean joinLines = this.formatter.preferences.join_lines_in_comments;
1431
		int scannerLine = Util.getLineNumber(this.scanner.currentPosition, this.lineEnds, 0, this.maxLines);
1431
		int scannerLine = Util.getLineNumber(this.scanner.currentPosition, this.lineEnds, 0, this.maxLines);
1432
		int firstLine = scannerLine;
1432
		int firstLine = scannerLine;
1433
		int lineNumber = scannerLine;
1433
		int lineNumber = scannerLine;
Lines 1534-1540 Link Here
1534
					// insert one blank line before root tags
1534
					// insert one blank line before root tags
1535
					linesGap = 2;
1535
					linesGap = 2;
1536
				}
1536
				}
1537
				max = preserveBreakLines ? 0 : 1;
1537
				max = joinLines ? 1 : 0;
1538
			}
1538
			}
1539
			if (linesGap > max) {
1539
			if (linesGap > max) {
1540
				if (clearBlankLines) {
1540
				if (clearBlankLines) {
Lines 1542-1548 Link Here
1542
					 if (token == TerminalTokens.TokenNameAT) {
1542
					 if (token == TerminalTokens.TokenNameAT) {
1543
						 linesGap = 1;
1543
						 linesGap = 1;
1544
					 } else {
1544
					 } else {
1545
						linesGap = max==0 || preserveBreakLines ? 1 : 0;
1545
						linesGap = (max==0 || !joinLines) ? 1 : 0;
1546
					 }
1546
					 }
1547
				}
1547
				}
1548
				for (int i=0; i<linesGap; i++) {
1548
				for (int i=0; i<linesGap; i++) {
Lines 1936-1942 Link Here
1936
						} else if (hasLineComment) {
1936
						} else if (hasLineComment) {
1937
							preserveEmptyLines(count, this.scanner.getCurrentTokenStartPosition());
1937
							preserveEmptyLines(count, this.scanner.getCurrentTokenStartPosition());
1938
							addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
1938
							addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
1939
						} else if (count != 0 && (this.formatter.preferences.preserve_existing_line_breaks || this.formatter.preferences.number_of_empty_lines_to_preserve != 0)) {
1939
						} else if (count != 0 && (!this.formatter.preferences.join_wrapped_lines || this.formatter.preferences.number_of_empty_lines_to_preserve != 0)) {
1940
							addReplaceEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition(), getPreserveEmptyLines(count-1));
1940
							addReplaceEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition(), getPreserveEmptyLines(count-1));
1941
						} else {
1941
						} else {
1942
							addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
1942
							addDeleteEdit(this.scanner.getCurrentTokenStartPosition(), this.scanner.getCurrentTokenEndPosition());
Lines 2444-2450 Link Here
2444
		// tag section: iterate through the blocks composing this tag but the last one
2444
		// tag section: iterate through the blocks composing this tag but the last one
2445
		int previousLine = Util.getLineNumber(previousEnd, this.lineEnds, 0, this.maxLines);
2445
		int previousLine = Util.getLineNumber(previousEnd, this.lineEnds, 0, this.maxLines);
2446
		boolean clearBlankLines = this.formatter.preferences.comment_clear_blank_lines_in_javadoc_comment;
2446
		boolean clearBlankLines = this.formatter.preferences.comment_clear_blank_lines_in_javadoc_comment;
2447
		boolean preserveBreakLines = this.formatter.preferences.preserve_existing_line_breaks;
2447
		boolean joinLines = this.formatter.preferences.join_lines_in_comments;
2448
		for (int i=0; i<=maxNodes; i++) {
2448
		for (int i=0; i<=maxNodes; i++) {
2449
			FormatJavadocNode node = block.nodes[i];
2449
			FormatJavadocNode node = block.nodes[i];
2450
			int nodeStart = node.sourceStart;
2450
			int nodeStart = node.sourceStart;
Lines 2454-2463 Link Here
2454
			if (i == 0) {
2454
			if (i == 0) {
2455
				newLines = this.formatter.preferences.comment_insert_new_line_for_parameter && block.isParamTag() ? 1 : 0;
2455
				newLines = this.formatter.preferences.comment_insert_new_line_for_parameter && block.isParamTag() ? 1 : 0;
2456
				if (nodeStart > (previousEnd+1)) {
2456
				if (nodeStart > (previousEnd+1)) {
2457
					if (!clearBlankLines || preserveBreakLines) {
2457
					if (!clearBlankLines || !joinLines) {
2458
						int startLine = Util.getLineNumber(nodeStart, this.lineEnds, previousLine-1, this.maxLines);
2458
						int startLine = Util.getLineNumber(nodeStart, this.lineEnds, previousLine-1, this.maxLines);
2459
						int gapLine = previousLine;
2459
						int gapLine = previousLine;
2460
						if (!preserveBreakLines) gapLine++; // if not preserving line break then gap must be at least of one line
2460
						if (joinLines) gapLine++; // if not preserving line break then gap must be at least of one line
2461
						if (startLine > gapLine) {
2461
						if (startLine > gapLine) {
2462
							newLines = startLine - previousLine;
2462
							newLines = startLine - previousLine;
2463
						}
2463
						}
Lines 3324-3330 Link Here
3324
	private void printJavadocText(FormatJavadocText text, FormatJavadocBlock block, boolean textOnNewLine) {
3324
	private void printJavadocText(FormatJavadocText text, FormatJavadocBlock block, boolean textOnNewLine) {
3325
3325
3326
		boolean clearBlankLines = this.formatter.preferences.comment_clear_blank_lines_in_javadoc_comment;
3326
		boolean clearBlankLines = this.formatter.preferences.comment_clear_blank_lines_in_javadoc_comment;
3327
		boolean preserveBreakLines = this.formatter.preferences.preserve_existing_line_breaks;
3327
		boolean joinLines = this.formatter.preferences.join_lines_in_comments;
3328
		StringBuffer buffer = new StringBuffer();
3328
		StringBuffer buffer = new StringBuffer();
3329
		int textStart = text.sourceStart;
3329
		int textStart = text.sourceStart;
3330
		int nextStart = textStart;
3330
		int nextStart = textStart;
Lines 3347-3357 Link Here
3347
3347
3348
			// Replace with current buffer if there are several empty lines between text lines
3348
			// Replace with current buffer if there are several empty lines between text lines
3349
			nextStart = (int) text.separators[idx];
3349
			nextStart = (int) text.separators[idx];
3350
			if (!clearBlankLines || preserveBreakLines) {
3350
			if (!clearBlankLines || !joinLines) {
3351
				int endLine = Util.getLineNumber(end, this.lineEnds, startLine-1, this.maxLines);
3351
				int endLine = Util.getLineNumber(end, this.lineEnds, startLine-1, this.maxLines);
3352
				startLine = Util.getLineNumber(nextStart, this.lineEnds, endLine-1, this.maxLines);
3352
				startLine = Util.getLineNumber(nextStart, this.lineEnds, endLine-1, this.maxLines);
3353
				int gapLine = endLine;
3353
				int gapLine = endLine;
3354
				if (!preserveBreakLines) gapLine++; // if not preserving line break then gap must be at least of one line
3354
				if (joinLines) gapLine++; // if not preserving line break then gap must be at least of one line
3355
				if (startLine > gapLine) {
3355
				if (startLine > gapLine) {
3356
					addReplaceEdit(textStart, end, buffer.toString());
3356
					addReplaceEdit(textStart, end, buffer.toString());
3357
					textStart = nextStart;
3357
					textStart = nextStart;
(-)formatter/org/eclipse/jdt/internal/formatter/DefaultCodeFormatterOptions.java (-7 / +15 lines)
Lines 302-308 Link Here
302
	public boolean never_indent_block_comments_on_first_column;
302
	public boolean never_indent_block_comments_on_first_column;
303
	public boolean never_indent_line_comments_on_first_column;
303
	public boolean never_indent_line_comments_on_first_column;
304
	public int number_of_empty_lines_to_preserve;
304
	public int number_of_empty_lines_to_preserve;
305
	public boolean preserve_existing_line_breaks;
305
	public boolean join_wrapped_lines;
306
	public boolean join_lines_in_comments;
306
	public boolean put_empty_statement_on_new_line;
307
	public boolean put_empty_statement_on_new_line;
307
	public int tab_size;
308
	public int tab_size;
308
	public final char filling_space = ' ';
309
	public final char filling_space = ' ';
Lines 580-586 Link Here
580
		options.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_BLOCK_COMMENTS_ON_FIRST_COLUMN, this.never_indent_block_comments_on_first_column ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
581
		options.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_BLOCK_COMMENTS_ON_FIRST_COLUMN, this.never_indent_block_comments_on_first_column ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
581
		options.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, this.never_indent_line_comments_on_first_column ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
582
		options.put(DefaultCodeFormatterConstants.FORMATTER_NEVER_INDENT_LINE_COMMENTS_ON_FIRST_COLUMN, this.never_indent_line_comments_on_first_column ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
582
		options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, Integer.toString(this.number_of_empty_lines_to_preserve));
583
		options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, Integer.toString(this.number_of_empty_lines_to_preserve));
583
		options.put(DefaultCodeFormatterConstants.FORMATTER_PRESERVE_EXISTING_LINE_BREAKS, this.preserve_existing_line_breaks ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
584
		options.put(DefaultCodeFormatterConstants.FORMATTER_JOIN_WRAPPED_LINES, this.join_wrapped_lines ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
585
		options.put(DefaultCodeFormatterConstants.FORMATTER_JOIN_LINES_IN_COMMENTS, this.join_lines_in_comments ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
584
		options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, this.put_empty_statement_on_new_line ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
586
		options.put(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE, this.put_empty_statement_on_new_line ? DefaultCodeFormatterConstants.TRUE : DefaultCodeFormatterConstants.FALSE);
585
		options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, Integer.toString(this.page_width));
587
		options.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, Integer.toString(this.page_width));
586
		switch(this.tab_char) {
588
		switch(this.tab_char) {
Lines 1848-1856 Link Here
1848
				this.number_of_empty_lines_to_preserve = 0;
1850
				this.number_of_empty_lines_to_preserve = 0;
1849
			}
1851
			}
1850
		}
1852
		}
1851
		final Object preserveExistingLineBreaksOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_PRESERVE_EXISTING_LINE_BREAKS);
1853
		final Object joinLinesInCommentsOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_JOIN_LINES_IN_COMMENTS);
1852
		if (preserveExistingLineBreaksOption != null) {
1854
		if (joinLinesInCommentsOption != null) {
1853
			this.preserve_existing_line_breaks = DefaultCodeFormatterConstants.TRUE.equals(preserveExistingLineBreaksOption);
1855
			this.join_lines_in_comments = DefaultCodeFormatterConstants.TRUE.equals(joinLinesInCommentsOption);
1856
		}
1857
		final Object joinWrappedLinesOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_JOIN_WRAPPED_LINES);
1858
		if (joinWrappedLinesOption != null) {
1859
			this.join_wrapped_lines = DefaultCodeFormatterConstants.TRUE.equals(joinWrappedLinesOption);
1854
		}
1860
		}
1855
		final Object putEmptyStatementOnNewLineOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE);
1861
		final Object putEmptyStatementOnNewLineOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_PUT_EMPTY_STATEMENT_ON_NEW_LINE);
1856
		if (putEmptyStatementOnNewLineOption != null) {
1862
		if (putEmptyStatementOnNewLineOption != null) {
Lines 2191-2197 Link Here
2191
		this.never_indent_block_comments_on_first_column = false;
2197
		this.never_indent_block_comments_on_first_column = false;
2192
		this.never_indent_line_comments_on_first_column = false;
2198
		this.never_indent_line_comments_on_first_column = false;
2193
		this.number_of_empty_lines_to_preserve = 1;
2199
		this.number_of_empty_lines_to_preserve = 1;
2194
		this.preserve_existing_line_breaks = false;
2200
		this.join_lines_in_comments = true;
2201
		this.join_wrapped_lines = true;
2195
		this.put_empty_statement_on_new_line = false;
2202
		this.put_empty_statement_on_new_line = false;
2196
		this.tab_size = 4;
2203
		this.tab_size = 4;
2197
		this.page_width = 80;
2204
		this.page_width = 80;
Lines 2456-2462 Link Here
2456
		this.never_indent_block_comments_on_first_column = false;
2463
		this.never_indent_block_comments_on_first_column = false;
2457
		this.never_indent_line_comments_on_first_column = false;
2464
		this.never_indent_line_comments_on_first_column = false;
2458
		this.number_of_empty_lines_to_preserve = 1;
2465
		this.number_of_empty_lines_to_preserve = 1;
2459
		this.preserve_existing_line_breaks = false;
2466
		this.join_lines_in_comments = true;
2467
		this.join_wrapped_lines = true;
2460
		this.put_empty_statement_on_new_line = true;
2468
		this.put_empty_statement_on_new_line = true;
2461
		this.tab_size = 8;
2469
		this.tab_size = 8;
2462
		this.page_width = 80;
2470
		this.page_width = 80;
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java (-5 / +6 lines)
Lines 2346-2352 Link Here
2346
	);
2346
	);
2347
}
2347
}
2348
public void testBug239130_preserveLineBreaks() throws JavaModelException {
2348
public void testBug239130_preserveLineBreaks() throws JavaModelException {
2349
	this.formatterPrefs.preserve_existing_line_breaks = true;
2349
	this.formatterPrefs.join_lines_in_comments = false;
2350
	String source = 
2350
	String source = 
2351
		"public class X {\n" + 
2351
		"public class X {\n" + 
2352
		"\n" + 
2352
		"\n" + 
Lines 2372-2378 Link Here
2372
	);
2372
	);
2373
}
2373
}
2374
public void testBug239130_clearBlankLines_preserveLineBreaks() throws JavaModelException {
2374
public void testBug239130_clearBlankLines_preserveLineBreaks() throws JavaModelException {
2375
	this.formatterPrefs.preserve_existing_line_breaks = true;
2375
	this.formatterPrefs.join_lines_in_comments = false;
2376
	this.formatterPrefs.comment_clear_blank_lines_in_javadoc_comment = true;
2376
	this.formatterPrefs.comment_clear_blank_lines_in_javadoc_comment = true;
2377
	String source = 
2377
	String source = 
2378
		"public class X {\n" + 
2378
		"public class X {\n" + 
Lines 2432-2438 Link Here
2432
	);
2432
	);
2433
}
2433
}
2434
public void testBug239130_196124() throws JavaModelException {
2434
public void testBug239130_196124() throws JavaModelException {
2435
	this.formatterPrefs.preserve_existing_line_breaks = true;
2435
	this.formatterPrefs.join_lines_in_comments = false;
2436
	String source = 
2436
	String source = 
2437
		"public class X {\n" + 
2437
		"public class X {\n" + 
2438
		"\n" + 
2438
		"\n" + 
Lines 2485-2490 Link Here
2485
	formatSource(source, source);
2485
	formatSource(source, source);
2486
}
2486
}
2487
public void testBug239130_96696_block_clearBlankLines() throws JavaModelException {
2487
public void testBug239130_96696_block_clearBlankLines() throws JavaModelException {
2488
	this.formatterPrefs.join_wrapped_lines = false;
2488
	this.formatterPrefs.comment_clear_blank_lines_in_block_comment = true;
2489
	this.formatterPrefs.comment_clear_blank_lines_in_block_comment = true;
2489
	String source = 
2490
	String source = 
2490
		"public class Test {\n" + 
2491
		"public class Test {\n" + 
Lines 2514-2520 Link Here
2514
	);
2515
	);
2515
}
2516
}
2516
public void testBug239130_96696_block_clearBlankLines_preserveLineBreaks() throws JavaModelException {
2517
public void testBug239130_96696_block_clearBlankLines_preserveLineBreaks() throws JavaModelException {
2517
	this.formatterPrefs.preserve_existing_line_breaks = true;
2518
	this.formatterPrefs.join_lines_in_comments = false;
2518
	this.formatterPrefs.comment_clear_blank_lines_in_block_comment = true;
2519
	this.formatterPrefs.comment_clear_blank_lines_in_block_comment = true;
2519
	String source = 
2520
	String source = 
2520
		"public class Test {\n" + 
2521
		"public class Test {\n" + 
Lines 2591-2597 Link Here
2591
	);
2592
	);
2592
}
2593
}
2593
public void testBug239130_96696_javadoc_clearBlankLines_preserveLineBreaks() throws JavaModelException {
2594
public void testBug239130_96696_javadoc_clearBlankLines_preserveLineBreaks() throws JavaModelException {
2594
	this.formatterPrefs.preserve_existing_line_breaks = true;
2595
	this.formatterPrefs.join_lines_in_comments = false;
2595
	this.formatterPrefs.comment_clear_blank_lines_in_javadoc_comment = true;
2596
	this.formatterPrefs.comment_clear_blank_lines_in_javadoc_comment = true;
2596
	String source = 
2597
	String source = 
2597
		"public class Test {\n" + 
2598
		"public class Test {\n" + 
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterRegressionTests.java (-6 / +26 lines)
Lines 10575-10581 Link Here
10575
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=198074"
10575
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=198074"
10576
 */
10576
 */
10577
public void testBug198074() throws JavaModelException {
10577
public void testBug198074() throws JavaModelException {
10578
	this.formatterPrefs.preserve_existing_line_breaks = true;
10578
	this.formatterPrefs.join_wrapped_lines = false;
10579
	String source = 
10579
	String source = 
10580
		"public class Test {\n" + 
10580
		"public class Test {\n" + 
10581
		"\n" + 
10581
		"\n" + 
Lines 10598-10604 Link Here
10598
}
10598
}
10599
// another test case put in bug's comment 1
10599
// another test case put in bug's comment 1
10600
public void testBug198074_c1() throws JavaModelException {
10600
public void testBug198074_c1() throws JavaModelException {
10601
	this.formatterPrefs.preserve_existing_line_breaks = true;
10601
	this.formatterPrefs.join_wrapped_lines = false;
10602
	String source = 
10602
	String source = 
10603
		"public class Test {\n" + 
10603
		"public class Test {\n" + 
10604
		"\n" + 
10604
		"\n" + 
Lines 10628-10634 Link Here
10628
}
10628
}
10629
// another test case put in bug's comment 3
10629
// another test case put in bug's comment 3
10630
public void testBug198074_c3() throws JavaModelException {
10630
public void testBug198074_c3() throws JavaModelException {
10631
	this.formatterPrefs.preserve_existing_line_breaks = true;
10631
	this.formatterPrefs.join_wrapped_lines = false;
10632
	String source = 
10632
	String source = 
10633
		"public class Test {\n" + 
10633
		"public class Test {\n" + 
10634
		"\n" + 
10634
		"\n" + 
Lines 10656-10664 Link Here
10656
		"}\n"
10656
		"}\n"
10657
	);
10657
	);
10658
}
10658
}
10659
public void testBug198074_comments() throws JavaModelException {
10660
	this.formatterPrefs.join_lines_in_comments = false;
10661
	String source = 
10662
		"public class Test {\n" + 
10663
		"\n" + 
10664
		"	void foo() {\n" + 
10665
		"String x = \"select x \"\n" + 
10666
		"         + \"from y \"\n" + 
10667
		"         + \"where z=a\";\n" + 
10668
		"	}\n" + 
10669
		"}\n";
10670
	formatSource(source,
10671
		"public class Test {\n" + 
10672
		"\n" + 
10673
		"	void foo() {\n" + 
10674
		"		String x = \"select x \" + \"from y \" + \"where z=a\";\n" + 
10675
		"	}\n" + 
10676
		"}\n"
10677
	);
10678
}
10659
// duplicate bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=201022
10679
// duplicate bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=201022
10660
public void testBug201022() throws JavaModelException {
10680
public void testBug201022() throws JavaModelException {
10661
	this.formatterPrefs.preserve_existing_line_breaks = true;
10681
	this.formatterPrefs.join_wrapped_lines = false;
10662
	String source = 
10682
	String source = 
10663
		"public class Test {\n" + 
10683
		"public class Test {\n" + 
10664
		"\n" + 
10684
		"\n" + 
Lines 10685-10691 Link Here
10685
}
10705
}
10686
// duplicate bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541
10706
// duplicate bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=208541
10687
public void testBug208541() throws JavaModelException {
10707
public void testBug208541() throws JavaModelException {
10688
	this.formatterPrefs.preserve_existing_line_breaks = true;
10708
	this.formatterPrefs.join_wrapped_lines = false;
10689
	String source = 
10709
	String source = 
10690
		"public class MyTest {\n" + 
10710
		"public class MyTest {\n" + 
10691
		"\n" + 
10711
		"\n" + 
Lines 10712-10718 Link Here
10712
}
10732
}
10713
// duplicate bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=213700
10733
// duplicate bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=213700
10714
public void testBug213700() throws JavaModelException {
10734
public void testBug213700() throws JavaModelException {
10715
	this.formatterPrefs.preserve_existing_line_breaks = true;
10735
	this.formatterPrefs.join_wrapped_lines = false;
10716
	String source = 
10736
	String source = 
10717
		"public class Test {\n" + 
10737
		"public class Test {\n" + 
10718
		"\n" + 
10738
		"\n" + 

Return to bug 257906