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
d5fb2c9614
commit
bf6112d9f0
2 changed files with 25 additions and 3 deletions
|
@ -3593,9 +3593,13 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
||||||
stmt.accept(this);
|
stmt.accept(this);
|
||||||
scribe.unIndent();
|
scribe.unIndent();
|
||||||
} else {
|
} else {
|
||||||
scribe.printTrailingComment();
|
// Don't insert a line break if we have already passed the start of the statement.
|
||||||
scribe.startNewLine();
|
// This is possible with macro expansions.
|
||||||
scribe.indent();
|
if (scribe.scanner.getCurrentPosition() <= stmt.getFileLocation().getNodeOffset()) {
|
||||||
|
scribe.printTrailingComment();
|
||||||
|
scribe.startNewLine();
|
||||||
|
scribe.indent();
|
||||||
|
}
|
||||||
stmt.accept(this);
|
stmt.accept(this);
|
||||||
scribe.unIndent();
|
scribe.unIndent();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1435,6 +1435,24 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
assertFormatterResult();
|
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;
|
||||||
|
|
||||||
//bool member __attribute__ ((__unused__)) = false;
|
//bool member __attribute__ ((__unused__)) = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue