Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Stornelli2019-10-13 08:14:28 +0000
committerMarco Stornelli2019-10-13 08:16:08 +0000
commit5c77776dcd0bd006d0161cc0d7d6870e738dd8b0 (patch)
tree301edfdb5a9f96fa1aa2dca86da78d71459028bb
parentf8316e315ba5737fa3134b343f30625062a75519 (diff)
downloadorg.eclipse.cdt-5c77776dcd0bd006d0161cc0d7d6870e738dd8b0.tar.gz
org.eclipse.cdt-5c77776dcd0bd006d0161cc0d7d6870e738dd8b0.tar.xz
org.eclipse.cdt-5c77776dcd0bd006d0161cc0d7d6870e738dd8b0.zip
Bug 550096 - Fix format function parameters in macro expansion
Change-Id: I509e434032a49a853e1794ab2d4b5a6a864eb5da Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java6
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java9
2 files changed, 13 insertions, 2 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 05c2f61d5b..2506888c15 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
@@ -2483,8 +2483,10 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
*/
private void formatList(List<?> elements, ListOptions options, boolean encloseInParen, boolean addEllipsis,
Runnable tailFormatter, Runnable prefix) {
- if (encloseInParen)
- scribe.printNextToken(options.leftToken, options.fSpaceBeforeOpeningParen);
+ if (encloseInParen) {
+ if (peekNextToken() == options.leftToken)
+ scribe.printNextToken(options.leftToken, options.fSpaceBeforeOpeningParen);
+ }
final int elementsLength = elements.size();
if (encloseInParen) {
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java
index f7f52b193a..c112ca61d8 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java
@@ -4699,4 +4699,13 @@ public class CodeFormatterTest extends BaseUITestCase {
public void testStructuredBindingInSwitchInitStatement() throws Exception {
assertFormatterResult();
}
+
+ //#define PROTO(X) X
+ //void foo PROTO((char* b));
+
+ //#define PROTO(X) X
+ //void foo PROTO((char* b));
+ public void testMacroInFunctionParameters_Bug550096() throws Exception {
+ assertFormatterResult();
+ }
}

Back to the top