mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +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
|
@Override
|
||||||
public int visit(IASTStatement node) {
|
public int visit(IASTStatement node) {
|
||||||
if (getCurrentPosition() <= nodeOffset(node) &&
|
if (getCurrentPosition() <= nodeOffset(node) && startsWithMacroExpansion(node)) {
|
||||||
startsWithMacroExpansion(node)) {
|
|
||||||
scribe.printCommentPreservingNewLines();
|
scribe.printCommentPreservingNewLines();
|
||||||
}
|
}
|
||||||
if (!startNode(node)) { return PROCESS_SKIP; }
|
if (!startNode(node)) { return PROCESS_SKIP; }
|
||||||
|
@ -1916,7 +1915,8 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
||||||
} else {
|
} else {
|
||||||
if (startNode(declaration)) {
|
if (startNode(declaration)) {
|
||||||
try {
|
try {
|
||||||
scribe.startNewLine();
|
if (getCurrentPosition() <= nodeOffset(declaration))
|
||||||
|
scribe.startNewLine();
|
||||||
formatDeclaration(declaration);
|
formatDeclaration(declaration);
|
||||||
} finally {
|
} finally {
|
||||||
finishNode(declaration);
|
finishNode(declaration);
|
||||||
|
|
|
@ -1865,6 +1865,20 @@ public class CodeFormatterTest extends BaseUITestCase {
|
||||||
assertFormatterResult();
|
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;
|
||||||
|
|
||||||
//bool member __attribute__ ((__unused__)) = false;
|
//bool member __attribute__ ((__unused__)) = false;
|
||||||
|
|
Loading…
Add table
Reference in a new issue