Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarco Stornelli2019-03-13 13:06:38 -0400
committerMarco Stornelli2019-07-20 04:18:08 -0400
commit04350fec0eb5063051144fa63c116fa7e83adb09 (patch)
tree04777e9d3834e51823d1e2ed081c4782624e8f9a
parente744550278131f5c6ee3cd98a75bd7aa4b9ad399 (diff)
downloadorg.eclipse.cdt-04350fec0eb5063051144fa63c116fa7e83adb09.tar.gz
org.eclipse.cdt-04350fec0eb5063051144fa63c116fa7e83adb09.tar.xz
org.eclipse.cdt-04350fec0eb5063051144fa63c116fa7e83adb09.zip
Bug 376395 - Fix const methods with never join wrapped lines
When at the same time never join wrapped lines and next line for opening function brace were selected, two tabs were added. Change-Id: I90f606bf7f8b7bb7e83f3ae85d7cbb9cd0146b97 Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java3
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java16
2 files changed, 18 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 a50ba70a5b..ffe73d2a7d 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
@@ -368,7 +368,8 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor,
}
} else {
// Skip the rest (=0)
- if (needSpace && scribe.printComment()) {
+ if (needSpace) {
+ scribe.printTrailingComment();
scribe.space();
}
skipNode(node);
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 49c0151164..c2c2473883 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
@@ -4444,4 +4444,20 @@ public class CodeFormatterTest extends BaseUITestCase {
fOptions.put(DefaultCodeFormatterConstants.FORMATTER_COMMENT_LINE, DefaultCodeFormatterConstants.FALSE);
assertFormatterResult();
}
+
+ //int foo(int arg1) const
+ //{
+ // return 2;
+ //}
+
+ //int foo(int arg1) const
+ //{
+ // return 2;
+ //}
+ public void testConstMethodsWithNeverJoin_Bug376395() throws Exception {
+ fOptions.put(DefaultCodeFormatterConstants.FORMATTER_JOIN_WRAPPED_LINES, false);
+ fOptions.put(DefaultCodeFormatterConstants.FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION,
+ DefaultCodeFormatterConstants.NEXT_LINE);
+ assertFormatterResult();
+ }
}

Back to the top