1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Formatting of macro statements.

This commit is contained in:
Sergey Prigogin 2011-03-02 02:38:02 +00:00
parent bf6112d9f0
commit 5aa57c8075
2 changed files with 6 additions and 1 deletions

View file

@ -3595,13 +3595,16 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
} else {
// Don't insert a line break if we have already passed the start of the statement.
// This is possible with macro expansions.
boolean indented = false;
if (scribe.scanner.getCurrentPosition() <= stmt.getFileLocation().getNodeOffset()) {
scribe.printTrailingComment();
scribe.startNewLine();
scribe.indent();
indented = true;
}
stmt.accept(this);
scribe.unIndent();
if (indented)
scribe.unIndent();
}
}
}

View file

@ -1440,6 +1440,7 @@ public class CodeFormatterTest extends BaseUITestCase {
//void g();
//void test() {
//MACRO(f(), g());
//int i = 0;
//}
//#define MACRO(a, b) while (a) b
@ -1447,6 +1448,7 @@ public class CodeFormatterTest extends BaseUITestCase {
//void g();
//void test() {
// MACRO(f(), g());
// int i = 0;
//}
public void testMacroStatement() throws Exception {
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE);