1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 397710 - Fix bool macro used in struct/class

Change-Id: Ifc900b4b5f522ce778c49072eb9ceac7be9234ed
Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
This commit is contained in:
Marco Stornelli 2019-04-06 10:42:44 +02:00 committed by Jeff Johnston
parent 3dc407d008
commit ce60ebbbf6
2 changed files with 33 additions and 11 deletions

View file

@ -2003,7 +2003,8 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
scribe.startNewLine(); scribe.startNewLine();
IASTDeclaration[] memberDecls = node.getMembers(); IASTDeclaration[] memberDecls = node.getMembers();
for (IASTDeclaration declaration : memberDecls) { for (int i = 0; i < memberDecls.length; i++) {
IASTDeclaration declaration = memberDecls[i];
if (preferences.indent_body_declarations_compare_to_access_specifier) { if (preferences.indent_body_declarations_compare_to_access_specifier) {
scribe.indent(); scribe.indent();
} }
@ -2012,18 +2013,24 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
if (preferences.indent_body_declarations_compare_to_access_specifier) { if (preferences.indent_body_declarations_compare_to_access_specifier) {
scribe.unIndent(); scribe.unIndent();
} }
if (enterNode(declaration)) { IASTDeclaration next = null;
scribe.startNewLine(); if (i < memberDecls.length - 1 && !(memberDecls[i + 1] instanceof IASTProblemHolder))
visit((ICPPASTVisibilityLabel) declaration); next = memberDecls[i + 1];
scribe.startNewLine(); if (i == memberDecls.length - 1 || next == null || !doNodeLocationsOverlap(declaration, next)) {
exitNode(declaration);
}
} else {
if (enterNode(declaration)) {
if (getCurrentPosition() <= nodeOffset(declaration)) if (getCurrentPosition() <= nodeOffset(declaration))
scribe.startNewLine(); scribe.startNewLine();
formatDeclaration(declaration); }
exitNode(declaration); declaration.accept(this);
} else {
if (!(declaration instanceof IASTProblemHolder)) {
IASTDeclaration next = null;
if (i < memberDecls.length - 1 && !(memberDecls[i + 1] instanceof IASTProblemHolder))
next = memberDecls[i + 1];
if (i == memberDecls.length - 1 || next == null || !doNodeLocationsOverlap(declaration, next)) {
if (getCurrentPosition() <= nodeOffset(declaration))
scribe.startNewLine();
}
declaration.accept(this);
} else { } else {
skipNode(declaration); skipNode(declaration);
} }

View file

@ -4003,4 +4003,19 @@ public class CodeFormatterTest extends BaseUITestCase {
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, CCorePlugin.INSERT); fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, CCorePlugin.INSERT);
assertFormatterResult(); assertFormatterResult();
} }
//#define bool bool
//struct ARGS {
// bool _unprune;
// bool _distributed_timing;
//};
//#define bool bool
//struct ARGS {
// bool _unprune;
// bool _distributed_timing;
//};
public void testBoolInStructWithMacro_Bug397710() throws Exception {
assertFormatterResult();
}
} }