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

Collapse All | Expand All

(-)buildnotes_jdt-core.html (+1 lines)
Lines 48-53 Link Here
48
<br>Project org.eclipse.jdt.core v_A41
48
<br>Project org.eclipse.jdt.core v_A41
49
(<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_A41">cvs</a>).
49
(<a href="http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jdt.core/?only_with_tag=v_A41">cvs</a>).
50
<h2>What's new in this drop</h2>
50
<h2>What's new in this drop</h2>
51
Patch v01 for bug 305830
51
52
52
<h3>Problem Reports Fixed</h3>
53
<h3>Problem Reports Fixed</h3>
53
<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=293558">293558</a>
54
<a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=293558">293558</a>
(-)formatter/org/eclipse/jdt/internal/formatter/Scribe.java (-14 / +19 lines)
Lines 1590-1595 Link Here
1590
	}
1590
	}
1591
1591
1592
	private boolean printBlockComment(int currentTokenStartPosition, int currentTokenEndPosition) {
1592
	private boolean printBlockComment(int currentTokenStartPosition, int currentTokenEndPosition) {
1593
//		if (this.nlsTagCounter > 0) {
1594
//			return false;
1595
//		}
1593
1596
1594
		// Compute indentation
1597
		// Compute indentation
1595
		int maxColumn = this.formatter.preferences.comment_line_length + 1;
1598
		int maxColumn = this.formatter.preferences.comment_line_length + 1;
Lines 1877-1898 Link Here
1877
		}
1880
		}
1878
1881
1879
		// Replace block comment text
1882
		// Replace block comment text
1880
		if (hasTokens || multiLines) {
1883
		if (this.nlsTagCounter == 0 || !multiLines) {
1881
			StringBuffer replacement = new StringBuffer();
1884
			if (hasTokens || multiLines) {
1882
			if (hasTextOnFirstLine == 1) {
1885
				StringBuffer replacement = new StringBuffer();
1883
				if ((hasMultiLines || multiLines)) {
1886
				if (hasTextOnFirstLine == 1) {
1884
					int col = this.column;
1887
					if ((hasMultiLines || multiLines)) {
1885
					replacement.append(this.lineSeparator);
1888
						int col = this.column;
1886
					this.column = 1;
1889
						replacement.append(this.lineSeparator);
1887
					printIndentationIfNecessary(replacement);
1890
						this.column = 1;
1888
					replacement.append(BLOCK_LINE_PREFIX);
1891
						printIndentationIfNecessary(replacement);
1889
			    	this.column = col;
1892
						replacement.append(BLOCK_LINE_PREFIX);
1890
				} else {
1893
				    	this.column = col;
1891
					replacement.append(' ');
1894
					} else {
1895
						replacement.append(' ');
1896
					}
1892
				}
1897
				}
1898
				replacement.append(buffer);
1899
				addReplaceEdit(editStart, editEnd, replacement.toString());
1893
			}
1900
			}
1894
			replacement.append(buffer);
1895
			addReplaceEdit(editStart, editEnd, replacement.toString());
1896
		}
1901
		}
1897
1902
1898
		// Reset
1903
		// Reset
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java (+75 lines)
Lines 6339-6342 Link Here
6339
	    "}\n");
6339
	    "}\n");
6340
}
6340
}
6341
6341
6342
/**
6343
 * @bug 305830: [formatter] Turning off formatting changes comment's formatting
6344
 * @test Verify that turning off formatting in a javadoc does not screw up its indentation
6345
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=305830"
6346
 */
6347
public void testBug305830() {
6348
	this.formatterPrefs = null;
6349
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "40");
6350
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "40");
6351
	String source = 
6352
		"public class X01 {\n" + 
6353
		"void foo() {\n" + 
6354
		"bar(\"a non-nls string\", 0 /*a    comment*/); //$NON-NLS-1$\n" + 
6355
		"}\n" + 
6356
		"void bar(String string, int i) {\n" + 
6357
		"}\n" + 
6358
	    "}\n";
6359
	formatSource(source,
6360
		"public class X01 {\n" + 
6361
		"	void foo() {\n" + 
6362
		"		bar(\"a non-nls string\", 0 /*a    comment*/); //$NON-NLS-1$\n" + 
6363
		"	}\n" + 
6364
		"\n" + 
6365
		"	void bar(String string, int i) {\n" + 
6366
		"	}\n" + 
6367
	    "}\n"
6368
	);
6369
}
6370
public void testBug305830b() {
6371
	this.formatterPrefs = null;
6372
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "40");
6373
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "40");
6374
	String source = 
6375
		"public class X02 {\n" + 
