View | Details | Raw Unified | Return to bug 234336
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsBugsTest.java (+23 lines)
Lines 954-957 Link Here
954
	this.preferences.comment_line_length = 40;
954
	this.preferences.comment_line_length = 40;
955
	formatUnit("bugs.b233224", "X01.java");
955
	formatUnit("bugs.b233224", "X01.java");
956
}
956
}
957
958
/**
959
 * @bug 234336: [formatter] JavaDocTestCase.testMultiLineCommentIndent* tests fail in I20080527-2000 build
960
 * @test Ensure that new comment formatter format all comments concerned by selections
961
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=234336"
962
 */
963
public void testBug234336() throws JavaModelException {
964
	String source = 
965
		"public class Test {\n" + 
966
		"	[#/**\n" + 
967
		"			 * test test\n" + 
968
		"				 */#]\n" + 
969
		"}\n";
970
	formatSource(source,
971
		"public class Test {\n" + 
972
		"	/**\n" + 
973
		"	 * test test\n" + 
974
		"	 */\n" + 
975
		"}\n",
976
		CodeFormatter.K_JAVA_DOC,
977
		1 /* indentation level */
978
	);
979
}
957
}
980
}
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterCommentsTests.java (-3 / +13 lines)
Lines 111-116 Link Here
111
}
111
}
112
112
113
void formatSource(String source, String formattedOutput) {
113
void formatSource(String source, String formattedOutput) {
114
	formatSource(source, formattedOutput, CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, 0);
115
}
116
117
void formatSource(String source, String formattedOutput, int kind, int indentationLevel) {
114
	int regionStart = source.indexOf("[#");
118
	int regionStart = source.indexOf("[#");
115
	if (regionStart != -1) {
119
	if (regionStart != -1) {
116
		IRegion[] regions =  new Region[10];
120
		IRegion[] regions =  new Region[10];
Lines 127-139 Link Here
127
			start = regionEnd + 2;
131
			start = regionEnd + 2;
128
			regionStart = source.indexOf("[#", start);
132
			regionStart = source.indexOf("[#", start);
129
		}
133
		}
130
		System.arraycopy(regions, 0, regions = new Region[idx], 0, idx);
131
		buffer.append(source.substring(start, source.length()));
134
		buffer.append(source.substring(start, source.length()));
132
		String newSource = buffer.toString();
135
		String newSource = buffer.toString();
133
		String result = runFormatter(codeFormatter(), newSource, CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, 0, regions, Util.LINE_SEPARATOR);
136
		String result;
137
		if (idx == 1) {
138
			// Use offset and length until bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=233967 is fixed
139
			result = runFormatter(codeFormatter(), newSource, kind, indentationLevel, regions[0].getOffset(), regions[0].getLength(), Util.LINE_SEPARATOR);
140
		} else {
141
			System.arraycopy(regions, 0, regions = new Region[idx], 0, idx);
142
			result = runFormatter(codeFormatter(), newSource, kind, indentationLevel, regions, Util.LINE_SEPARATOR);
143
		}
134
		assertLineEquals(result, newSource, formattedOutput, false);
144
		assertLineEquals(result, newSource, formattedOutput, false);
135
	} else {
145
	} else {
136
		formatSource(source, formattedOutput, CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, 0, false, 0, -1, null);
146
		formatSource(source, formattedOutput, kind, indentationLevel, false, 0, -1, null);
137
	}
147
	}
138
}
148
}
139
149
(-)formatter/org/eclipse/jdt/internal/formatter/Scribe.java (-1 / +5 lines)
Lines 1896-1902 Link Here
1896
		// Set scanner
1896
		// Set scanner
1897
		initializeScanner(source.toCharArray());
1897
		initializeScanner(source.toCharArray());
1898
		this.scanner.resetTo(start, end);
1898
		this.scanner.resetTo(start, end);
1899
		this.scannerEndPosition = end;
1899
		// Put back 3.4RC2 code => comment following line  as it has an impact on Linux tests
1900
		// see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=234336
1901
		// TODO (frederic) Need more investigations and a better fix in 
1902
		// isAdaptableRegion(int) and adaptRegions()
1903
		// this.scannerEndPosition = end;
1900
1904
1901
		// Set indentation level
1905
		// Set indentation level
1902
	    this.numberOfIndentations = level;
1906
	    this.numberOfIndentations = level;

Return to bug 234336