Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Stornelli2019-05-17 14:27:35 -0400
committerMarco Stornelli2019-05-18 02:15:26 -0400
commit1cd5180642ada741ec45500ec3aba26f8855fb36 (patch)
tree80cec32755d861357d012b98727539b24a2981b2 /core/org.eclipse.cdt.core
parent6452688c183614a4bc1f4163a253f08d2dc507d9 (diff)
downloadorg.eclipse.cdt-1cd5180642ada741ec45500ec3aba26f8855fb36.tar.gz
org.eclipse.cdt-1cd5180642ada741ec45500ec3aba26f8855fb36.tar.xz
org.eclipse.cdt-1cd5180642ada741ec45500ec3aba26f8855fb36.zip
Bug 353022 - Fix format switch without parenthesis
Change-Id: I8d8a6498abe5c08c65c03f86b563563910f01098 Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
Diffstat (limited to 'core/org.eclipse.cdt.core')
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
index bd5c069f87..d6518351cf 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java
@@ -3998,11 +3998,13 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
}
// switch body
String brace_position = preferences.brace_position_for_switch;
+ boolean hasOpenBrace = false;
int braceIndent = -1;
IASTStatement bodyStmt = node.getBody();
if (!startsWithMacroExpansion(bodyStmt)) {
boolean insertSpaceBeforeOpeningBrace = preferences.insert_space_before_opening_brace_in_switch;
formatAttributes(bodyStmt, insertSpaceBeforeOpeningBrace, false);
+ hasOpenBrace = peekNextToken() == Token.tLBRACE;
formatOpeningBrace(brace_position, insertSpaceBeforeOpeningBrace);
scribe.startNewLine();
braceIndent = scribe.numberOfIndentations;
@@ -4142,7 +4144,8 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
}
scribe.startNewLine();
- formatClosingBrace(brace_position);
+ if (hasOpenBrace)
+ formatClosingBrace(brace_position);
}
exitNode(bodyStmt);
return PROCESS_SKIP;

Back to the top