From 3edce39739a91463835411e629001eef02d75ebf Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Tue, 4 Oct 2011 16:30:12 -0700 Subject: [PATCH] Bug 359905 - Invalid formatting of comment in enum. --- .../formatter/CodeFormatterVisitor.java | 1 + .../cdt/ui/tests/text/CodeFormatterTest.java | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+) 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 2368c0aee5c..b4626fc404e 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 @@ -2032,6 +2032,7 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, scribe.space(); } } + scribe.printTrailingComment(); if (enumIndent > braceIndent) { scribe.unIndent(); 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 989fa1fac6c..ef9692b2095 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 @@ -2736,4 +2736,26 @@ public class CodeFormatterTest extends BaseUITestCase { assertFormatterResult(); } + //enum SomeEnum { + //FirstValue,// first value comment + //SecondValue// second value comment + //}; + //enum OtherEnum { + //First,// first value comment + //Second,// second value comment + //}; + + //enum SomeEnum { + // FirstValue, // first value comment + // SecondValue // second value comment + //}; + //enum OtherEnum { + // First, // first value comment + // Second, // second value comment + //}; + public void testEnum() throws Exception { + fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE); + fOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_MIN_DISTANCE_BETWEEN_CODE_AND_LINE_COMMENT, "2"); + assertFormatterResult(); + } }