mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Fixed a bug in formatting of declarations contained in macro expansion.
This commit is contained in:
parent
b6cf5bbc41
commit
9d10668c5e
2 changed files with 17 additions and 3 deletions
|
@ -928,8 +928,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
|||
*/
|
||||
@Override
|
||||
public int visit(IASTStatement node) {
|
||||
if (getCurrentPosition() <= nodeOffset(node) &&
|
||||
startsWithMacroExpansion(node)) {
|
||||
if (getCurrentPosition() <= nodeOffset(node) && startsWithMacroExpansion(node)) {
|
||||
scribe.printCommentPreservingNewLines();
|
||||
}
|
||||
if (!startNode(node)) { return PROCESS_SKIP; }
|
||||
|
@ -1916,7 +1915,8 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
|||
} else {
|
||||
if (startNode(declaration)) {
|
||||
try {
|
||||
scribe.startNewLine();
|
||||
if (getCurrentPosition() <= nodeOffset(declaration))
|
||||
scribe.startNewLine();
|
||||
formatDeclaration(declaration);
|
||||
} finally {
|
||||
finishNode(declaration);
|
||||
|
|
|
@ -1865,6 +1865,20 @@ public class CodeFormatterTest extends BaseUITestCase {
|
|||
assertFormatterResult();
|
||||
}
|
||||
|
||||
//#define MACRO(a) a(const a&); void operator=(const a&)
|
||||
//
|
||||
//class Test{MACRO(Test);};
|
||||
|
||||
//#define MACRO(a) a(const a&); void operator=(const a&)
|
||||
//
|
||||
//class Test {
|
||||
// MACRO(Test);
|
||||
//};
|
||||
public void testMacroDeclaration() throws Exception {
|
||||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE);
|
||||
assertFormatterResult();
|
||||
}
|
||||
|
||||
//bool member __attribute__ ((__unused__)) = false;
|
||||
|
||||
//bool member __attribute__ ((__unused__)) = false;
|
||||
|
|
Loading…
Add table
Reference in a new issue