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:
parent
3dc407d008
commit
ce60ebbbf6
2 changed files with 33 additions and 11 deletions
|
@ -2003,7 +2003,8 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
|||
scribe.startNewLine();
|
||||
|
||||
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) {
|
||||
scribe.indent();
|
||||
}
|
||||
|
@ -2012,18 +2013,24 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
|
|||
if (preferences.indent_body_declarations_compare_to_access_specifier) {
|
||||
scribe.unIndent();
|
||||
}
|
||||
if (enterNode(declaration)) {
|
||||
scribe.startNewLine();
|
||||
visit((ICPPASTVisibilityLabel) declaration);
|
||||
scribe.startNewLine();
|
||||
exitNode(declaration);
|
||||
}
|
||||
} else {
|
||||
if (enterNode(declaration)) {
|
||||
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();
|
||||
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 {
|
||||
skipNode(declaration);
|
||||
}
|
||||
|
|
|
@ -4003,4 +4003,19 @@ public class CodeFormatterTest extends BaseUITestCase {
|
|||
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, CCorePlugin.INSERT);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue