mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
Bug 535266: Formatter error CaseStatement with attributes
Fix and test. Also fixes formatting errors with DefaultStatements. Change-Id: Idac4a7105d7ae86db40755bd27cef60e197de664 Signed-off-by: Hansruedi Patzen <hansruedi.patzen@hsr.ch> Signed-off-by: Thomas Corbat <tcorbat@hsr.ch>
This commit is contained in:
parent
8792d9d5a6
commit
3f98811f73
2 changed files with 23 additions and 0 deletions
|
@ -3615,6 +3615,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
||||||
|
|
||||||
private int visit(IASTCaseStatement node) {
|
private int visit(IASTCaseStatement node) {
|
||||||
IASTExpression constant = node.getExpression();
|
IASTExpression constant = node.getExpression();
|
||||||
|
formatLeadingAttributes(node);
|
||||||
if (constant == null) {
|
if (constant == null) {
|
||||||
scribe.printNextToken(Token.t_default);
|
scribe.printNextToken(Token.t_default);
|
||||||
scribe.printNextToken(Token.tCOLON, preferences.insert_space_before_colon_in_default);
|
scribe.printNextToken(Token.tCOLON, preferences.insert_space_before_colon_in_default);
|
||||||
|
@ -3628,6 +3629,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
||||||
}
|
}
|
||||||
|
|
||||||
private int visit(IASTDefaultStatement node) {
|
private int visit(IASTDefaultStatement node) {
|
||||||
|
formatLeadingAttributes(node);
|
||||||
scribe.printNextToken(Token.t_default);
|
scribe.printNextToken(Token.t_default);
|
||||||
scribe.printNextToken(Token.tCOLON, preferences.insert_space_before_colon_in_default);
|
scribe.printNextToken(Token.tCOLON, preferences.insert_space_before_colon_in_default);
|
||||||
return PROCESS_SKIP;
|
return PROCESS_SKIP;
|
||||||
|
|
|
@ -3384,4 +3384,25 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
public void testInlineNamespace_Bug532849() throws Exception {
|
public void testInlineNamespace_Bug532849() throws Exception {
|
||||||
assertFormatterResult();
|
assertFormatterResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//void f() {
|
||||||
|
// switch (1) {
|
||||||
|
// [[foo]] case 1:
|
||||||
|
// break;
|
||||||
|
// [[foo]] default:
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//void f() {
|
||||||
|
// switch (1) {
|
||||||
|
// [[foo]] case 1:
|
||||||
|
// break;
|
||||||
|
// [[foo]] default:
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
public void testFormatAttributedLabelStatements_Bug535266() throws Exception {
|
||||||
|
assertFormatterResult();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue