Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Stornelli2020-05-31 07:46:41 +0000
committerMarco Stornelli2020-06-01 14:30:35 +0000
commitff0912e6325fc389b33c0e637fd10ad611fa3fbc (patch)
tree405f3434ae78a13fcacd09fc436263f36711bb54
parent92df241b389ffa0da150962f1b7cb797f7b87691 (diff)
downloadorg.eclipse.cdt-cdt_9_11.tar.gz
org.eclipse.cdt-cdt_9_11.tar.xz
org.eclipse.cdt-cdt_9_11.zip
Bug 487990 - Fix format of variadic functionscdt_9_11
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java4
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java11
2 files changed, 14 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 19239262c9..240db77686 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
@@ -2582,7 +2582,9 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
}
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 47269ee5a8..47ee70ce11 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
@@ -4777,4 +4777,15 @@ public class CodeFormatterTest extends BaseUITestCase {
public void testNoexcept_Bug562723() throws Exception {
assertFormatterResult();
}
+
+ //void foo(int...) {}
+ //int main() {}
+
+ //void foo(int ...) {
+ //}
+ //int main() {
+ //}
+ public void testVariadicFunction_Bug487990() throws Exception {
+ assertFormatterResult();
+ }
}

Back to the top