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:
parent
bf6112d9f0
commit
5aa57c8075
2 changed files with 6 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue