commit | 0f1940afc569e3dda300f55ff2d321a11c7e8c1c | [log] [tgz] |
---|---|---|
author | Marco Stornelli <marco.stornelli@gmail.com> | Sun May 31 09:46:41 2020 +0200 |
committer | Marco Stornelli <marco.stornelli@gmail.com> | Mon Jun 01 04:37:13 2020 -0400 |
tree | 8e1ba030b83735f46dfca300b6955d1e52d27d66 | |
parent | cfc3278454eecf3c1b8b93f69be0b4b9d5a5a3d2 [diff] |
Bug 487990 - Fix format of variadic functions Change-Id: I802d032f733247178db46c8fe43fdb9350555509
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 f7f0294..67e4141 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
@@ -2605,7 +2605,9 @@ } if (addEllipsis) { if (i > 0) { - scribe.printNextToken(options.fSeparatorToken, options.fSpaceBeforeSeparator); + if (peekNextToken() == options.fSeparatorToken) { + scribe.printNextToken(options.fSeparatorToken, options.fSpaceBeforeSeparator); + } scribe.printTrailingComment(); } scribe.alignFragment(alignment, i);
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 b850037..a2a490f 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
@@ -4814,4 +4814,15 @@ public void testNoexcept_Bug562723() throws Exception { assertFormatterResult(); } + + //void foo(int...) {} + //int main() {} + + //void foo(int ...) { + //} + //int main() { + //} + public void testVariadicFunction_Bug487990() throws Exception { + assertFormatterResult(); + } }