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

(-)formatter/org/eclipse/jdt/internal/formatter/CodeFormatterVisitor.java (+1 lines)
Lines 1156-1161 Link Here
1156
					this.scribe.printNewLine();
1156
					this.scribe.printNewLine();
1157
				}
1157
				}
1158
			} else if (hasConstants) {
1158
			} else if (hasConstants) {
1159
				this.scribe.printComment(CodeFormatter.K_UNKNOWN, Scribe.BASIC_TRAILING_COMMENT);
1159
				// only had a new line if there is at least one enum constant
1160
				// only had a new line if there is at least one enum constant
1160
				this.scribe.printNewLine();
1161
				this.scribe.printNewLine();
1161
			}
1162
			}
(-)src/org/eclipse/jdt/core/tests/formatter/FormatterBugsTests.java (+19 lines)
Lines 7628-7631 Link Here
7628
		"}\n"
7628
		"}\n"
7629
	);
7629
	);
7630
}
7630
}
7631
7632
/**
7633
 * @bug 332877: [formatter] line comment wrongly put on a new line
7634
 * @test Ensure that the comment on last enum constant is not wrongly put on a new line
7635
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=332877"
7636
 */
7637
public void testBug332877() throws Exception {
7638
	String source =
7639
		"public enum Environment {\n" + 
7640
		"    PROD,       // Production level environments\n" + 
7641
		"    STAGING    // Staging\n" + 
7642
		"}\n";
7643
	formatSource(source,
7644
		"public enum Environment {\n" + 
7645
		"	PROD, // Production level environments\n" + 
7646
		"	STAGING // Staging\n" + 
7647
		"}\n"
7648
	);
7649
}
7631
}
7650
}

Return to bug 332877