6376
		"void foo() {\n" + 
6377
		"bar(\"str\", 0 /*a    comment*/); //$NON-NLS-1$\n" + 
6378
		"}\n" + 
6379
		"void bar(String string, int i) {\n" + 
6380
		"}\n" + 
6381
	    "}\n";
6382
	formatSource(source,
6383
		"public class X02 {\n" + 
6384
		"	void foo() {\n" + 
6385
		"		bar(\"str\", 0 /* a comment */); //$NON-NLS-1$\n" + 
6386
		"	}\n" + 
6387
		"\n" + 
6388
		"	void bar(String string, int i) {\n" + 
6389
		"	}\n" + 
6390
	    "}\n"
6391
	);
6392
}
6393
public void testBug305830c() {
6394
	this.formatterPrefs = null;
6395
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT, "40");
6396
	this.formatterOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE_LENGTH, "40");
6397
	String source = 
6398
		"public class X03 {\n" + 
6399
		"void foo() {\n" + 
6400
		"bar(\"str\", 0 /*              a						comment                            */); //$NON-NLS-1$\n" + 
6401
		"}\n" + 
6402
		"void bar(String string, int i) {\n" + 
6403
		"}\n" + 
6404
	    "}\n";
6405
	formatSource(source,
6406
		"public class X03 {\n" + 
6407
		"	void foo() {\n" + 
6408
		"		bar(\"str\", 0 /* a comment */); //$NON-NLS-1$\n" + 
6409
		"	}\n" + 
6410
		"\n" + 
6411
		"	void bar(String string, int i) {\n" + 
6412
		"	}\n" + 
6413
	    "}\n"
6414
	);
6415
}
6416
6342
}
6417
}
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java (-14 / +14 lines)
Lines 919-925 Link Here
919
		"public class X13 {\r\n" + 
919
		"public class X13 {\r\n" + 
920
		"\r\n" + 
920
		"\r\n" + 
921
		"protected void handleWarningToken(String token, boolean isEnabling) {\r\n" + 
921
		"protected void handleWarningToken(String token, boolean isEnabling) {\r\n" + 
922
		"	if (token.equals(\"pkgDefaultMethod___\") || token.equals(\"packageDefaultMethod___\")/*backward compatible*/ ) { //$NON-NLS-1$ //$NON-NLS-2$\r\n" + 
922
		"	if (token.equals(\"pkgDefaultMethod___\") || token.equals(\"packageDefaultMethod___\")/*_backward_ _compatible_*/ ) {\r\n" + 
923
		"	}\r\n" + 
923
		"	}\r\n" + 
924
		"}\r\n" + 
924
		"}\r\n" + 
925
		"}\r\n";
925
		"}\r\n";
Lines 927-945 Link Here
927
	// 1) split comment block starts one tab before to avoid possible words over the max line length
927
	// 1) split comment block starts one tab before to avoid possible words over the max line length
928
	//		note that in this peculiar this was not necessary as even the first word is over the max line length!
928
	//		note that in this peculiar this was not necessary as even the first word is over the max line length!
929
	formatSource(source,
929
	formatSource(source,
930
		"package test.comments.block;\r\n" + 
930
		"package test.comments.block;\n" + 
931
		"\r\n" + 
931
		"\n" + 
932
		"public class X13 {\r\n" + 
932
		"public class X13 {\n" + 
933
		"\r\n" + 
933
		"\n" + 
934
		"	protected void handleWarningToken(String token, boolean isEnabling) {\r\n" + 
934
		"	protected void handleWarningToken(String token, boolean isEnabling) {\n" + 
935
		"		if (token.equals(\"pkgDefaultMethod___\") || token.equals(\"packageDefaultMethod___\")/*\r\n" + 
935
		"		if (token.equals(\"pkgDefaultMethod___\")\n" + 
936
		"																						 * backward\r\n" + 
936
		"				|| token.equals(\"packageDefaultMethod___\")/*\n" + 
937
		"																						 * compatible\r\n" + 
937
		"														 * _backward_\n" + 
938
		"																						 */) { //$NON-NLS-1$ //$NON-NLS-2$\r\n" + 
938
		"														 * _compatible_\n" + 
939
		"		}\r\n" + 
939
		"														 */) {\n" + 
940
		"	}\r\n" + 
940
		"		}\n" + 
941
		"}\r\n",
941
		"	}\n" + 
942
		false /* do not repeat */
942
		"}\n"
943
	);
943
	);
944
}
944
}
945
public void testBlockComments14() throws JavaModelException {
945
public void testBlockComments14() throws JavaModelException {

Return to bug 305830