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:08:04 +00:00
parent d5fb2c9614
commit bf6112d9f0
2 changed files with 25 additions and 3 deletions

View file

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

View file

@ -1435,6 +1435,24 @@ public class CodeFormatterTest extends BaseUITestCase {
assertFormatterResult();
}
//#define MACRO(a, b) while (a) b
//bool f();
//void g();
//void test() {
//MACRO(f(), g());
//}
//#define MACRO(a, b) while (a) b
//bool f();
//void g();
//void test() {
// MACRO(f(), g());
//}
public void testMacroStatement() throws Exception {
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE);
assertFormatterResult();
}
//bool member __attribute__ ((__unused__)) = false;
//bool member __attribute__ ((__unused__)) = false;