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

(-)formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java (-2 / +2 lines)
Lines 1505-1511 Link Here
1505
						isChunkStart = memberAlignment.checkChunkStart(TYPE, i, this.scribe.scanner.currentPosition);
1505
						isChunkStart = memberAlignment.checkChunkStart(TYPE, i, this.scribe.scanner.currentPosition);
1506
						format((TypeDeclaration)member, null, isChunkStart, i == 0);
1506
						format((TypeDeclaration)member, null, isChunkStart, i == 0);
1507
					}
1507
					}
1508
					if (isNextToken(TerminalTokens.TokenNameSEMICOLON)) {
1508
					while (isNextToken(TerminalTokens.TokenNameSEMICOLON)) {
1509
						this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
1509
						this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
1510
						this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
1510
						this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
1511
					}
1511
					}
Lines 2021-2027 Link Here
2021
							isChunkStart = memberAlignment.checkChunkStart(Alignment.CHUNK_TYPE, i, this.scribe.scanner.currentPosition);
2021
							isChunkStart = memberAlignment.checkChunkStart(Alignment.CHUNK_TYPE, i, this.scribe.scanner.currentPosition);
2022
							format((TypeDeclaration)member, typeDeclaration.scope, isChunkStart, i == 0);
2022
							format((TypeDeclaration)member, typeDeclaration.scope, isChunkStart, i == 0);
2023
						}
2023
						}
2024
						if (isNextToken(TerminalTokens.TokenNameSEMICOLON)) {
2024
						while (isNextToken(TerminalTokens.TokenNameSEMICOLON)) {
2025
							this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
2025
							this.scribe.printNextToken(TerminalTokens.TokenNameSEMICOLON, this.preferences.insert_space_before_semicolon);
2026
							this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
2026
							this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
2027
						}
2027
						}
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java (+55 lines)
Lines 5373-5376 Link Here
5373
	);
5373
	);
5374
}
5374
}
5375
5375
5376
/**
5377
 * @bug 309706: [formatter] doesn´t work when code has three semicolons side by side
5378
 * @test Verify that formatter does get puzzled by three consecutive semicolons
5379
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=309706"
5380
 */
5381
public void testBug309706() {
5382
	String source =
5383
		"public class Test {\n" + 
5384
		"\n" + 
5385
		"    private int id;;;\n" + 
5386
		"\n" + 
5387
		"    private void dummy() {\n" + 
5388
		"\n" + 
5389
		"        if (true) {\n" + 
5390
		"                    System.out.println(\"bla\");\n" + 
5391
		"        }\n" + 
5392
		"    }\n" + 
5393
		"}\n";
5394
	formatSource(source,
5395
		"public class Test {\n" + 
5396
		"\n" + 
5397
		"	private int id;;;\n" + 
5398
		"\n" + 
5399
		"	private void dummy() {\n" + 
5400
		"\n" + 
5401
		"		if (true) {\n" + 
5402
		"			System.out.println(\"bla\");\n" + 
5403
		"		}\n" + 
5404
		"	}\n" + 
5405
		"}\n"
5406
	);
5407
}
5408
public void testBug309706b() {
5409
	String source =
5410
		"    private int id;;;\n" + 
5411
		"\n" + 
5412
		"    private void dummy() {\n" + 
5413
		"\n" + 
5414
		"        if (true) {\n" + 
5415
		"                    System.out.println(\"bla\");\n" + 
5416
		"        }\n" + 
5417
		"	}\n";
5418
	formatSource(source,
5419
		"private int id;;;\n" + 
5420
		"\n" + 
5421
		"private void dummy() {\n" + 
5422
		"\n" + 
5423
		"	if (true) {\n" + 
5424
		"		System.out.println(\"bla\");\n" + 
5425
		"	}\n" + 
5426
		"}",
5427
		CodeFormatter.K_CLASS_BODY_DECLARATIONS
5428
	);
5429
}
5430
5376
}
5431
}

Return to bug 309706