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

(-)compiler/org/eclipse/jdt/internal/compiler/parser/AbstractCommentParser.java (-1 / +3 lines)
Lines 147-152 Link Here
147
			boolean verifText = (this.kind & TEXT_VERIF) != 0;
147
			boolean verifText = (this.kind & TEXT_VERIF) != 0;
148
			boolean isDomParser = (this.kind & DOM_PARSER) != 0;
148
			boolean isDomParser = (this.kind & DOM_PARSER) != 0;
149
			boolean isFormatterParser = (this.kind & FORMATTER_COMMENT_PARSER) != 0;
149
			boolean isFormatterParser = (this.kind & FORMATTER_COMMENT_PARSER) != 0;
150
			int lastStarPosition = -1;
150
151
151
			// Init scanner position
152
			// Init scanner position
152
			this.linePtr = getLineNumber(this.firstTagPosition);
153
			this.linePtr = getLineNumber(this.firstTagPosition);
Lines 325-330 Link Here
325
						break;
326
						break;
326
					case '*' :
327
					case '*' :
327
						// Store the star position as text start while formatting
328
						// Store the star position as text start while formatting
329
						lastStarPosition = previousPosition;
328
						if (previousChar != '*') {
330
						if (previousChar != '*') {
329
							this.starPosition = previousPosition;
331
							this.starPosition = previousPosition;
330
							if (isDomParser || isFormatterParser) {
332
							if (isDomParser || isFormatterParser) {
Lines 401-407 Link Here
401
				}
403
				}
402
				refreshInlineTagPosition(textEndPosition);
404
				refreshInlineTagPosition(textEndPosition);
403
				setInlineTagStarted(false);
405
				setInlineTagStarted(false);
404
			} else if (this.lineStarted && this.textStart != -1 && this.textStart <= textEndPosition) {
406
			} else if (this.lineStarted && this.textStart != -1 && this.textStart <= textEndPosition && (this.textStart < this.starPosition || this.starPosition == lastStarPosition)) {
405
				pushText(this.textStart, textEndPosition);
407
				pushText(this.textStart, textEndPosition);
406
			}
408
			}
407
			updateDocComment();
409
			updateDocComment();
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java (+90 lines)
Lines 3928-3931 Link Here
3928
		"}\n";
3928
		"}\n";
3929
	formatSource(source);
3929
	formatSource(source);
3930
}
3930
}
3931
3932
/**
3933
 * @bug 302123: [formatter] AssertionFailedException occurs while formatting a source containing the specific javadoc comment...
3934
 * @test Verify that no exception occurs while formatting source including the specific comment
3935
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=302123"
3936
 */
3937
public void testBug302123() {
3938
	String source = 
3939
		"package test;\n" + 
3940
		"public class Test {\n" + 
3941
		"	public static void main(String[] args) {\n" + 
3942
		"		String s=\"X\"+/** ***/\"Y\";\n" + 
3943
		"	}\n" + 
3944
		"\n" + 
3945
		"}\n";
3946
	formatSource(source,
3947
		"package test;\n" + 
3948
		"\n" + 
3949
		"public class Test {\n" + 
3950
		"	public static void main(String[] args) {\n" + 
3951
		"		String s = \"X\" + /** ***/\n" + 
3952
		"		\"Y\";\n" + 
3953
		"	}\n" + 
3954
		"\n" + 
3955
		"}\n"
3956
	);
3957
}
3958
public void testBug302123b() {
3959
	String source = 
3960
		"package test;\n" + 
3961
		"public class Test {\n" + 
3962
		"	public static void main(String[] args) {\n" + 
3963
		"		String s=\"X\"+/**    XXX   ***/\"Y\";\n" + 
3964
		"	}\n" + 
3965
		"\n" + 
3966
		"}\n";
3967
	formatSource(source,
3968
		"package test;\n" + 
3969
		"\n" + 
3970
		"public class Test {\n" + 
3971
		"	public static void main(String[] args) {\n" + 
3972
		"		String s = \"X\" + /** XXX ***/\n" + 
3973
		"		\"Y\";\n" + 
3974
		"	}\n" + 
3975
		"\n" + 
3976
		"}\n"
3977
	);
3978
}
3979
public void testBug302123c() {
3980
	String source = 
3981
		"package test;\n" + 
3982
		"public class Test {\n" + 
3983
		"	public static void main(String[] args) {\n" + 
3984
		"		String s=\"X\"+/**    **  XXX  **    ***/\"Y\";\n" + 
3985
		"	}\n" + 
3986
		"\n" + 
3987
		"}\n";
3988
	formatSource(source,
3989
		"package test;\n" + 
3990
		"\n" + 
3991
		"public class Test {\n" + 
3992
		"	public static void main(String[] args) {\n" + 
3993
		"		String s = \"X\" + /** ** XXX ** ***/\n" + 
3994
		"		\"Y\";\n" + 
3995
		"	}\n" + 
3996
		"\n" + 
3997
		"}\n"
3998
	);
3999
}
4000
public void testBug302123d() {
4001
	String source = 
4002
		"package test;\n" + 
4003
		"public class Test {\n" + 
4004
		"	public static void main(String[] args) {\n" + 
4005
		"		String s=\"X\"+/**AAA   *** BBB ***   CCC***/\"Y\";\n" + 
4006
		"	}\n" + 
4007
		"\n" + 
4008
		"}\n";
4009
	formatSource(source,
4010
		"package test;\n" + 
4011
		"\n" + 
4012
		"public class Test {\n" + 
4013
		"	public static void main(String[] args) {\n" + 
4014
		"		String s = \"X\" + /** AAA *** BBB *** CCC ***/\n" + 
4015
		"		\"Y\";\n" + 
4016
		"	}\n" + 
4017
		"\n" + 
4018
		"}\n"
4019
	);
4020
}
3931
}
4021
}

Return to bug 302123