diff options
author | Sergey Prigogin | 2011-03-16 00:42:31 +0000 |
---|---|---|
committer | Sergey Prigogin | 2011-03-16 00:42:31 +0000 |
commit | 199adb3ec55dbb839aab228415e1478ab1a6f760 (patch) | |
tree | cb0ed1ecd3fac87c57f85ed2448d9dce903cc983 | |
parent | b131a8f06bdb5bef93128c72263f276d3bd6aff4 (diff) | |
download | org.eclipse.cdt-199adb3ec55dbb839aab228415e1478ab1a6f760.tar.gz org.eclipse.cdt-199adb3ec55dbb839aab228415e1478ab1a6f760.tar.xz org.eclipse.cdt-199adb3ec55dbb839aab228415e1478ab1a6f760.zip |
Improved formatting of function calls.
-rw-r--r-- | core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/align/Alignment.java | 6 | ||||
-rw-r--r-- | core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java | 23 |
2 files changed, 28 insertions, 1 deletions
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/align/Alignment.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/align/Alignment.java index 5f68e2ea0c6..f3137c74c07 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/align/Alignment.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/align/Alignment.java @@ -272,6 +272,12 @@ public class Alignment { case M_COMPACT_SPLIT: i = this.fragmentIndex; do { + if (i == 0 && (mode & M_INDENT_ON_COLUMN) != 0 && + name.startsWith(LIST_ELEMENTS_PREFIX)) { + // Don't split the line before the first element of the list if the list + // elements are indented on column. + break; + } if (this.fragmentBreaks[i] == NONE) { this.fragmentBreaks[i] = BREAK; this.fragmentIndentations[i] = this.breakIndentationLevel; 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 575456c313a..03c402206c9 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 @@ -1054,11 +1054,32 @@ public class CodeFormatterTest extends BaseUITestCase { // f1(100000, 200000, 300000, 400000, 500000, // f2(10, 20, 30, 40, 50, 60, 70000), 700000); //} - public void testFunctionCall() throws Exception { + public void testFunctionCall_1() throws Exception { fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE); assertFormatterResult(); } + //int function(int, int, int, int, int); + //int function_with_a_long_name(int, int); + // + //void test() { + //function_with_a_long_name(function(1000000, 2000000, 3000000, 4000000, 5000000), 6000000); + //} + + //int function(int, int, int, int, int); + //int function_with_a_long_name(int, int); + // + //void test() { + // function_with_a_long_name(function(1000000, 2000000, 3000000, 4000000, + // 5000000), 6000000); + //} + public void testFunctionCall_2() throws Exception { + fOptions.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, CCorePlugin.SPACE); + fOptions.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, + Integer.toString(Alignment.M_COMPACT_SPLIT | Alignment.M_INDENT_ON_COLUMN)); + assertFormatterResult(); + } + //void function(const char* s); // //void test() { |