diff --git a/org.eclipse.xtext.xbase.tests/.classpath b/org.eclipse.xtext.xbase.tests/.classpath index c59580bb78..2c3019a9a7 100644 --- a/org.eclipse.xtext.xbase.tests/.classpath +++ b/org.eclipse.xtext.xbase.tests/.classpath @@ -7,13 +7,6 @@ - - - - - - - diff --git a/org.eclipse.xtext.xbase.tests/build.properties b/org.eclipse.xtext.xbase.tests/build.properties index 3d4be68bf1..c387a04a8f 100644 --- a/org.eclipse.xtext.xbase.tests/build.properties +++ b/org.eclipse.xtext.xbase.tests/build.properties @@ -1,5 +1,4 @@ source.. = src/,\ - xtend-gen/,\ longrunning/src/,\ suites/,\ smoke-suites/ diff --git a/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/formatting/XbaseCommentFormatterTest.java b/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/formatting/XbaseCommentFormatterTest.java new file mode 100644 index 0000000000..dbb69b0f1d --- /dev/null +++ b/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/formatting/XbaseCommentFormatterTest.java @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2012, 2021 itemis AG (http://www.itemis.eu) and others. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.xtext.xbase.tests.formatting; + +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.XtextRunner; +import org.eclipse.xtext.testing.formatter.FormatterTestRequest; +import org.eclipse.xtext.util.Strings; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.google.inject.Inject; + +@RunWith(XtextRunner.class) +@InjectWith(XbaseFormatterTestInjectorProvider.class) +public class XbaseCommentFormatterTest { + @Inject + private XbaseFormatterTester xbaseFormatterTester; + + @Test + public void commentInIfExpression() { + xbaseFormatterTester.assertFormattedExpression((FormatterTestRequest it) -> { + String model = + "if (true)\n" + + " println(\"foo\")\n" + + "else // if (true)\n" + + " println(\"bar\")\n" + + "println(\"end\")\n"; + it.setToBeFormatted(Strings.toPlatformLineSeparator(model)); + }); + } + + @Test + public void commentAfterForExpression1() { + xbaseFormatterTester.assertFormattedExpression((FormatterTestRequest it) -> { + String model = + "for (f : #[])\n" + + " if (1 < 2) {\n" + + " }\n" + + "\n" + + "// foo\n" + + "var lastOffset = \"\"\n"; + it.setToBeFormatted(Strings.toPlatformLineSeparator(model)); + }); + } + + @Test + public void commentAfterForExpression3() { + xbaseFormatterTester.assertFormattedExpression((FormatterTestRequest it) -> { + String model = "val ll = #[].map(e|e.toString) // error here\n"; + it.setToBeFormatted(Strings.toPlatformLineSeparator(model)); + }); + } +} diff --git a/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/formatting/XbaseCommentFormatterTest.xtend b/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/formatting/XbaseCommentFormatterTest.xtend deleted file mode 100644 index ee3b6a183c..0000000000 --- a/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/formatting/XbaseCommentFormatterTest.xtend +++ /dev/null @@ -1,47 +0,0 @@ -package org.eclipse.xtext.xbase.tests.formatting - -import com.google.inject.Inject -import org.eclipse.xtext.testing.InjectWith -import org.eclipse.xtext.testing.XtextRunner -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(typeof(XtextRunner)) -@InjectWith(typeof(XbaseFormatterTestInjectorProvider)) -class XbaseCommentFormatterTest { - - @Inject extension XbaseFormatterTester - - @Test def commentInIfExpression() { - assertFormattedExpression [ - toBeFormatted = ''' - if (true) - println("foo") - else // if (true) - println("bar") - println("end") - ''' - ] - } - - @Test def commentAfterForExpression1() { - assertFormattedExpression [ - toBeFormatted = ''' - for (f : #[]) - if (1 < 2) { - } - - // foo - var lastOffset = "" - ''' - ] - } - - @Test def commentAfterForExpression3() { - assertFormattedExpression [ - toBeFormatted = ''' - val ll = #[].map(e|e.toString) // error here - ''' - ] - } -} diff --git a/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/formatting/XbaseFormatterTest.java b/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/formatting/XbaseFormatterTest.java new file mode 100644 index 0000000000..76a2be0baf --- /dev/null +++ b/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/formatting/XbaseFormatterTest.java @@ -0,0 +1,1114 @@ +/** + * Copyright (c) 2012, 2021 itemis AG (http://www.itemis.eu) and others. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.eclipse.xtext.xbase.tests.formatting; + +import org.eclipse.xtext.preferences.MapBasedPreferenceValues; +import org.eclipse.xtext.testing.InjectWith; +import org.eclipse.xtext.testing.XtextRunner; +import org.eclipse.xtext.testing.formatter.FormatterTestRequest; +import org.eclipse.xtext.util.Strings; +import org.eclipse.xtext.xbase.formatting2.XbaseFormatterPreferenceKeys; +import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; +import org.junit.Test; +import org.junit.runner.RunWith; + +import com.google.inject.Inject; + +@RunWith(XtextRunner.class) +@InjectWith(XbaseFormatterTestInjectorProvider.class) +public class XbaseFormatterTest { + @Inject + private XbaseFormatterTester xbaseFormatterTester; + + @Test + public void formatGenerics() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setToBeFormatted("val x = >newArrayList()\n"); + }); + } + + @Test + public void formatBlockExpression() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val x = newArrayList(\"A\", \"b\");\nval y = \'foo\';\nx.join\n"); + it.setToBeFormatted("val x = newArrayList(\"A\", \"b\") ; val y = \'foo\' ; x.join\n"); + }); + } + + @Test + public void formatBlockExpressionPreserveNewLines() { + xbaseFormatterTester.assertFormatted((FormatterTestRequest it) -> { + String expectation = "{\n\n\tval x = newArrayList(\"A\", \"b\");\n\n\tval y = \'foo\'\n\n\tx.join\n\n}\n".toString().trim(); + it.setExpectation(Strings.toPlatformLineSeparator(expectation)); + String toBeFormatted = " { \n\n\nval x = newArrayList(\"A\", \"b\") ;\n\n\nval y = \'foo\'\n\n\n x.join\n\n\n }\n"; + it.setToBeFormatted(Strings.toPlatformLineSeparator(toBeFormatted)); + }); + } + + @Test + public void formatClosures() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setToBeFormatted( + "val x = newArrayList(\"A\", \"b\")\nval y = x.filter[toUpperCase == it]\ny.join\n"); + }); + } + + @Test + public void formatClosuresParenthesis() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setToBeFormatted( + "val x = newArrayList(\"A\", \"b\")\nval y = x.filter(toUpperCase == it)\ny.join\n"); + }); + } + + @Test + public void formatClosuresParenthesis2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setToBeFormatted(Strings + .toPlatformLineSeparator("val x = newArrayList(\"A\", \"b\")\nval y = x.filter(foo|foo.toUpperCase == foo)\ny.join\n")); + }); + } + + @Test + public void formatClosuresSemicolon() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("newArrayList(\"A\", \"b\").filter[val b = it; b.toUpperCase == b]\n"); + it.setToBeFormatted( + "newArrayList(\"A\", \"b\").filter[ val b = it ; b.toUpperCase == b ]\n"); + }); + } + + @Test + public void formatClosuresEmpty() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val x = newArrayList(\"A\", \"b\")\nval y = x.filter[]\ny.join\n"); + it.setToBeFormatted("val x = newArrayList(\"A\", \"b\") val y = x.filter[ ] y.join\n"); + }); + } + + @Test + public void formatClosuresParam() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setToBeFormatted(Strings + .toPlatformLineSeparator("val x = newArrayList(\"A\", \"b\")\nval y = x.filter[z|z.toUpperCase == z]\ny.join\n")); + }); + } + + @Test + public void formatClosuresEmptyParam() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setToBeFormatted("val Iterable x = [|#[].iterator]\n"); + }); + } + + @Test + public void formatClosuresMultiLine() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val x = newArrayList(\"A\", \"b\")\nval y = x.filter [\n\tval z = it\n\tz.toUpperCase == z\n]\ny.join\n"); + it.setToBeFormatted("val x = newArrayList(\"A\", \"b\") val y = x.filter [\n\tval z = it z.toUpperCase == z \n] y.join\n"); + }); + } + + @Test + public void formatClosuresMultiLine_02() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val x = newArrayList(\"A\", \"b\")\nval y = x.filter [\n\tval z = it\n\tz.toUpperCase == z\n]\ny.join\n"); + it.setToBeFormatted("val x = newArrayList(\"A\", \"b\") val y = x.filter[\n\tval z = it z.toUpperCase == z \n] y.join\n"); + }); + } + + @Test + public void formatClosuresMultiLine03() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("new Thread [|\n\tprintln(\"foo\")\n]\n"); + it.setToBeFormatted("new Thread[ | println(\"foo\")\n]\n"); + }); + } + + @Test + public void formatClosuresMultiLineSemicolon() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val x = newArrayList(\"A\", \"b\")\nval y = x.filter [\n\tval z = it;\n\tz.toUpperCase == z;\n]\ny.join\n"); + it.setToBeFormatted("val x = newArrayList(\"A\", \"b\") val y = x.filter [\n\tval z = it ; z.toUpperCase == z ; \n] y.join\n"); + }); + } + + @Test + public void formatClosuresWrapIfNeeded() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val x = newArrayList(\"A\", \"b\")\nval y = x.filter [\n\tval z = it\n\tz.toUpperCase == z\n\tz.toUpperCase == z\n\tz.toUpperCase == z\n]\ny.join\n"); + it.setToBeFormatted("val x = newArrayList(\"A\", \"b\") val y = x.filter [ val z = it z.toUpperCase == z z.toUpperCase == z z.toUpperCase == z ] y.join\n"); + }); + } + + @Test + public void formatClosuresParamMultiLine() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val x = newArrayList(\"A\", \"b\")\nval y = x.filter [ z |\n\tval w = z\n\tw.toUpperCase == w\n]\ny.join\n"); + it.setToBeFormatted("val x = newArrayList(\"A\", \"b\") val y = x.filter[ z |\n\tval w = z w.toUpperCase == w\n] y.join\n"); + }); + } + + @Test + public void formatClosuresWithOperator() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val x = new StringBuffer() => [\n\tappend(\"x\")\n\tappend(\"y\")\n]\n"); + it.setToBeFormatted("val x = new StringBuffer() => [\n\tappend(\"x\")\n\tappend(\"y\")\n]\n"); + }); + } + + @Test + public void formatMultiLineClosureWithAssignment() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("x += foo.myBuilder [\n\tfoo\n\tbar\n]\n"); + it.setToBeFormatted("x += foo.myBuilder [\n\tfoo bar\n]\n"); + }); + } + + @Test + public void formatSynchronizedBlock_1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("synchronized (new Object) {\n}\n"); + it.setToBeFormatted("synchronized(new Object){}\n"); + }); + } + + @Test + public void formatSynchronizedBlock_2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("synchronized (new Object) {\n}\n"); + it.setToBeFormatted(Strings + .toPlatformLineSeparator("synchronized ( new Object ) { }\n")); + }); + } + + @Test + public void formatIf1SL1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisSL, Boolean.valueOf(true)); + }; + it.preferences(_function_1); + it.setToBeFormatted("if (true) println(\"foo\")\n"); + }); + } + + @Test + public void formatIf1SL2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisSL, Boolean.valueOf(false)); + }; + it.preferences(_function_1); + it.setToBeFormatted("if(true) println(\"foo\")\n"); + }); + } + + @Test + public void formatIf1ML1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(true)); + }; + it.preferences(_function_1); + it.setToBeFormatted("if (true)\n\tprintln(\"foo\")\n"); + }); + } + + @Test + public void formatIf1ML2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(false)); + }; + it.preferences(_function_1); + it.setToBeFormatted("if(true)\n\tprintln(\"foo\")\n"); + }); + } + + @Test + public void formatIf1MLVar() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("var x = if (true)\n\t\tprintln(\"foo\")\n\telse\n\t\tprintln(\"bar\")\n"); + it.setToBeFormatted("var x = if(true)\nprintln(\"foo\") else println(\"bar\")\n"); + }); + } + + @Test + public void formatIf1MLSemicolon1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("if (true)\n\tprintln(\"foo\");\n"); + it.setToBeFormatted("if(true)\nprintln(\"foo\");\n"); + }); + } + + @Test + public void formatIf1MLSemicolon2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("if (true)\n\tprintln(\"foo\");\nprintln(\"bar\")\n"); + it.setToBeFormatted("if(true)\nprintln(\"foo\");\nprintln(\"bar\")\n"); + }); + } + + @Test + public void formatIf2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setToBeFormatted("if (true) {\n\tprintln(\"foo\")\n}\n"); + }); + } + + @Test + public void formatIfElse1SL() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("if(true) println(\"foo\") else println(\"bar\")\n"); + it.setToBeFormatted("if(true)println(\"foo\")else println(\"bar\")\n"); + }); + } + + @Test + public void formatIfElse1ML() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("if (true)\n\tprintln(\"foo\")\nelse\n\tprintln(\"bar\")\n"); + it.setToBeFormatted("if(true)\nprintln(\"foo\")\nelse\nprintln(\"bar\")\n"); + }); + } + + @Test + public void formatIfElse2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setToBeFormatted("if (true) {\n\tprintln(\"foo\")\n} else {\n\tprintln(\"bar\")\n}\n"); + }); + } + + @Test + public void formatIfElse3() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); + }; + it.preferences(_function_1); + it.setToBeFormatted("if (true)\n{\n\tprintln(\"foo\")\n}\nelse\n{\n\tprintln(\"bar\")\n}\n"); + }); + } + + @Test + public void formatIfElseIf1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("if (true)\n\tprintln(\"foo\")\nelse if (false)\n\tprintln(\"bar\")\n"); + it.setToBeFormatted("if(true)\nprintln(\"foo\")\nelse if(false)\nprintln(\"bar\")\n"); + }); + } + + @Test + public void formatIfElseIf2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation( + "if (true) {\n\tprintln(\"foo\")\n} else if (false) {\n\tprintln(\"bar\")\n}\n"); + it.setToBeFormatted("if(true) {\nprintln(\"foo\")\n} else if(false) {\nprintln(\"bar\")\n}\n"); + }); + } + + @Test + public void formatIfElseIf3() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("if (true) {\n\tprintln(\"foo\")\n} else if (false)\n\tprintln(\"bar\")\n"); + it.setToBeFormatted("if(true) {\nprintln(\"foo\")\n} else if(false)\nprintln(\"bar\")\n"); + }); + } + + @Test + public void formatFor1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("for (i : 1 .. 2)\n\tprintln(i)\n"); + it.setToBeFormatted("for ( i : 1 .. 2 ) println(i)\n"); + }); + } + + @Test + public void formatFor2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(false)); + }; + it.preferences(_function_1); + it.setToBeFormatted("for (i : 1 .. 2) {\n\tprintln(i)\n}\n"); + }); + } + + @Test + public void formatFor3() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); + }; + it.preferences(_function_1); + it.setToBeFormatted("for (i : 1 .. 2)\n{\n\tprintln(i)\n}\n"); + }); + } + + @Test + public void formatBasicFor() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("for (var i = 1; i < 10; i = i + 1)\n\tprintln(i)\n"); + it.setToBeFormatted( + "for ( var i = 1 ; i < 10; i = i + 1 ) println(i)\n"); + }); + } + + @Test + public void formatBasicFor2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("for (;;) {\n\treturn true\n}\n"); + it.setToBeFormatted("for ( ; ; ) { return true }\n"); + }); + } + + @Test + public void formatBasicFor3() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("var int x\nvar int y\nfor (x = 1, y = 2;;) {\n\treturn x + y\n}\n"); + it.setToBeFormatted("var int x\nvar int y \nfor ( x = 1 , y = 2 ; ; ) { return x + y }\n"); + }); + } + + @Test + public void formatBasicFor4() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val x = 1\nfor (; x < 10;)\n\tprintln(x)\n"); + it.setToBeFormatted( + "val x = 1\nfor ( ; x < 10 ; ) println(x)\n"); + }); + } + + @Test + public void formatBasicFor5() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val x = 1\nfor (;; x = x + 1, x = x + 2)\n\tprintln(x)\n"); + it.setToBeFormatted("val x = 1\nfor ( ; ; x = x \t+ 1 , x = x + 2 ) println(x)\n"); + }); + } + + @Test + public void formatBasicFor6() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("for (val x = 1;; x = x + 1, x = x + 2)\n\tprintln(x)\n"); + it.setToBeFormatted("for (\t\t\tval \t\tx \t\t= \t\t1\t\t; ; x = x \t+ 1 , x = x + 2 ) println(x)\n"); + }); + } + + @Test + public void formatWhile11() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(true)); + }; + it.preferences(_function_1); + it.setToBeFormatted("while (true)\n\tprintln(\"x\")\n"); + }); + } + + @Test + public void formatWhile12() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(false)); + }; + it.preferences(_function_1); + it.setToBeFormatted("while(true)\n\tprintln(\"x\")\n"); + }); + } + + @Test + public void formatWhile2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(false)); + }; + it.preferences(_function_1); + it.setToBeFormatted("while (true) {\n\tprintln(\"x\")\n}\n"); + }); + } + + @Test + public void formatWhile21() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); + }; + it.preferences(_function_1); + it.setToBeFormatted("while (true)\n{\n\tprintln(\"x\")\n}\n"); + }); + } + + @Test + public void formatDoWhile11() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(true)); + }; + it.preferences(_function_1); + it.setToBeFormatted("do\n\tprintln(\"x\")\nwhile (true)\n"); + }); + } + + @Test + public void formatDoWhile12() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(false)); + }; + it.preferences(_function_1); + it.setToBeFormatted("do\n\tprintln(\"x\")\nwhile(true)\n"); + }); + } + + @Test + public void formatDoWhile2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(false)); + }; + it.preferences(_function_1); + it.setToBeFormatted("do {\n\tprintln(\"x\")\n} while (true)\n"); + }); + } + + @Test + public void formatDoWhile3() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); + }; + it.preferences(_function_1); + it.setToBeFormatted("do\n{\n\tprintln(\"x\")\n}\nwhile (true)\n"); + }); + } + + @Test + public void formatSwitchSL() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(false)); + }; + it.preferences(_function_1); + it.setToBeFormatted( + "switch \'x\' { case \'x\': println(\'x\') case \'y\': println(\'y\') }\n"); + }); + } + + @Test + public void formatSwitchSL1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); + }; + it.preferences(_function_1); + it.setToBeFormatted( + "switch \'x\' { case \'x\': println(\'x\') case \'y\': println(\'y\') }\n"); + }); + } + + @Test + public void formatSwitchDefaultSL() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(false)); + }; + it.preferences(_function_1); + it.setToBeFormatted("switch \'x\' { case \'y\': println(\'y\') default: println(\'z\') }\n"); + }); + } + + @Test + public void formatSwitchDefaultSL1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); + }; + it.preferences(_function_1); + it.setToBeFormatted("switch \'x\' { case \'y\': println(\'y\') default: println(\'z\') }\n"); + }); + } + + @Test + public void formatSwitchCaseSL1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); + }; + it.preferences(_function_1); + it.setToBeFormatted( + "switch \'x\'\n{\n\tcase \'x\': println(\'x\')\n\tcase \'y\': println(\'y\')\n}\n"); + }); + } + + @Test + public void formatSwitchCaseSLParenthesis() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation( + "switch \'x\' {\n\tcase \'x\': println(\'x\')\n\tcase \'y\': println(\'y\')\n}\n"); + it.setToBeFormatted("switch \'x\' { \n\tcase \'x\': println(\'x\') case \'y\': println(\'y\')\n}\n"); + }); + } + + @Test + public void formatSwitchCaseDefaultSL1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); + }; + it.preferences(_function_1); + it.setToBeFormatted("switch \'x\'\n{\n\tcase \'x\': println(\'x\')\n\tcase \'y\': println(\'y\')\n\tdefault: println(\'z\')\n}\n"); + }); + } + + @Test + public void formatSwitchCaseDefaultSLParenthesis() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("switch \'x\' {\n\tcase \'x\': println(\'x\')\n\tcase \'y\': println(\'y\')\n\tdefault: println(\'z\')\n}\n"); + it.setToBeFormatted("switch \'x\' { \n\tcase \'x\': println(\'x\') case \'y\': println(\'y\') default : println(\'z\')\n}\n"); + }); + } + + @Test + public void formatSwitchML() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation(Strings + .toPlatformLineSeparator("switch \'x\' {\n\tcase \'x\':\n\t\tprintln(\'x\')\n\tcase \'y\':\n\t\tprintln(\'y\')\n}\n")); + it.setToBeFormatted("switch \'x\' { \n\tcase \'x\': \n\t\tprintln(\'x\') case \'y\': println(\'y\')\n}\n"); + }); + } + + @Test + public void formatSwitchDefaultML() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("switch \'x\' {\n\tcase \'x\':\n\t\tprintln(\'x\')\n\tcase \'y\':\n\t\tprintln(\'y\')\n\tdefault:\n\t\tprintln(\'z\')\n}\n"); + it.setToBeFormatted("switch \'x\' { \n\tcase \'x\': \n\t\tprintln(\'x\') case \'y\': println(\'y\') default : println(\'z\')\n}\n"); + }); + } + + @Test + public void formatSwitchDefault2ML() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("switch \'x\' {\n\tcase \'x\':\n\t\tprintln(\'x\')\n\tcase \'y\':\n\t\tprintln(\'y\')\n\tdefault:\n\t\tprintln(\'z\')\n}\n"); + it.setToBeFormatted("switch \'x\' { \n\tcase \'x\': println(\'x\') case \'y\': println(\'y\') \n\tdefault : \n\t\tprintln(\'z\')\n}\n"); + }); + } + + @Test + public void formatSwitchDefault2MLFallThrough() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("switch \'x\' {\n\tcase \'x\',\n\tcase \'y\':\n\t\tprintln(\'y\')\n\tdefault:\n\t\tprintln(\'z\')\n}\n"); + it.setToBeFormatted("switch \'x\' { \n\tcase \'x\' , case \'y\': println(\'y\') \n\tdefault : \n\t\tprintln(\'z\')\n}\n"); + }); + } + + @Test + public void formatSwitchMLBlock() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(false)); + }; + it.preferences(_function_1); + it.setExpectation("switch \'x\' {\n\tcase \'x\': {\n\t\tprintln(\'x\')\n\t}\n\tcase \'y\': {\n\t\tprintln(\'y\')\n\t}\n}\n"); + it.setToBeFormatted(Strings + .toPlatformLineSeparator("switch \'x\' { case \'x\': { println(\'x\') } case \'y\': { println(\'y\') } }\n")); + }); + } + + @Test + public void formatSwitchDefaultMLBlock() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(false)); + }; + it.preferences(_function_1); + it.setExpectation("switch \'x\' {\n\tcase \'x\': {\n\t\tprintln(\'x\')\n\t}\n\tcase \'y\': {\n\t\tprintln(\'y\')\n\t}\n\tdefault: {\n\t\tprintln(\'z\')\n\t}\n}\n"); + it.setToBeFormatted("switch \'x\' { case \'x\': { println(\'x\') } case \'y\': { println(\'y\') } default: { println(\'z\') } }\n"); + }); + } + + @Test + public void formatSwitchMLBlock1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); + }; + it.preferences(_function_1); + it.setExpectation("switch \'x\'\n{\n\tcase \'x\':\n\t{\n\t\tprintln(\'x\')\n\t}\n\tcase \'y\':\n\t{\n\t\tprintln(\'y\')\n\t}\n}\n"); + it.setToBeFormatted(Strings + .toPlatformLineSeparator("switch \'x\' { case \'x\': { println(\'x\') } case \'y\': { println(\'y\') } }\n")); + }); + } + + @Test + public void formatFeatureCallNoParenthesis() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setToBeFormatted("val v1 = newArrayList\nval v2 = newArrayList\n"); + }); + } + + @Test + public void formatFeatureCallNoParams() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setToBeFormatted("val v1 = newArrayList()\nval v2 = newArrayList()\n"); + }); + } + + @Test + public void formatFeatureCall1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val ML2 = newArrayList(newArrayList(1, 2, 3, 4, 5, 6),\n\tnewArrayList(5, 6, 7, 8), newArrayList(9, 10, 11, 12),\n\tnewArrayList(13, 14, 15, 16))\n"); + it.setToBeFormatted("val ML2 = newArrayList(newArrayList(1, 2, 3, 4, 5, 6), newArrayList(5, 6, 7, 8), newArrayList(9, 10, 11, 12), newArrayList(13, 14, 15, 16))\n"); + }); + } + + @Test + public void formatFeatureCall2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val ML2 = newArrayList(newArrayList(1, 2, 3, 4),\n\tnewArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109,\n\t\t110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120),\n\tnewArrayList(9, 10, 11, 12), newArrayList(13, 14, 15, 16))\n"); + it.setToBeFormatted("val ML2 = newArrayList(newArrayList(1, 2, 3, 4), newArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120), newArrayList(9, 10, 11, 12), newArrayList(13, 14, 15, 16))\n"); + }); + } + + @Test + public void formatFeatureCallMultiline() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val ML2 = newArrayList(\n\tnewArrayList(1, 2, 3, 4),\n\tnewArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109,\n\t\t110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120),\n\tnewArrayList(9),\n\tnewArrayList(10)\n)\n"); + it.setToBeFormatted("val ML2 = newArrayList(newArrayList(1, 2, 3, 4), newArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120), newArrayList(9), newArrayList(10)\n)\n"); + }); + } + + @Test + public void formatConstructorCallNoParenthesis() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setToBeFormatted("val v1 = new ArrayList\nval v2 = new ArrayList\n"); + }); + } + + @Test + public void formatConstructorCallClosure() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setToBeFormatted("new Thread[|println(\"foo\")]\n"); + }); + } + + @Test + public void formatConstructorCallNoParams() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setToBeFormatted("val v1 = new ArrayList()\nval v2 = new ArrayList()\n"); + }); + } + + @Test + public void formatConstructorCall1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val ML2 = new ArrayList(new ArrayList(1, 2, 3, 4, 5, 6),\n\tnew ArrayList(5, 6, 7, 8), new ArrayList(9, 10, 11, 12),\n\tnew ArrayList(13, 14, 15, 16))\n"); + it.setToBeFormatted("val ML2 = new ArrayList(new ArrayList(1, 2, 3, 4, 5, 6), new ArrayList(5, 6, 7, 8), new ArrayList(9, 10, 11, 12), new ArrayList(13, 14, 15, 16))\n"); + }); + } + + @Test + public void formatConstructorCall2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val ML2 = new ArrayList(new ArrayList(1, 2, 3, 4),\n\tnew ArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109,\n\t\t110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120),\n\tnew ArrayList(9, 10, 11, 12), new ArrayList(13, 14, 15, 16))\n"); + it.setToBeFormatted("val ML2 = new ArrayList(new ArrayList(1, 2, 3, 4), new ArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120), new ArrayList(9, 10, 11, 12), new ArrayList(13, 14, 15, 16))\n"); + }); + } + + @Test + public void formatConstructorCallMultiline() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val ML2 = new ArrayList(\n\tnew ArrayList(1, 2, 3, 4),\n\tnew ArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109,\n\t\t110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120),\n\tnew ArrayList(9, 10, 11, 12),\n\tnew ArrayList(13, 14, 15, 16)\n)\n"); + it.setToBeFormatted("val ML2 = new ArrayList(new ArrayList(1, 2, 3, 4), new ArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120), new ArrayList(9, 10, 11, 12), new ArrayList(13, 14, 15, 16)\n)\n"); + }); + } + + @Test + public void formatMemberFeatureCallNoParenthesis() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setToBeFormatted("val v1 = \"x\".toString\nval v2 = \"x\".toString\n"); + }); + } + + @Test + public void formatMemberFeatureCallNoParams() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setToBeFormatted("val v1 = \"x\".toString()\nval v2 = \"x\".toString()\n"); + }); + } + + @Test + public void formatMemberFeatureCall1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val ML1 = \"x\".substring(0).substring(1).substring(2).substring(3).\n\tsubstring(4).substring(5).substring(6).substring(7).substring(8).\n\tsubstring(9).substring(10).substring(11)\n"); + it.setToBeFormatted("val ML1 = \"x\".substring(0).substring(1).substring(2).substring(3).substring(4).substring(5).substring(6).substring(7).substring(8).substring(9).substring(10).substring(11)\n"); + }); + } + + @Test + public void formatMemberFeatureCall2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val ML1 = \"x\".substring(0).substring(1)\n"); + it.setToBeFormatted("val ML1 = \"x\"\n.\nsubstring(0)\n.\nsubstring(1)\n"); + }); + } + + @Test + public void formatMemberFeatureCall21() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val ML1 = \"x\".toString.toString\n"); + it.setToBeFormatted("val ML1 = \"x\"\n.\ntoString\n.\ntoString\n"); + }); + } + + @Test + public void formatMemberFeatureCall3() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val ML1 = \"x\".substring(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,\n\t15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28)\n"); + it.setToBeFormatted("val ML1 = \"x\".substring(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28)\n"); + }); + } + + @Test + public void formatMemberFeatureCall4() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val ML1 = \"x\".substring(0, 1, 2)\n"); + it.setToBeFormatted("val ML1 = \"x\".substring (\n\n0, \n\n1, \n\n2)\n"); + }); + } + + @Test + public void formatMemberFeatureCallMultiline() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val ML1 = \"x\".substring(\n\t0,\n\t1,\n\t2\n)\n"); + it.setToBeFormatted("val ML1 = \"x\".substring (\n\n0, \n\n1, \n\n2\n)\n"); + }); + } + + @Test + public void formatMemberFeatureCallBuilder1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("newArrayList(\"x\").map()[]\n"); + it.setToBeFormatted("newArrayList(\"x\") . map ( ) [ ]\n"); + }); + } + + @Test + public void formatMemberFeatureCallBuilder2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("newArrayList(\"x\").map()[lenght]\n"); + it.setToBeFormatted("newArrayList(\"x\") . map ( ) [ lenght ]\n"); + }); + } + + @Test + public void formatMemberFeatureCallBuilderMultiline1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("newArrayList(\"x\").map(\n\tlength\n)[lenght]\n"); + it.setToBeFormatted("newArrayList(\"x\") . map ( length \n) [ lenght ]\n"); + }); + } + + @Test + public void formatMemberFeatureCallBuilderMultiline2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("newArrayList(\"x\").map(length) [\n\tlength\n]\n"); + it.setToBeFormatted("newArrayList(\"x\") . map ( length ) [ length \n]\n"); + }); + } + + /** + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=461033 + */ + @Test + public void formatMemberFeatureCallParenthesized() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val s = (\"a\" + \"b\").substring(1)\n"); + it.setToBeFormatted("val s = (\"a\" + \"b\") . substring(1)\n"); + }); + } + + @Test + public void formatBinaryExpression1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val ML1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 +\n\t16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 +\n\t30 + 31 + 32 + 33 + 34 + 35 + 36\n"); + it.setToBeFormatted("val ML1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 \n"); + }); + } + + @Test + public void formatBinaryExpression2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val ML1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 +\n\t11 * 12 * 13 * 14 * 15 * 16 * 17 * 18 + 19 + 20 + 21 + 22 + 23 + 24 +\n\t25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36\n"); + it.setToBeFormatted("val ML1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 * 12 * 13 * 14 * 15 * 16 * 17 * 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 \n"); + }); + } + + @Test + public void formatXTypeLiteral() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("typeof(String)\n"); + it.setToBeFormatted("typeof ( String )\n"); + }); + } + + @Test + public void formatXTypeLiteralArray1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("typeof(String[])\n"); + it.setToBeFormatted("typeof ( String [ ])\n"); + }); + } + + @Test + public void formatXTypeLiteralArray2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("typeof(String[][])\n"); + it.setToBeFormatted("typeof ( String [ ] [ ] )\n"); + }); + } + + @Test + public void formatXThrowExpression() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("throw new RuntimeException()\n"); + it.setToBeFormatted("throw new RuntimeException()\n"); + }); + } + + @Test + public void formatXReturnExpression1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("return \"foo\"\n"); + it.setToBeFormatted("return \"foo\"\n"); + }); + } + + @Test + public void formatXReturnExpression2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("\"foo\"\nreturn\n"); + it.setToBeFormatted("\"foo\" return\n"); + }); + } + + @Test + public void formatXReturnExpression3() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("return;\n"); + it.setToBeFormatted("return ;\n"); + }); + } + + @Test + public void formatTryFinallyExpression1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("try\n\tprintln(\"x\")\nfinally\n\tprintln(\"y\")\n"); + it.setToBeFormatted("try println(\"x\") finally println(\"y\")\n"); + }); + } + + @Test + public void formatTryFinallyExpression2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("try {\n\tprintln(\"x\")\n} finally {\n\tprintln(\"y\")\n}\n"); + it.setToBeFormatted("try { println(\"x\") } finally { println(\"y\") }\n"); + }); + } + + @Test + public void formatTryCatchExpression11() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(true)); + }; + it.preferences(_function_1); + it.setToBeFormatted("try\n\tprintln(\"x\")\ncatch (Exception e)\n\tprintln(\"y\")\n"); + }); + } + + @Test + public void formatTryCatchExpression12() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(false)); + }; + it.preferences(_function_1); + it.setToBeFormatted("try\n\tprintln(\"x\")\ncatch(Exception e)\n\tprintln(\"y\")\n"); + }); + } + + @Test + public void formatTryCatchExpression2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("try {\n\tprintln(\"x\")\n} catch (Exception e) {\n\tprintln(\"y\")\n}\n"); + it.setToBeFormatted( + "try { println(\"x\") } catch ( Exception e ) { println(\"y\") }\n"); + }); + } + + @Test + public void formatTryCatchFinallyExpression1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation(Strings + .toPlatformLineSeparator("try\n\tprintln(\"x\")\ncatch (Exception e)\n\tprintln(\"y\")\nfinally\n\tprintln(\"z\")\n")); + it.setToBeFormatted("try println(\"x\") catch ( Exception e ) println(\"y\") finally println(\"z\")\n"); + }); + } + + @Test + public void formatTryCatchFinallyExpressionBug474022() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(false)); + }; + it.preferences(_function_1); + it.setExpectation("val i = try {\n\t\tprintln(\"x\")\n\t\t1\n\t} catch (Exception e) {\n\t\tprintln(\"y\")\n\t\t2\n\t} finally {\n\t\tprintln(\"z\")\n\t}\n"); + it.setToBeFormatted("val i = try { println(\"x\") 1 } catch ( Exception e ) { println(\"y\") 2 } finally { println(\"z\") }\n"); + }); + } + + @Test + public void formatTryCatchFinallyExpression2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(false)); + }; + it.preferences(_function_1); + it.setExpectation("try {\n\tprintln(\"x\")\n} catch (Exception e) {\n\tprintln(\"y\")\n} finally {\n\tprintln(\"z\")\n}\n"); + it.setToBeFormatted("try { println(\"x\") } catch ( Exception e ) { println(\"y\") } finally { println(\"z\") }\n"); + }); + } + + @Test + public void formatTryCatchFinallyExpression3() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { + it_1. put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); + }; + it.preferences(_function_1); + it.setExpectation("try\n{\n\tprintln(\"x\")\n}\ncatch (Exception e)\n{\n\tprintln(\"y\")\n}\nfinally\n{\n\tprintln(\"z\")\n}\n"); + it.setToBeFormatted("try { println(\"x\") } catch ( Exception e ) { println(\"y\") } finally { println(\"z\") }\n"); + }); + } + + @Test + public void formatTryCatchCatchFinallyExpression1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("try\n\tprintln(\"x\")\ncatch (Exception e)\n\tprintln(\"y\")\ncatch (Exception f)\n\tprintln(\"z\")\nfinally\n\tprintln(\"a\")\n"); + it.setToBeFormatted("try println(\"x\") catch ( Exception e ) println(\"y\") catch ( Exception f ) println(\"z\") finally println(\"a\")\n"); + }); + } + + @Test + public void formatTryCatchCatchFinallyExpression2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("try {\n\tprintln(\"x\")\n} catch (Exception e) {\n\tprintln(\"y\")\n} catch (Exception f) {\n\tprintln(\"z\")\n} finally {\n\tprintln(\"a\")\n}\n"); + it.setToBeFormatted("try { println(\"x\") } catch ( Exception e ) { println(\"y\") } catch ( Exception f ) { println(\"z\") } finally { println(\"a\") }\n"); + }); + } + + @Test + public void formatListLiteral1() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("#[12, 13, 14]\n"); + it.setToBeFormatted("#[12, 13 ,\t14\t\t]\n"); + }); + } + + @Test + public void formatListLiteral3() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("#[\n\t12,\n\t13,\n\t14\n]\n"); + it.setToBeFormatted("#[12, 13 ,\t14\t\t\n]\n"); + }); + } + + @Test + public void formatEmptySwitchSL() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("switch null { }\n"); + it.setToBeFormatted("switch null { }\n"); + }); + } + + @Test + public void formatEmptySwitchSL_2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("switch null { default: 1 }\n"); + it.setToBeFormatted("switch null { default : 1 }\n"); + }); + } + + @Test + public void formatEmptySwitchML() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("switch null {\n}\n"); + it.setToBeFormatted("switch null { \n\t\n\t\n\t\n}\n"); + }); + } + + @Test + public void formatEmptySwitchML_2() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("switch null {\n\tdefault: 1\n}\n"); + it.setToBeFormatted("switch null { \n\t\n\t\n\t\n\tdefault : 1\n\t\n}\n"); + }); + } + + @Test + public void formatInstanceOf() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("\"x\".toString instanceof String\n"); + it.setToBeFormatted("\"x\".toString instanceof String\n"); + }); + } + + @Test + public void formatCast() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("\"x\" as String\n"); + it.setToBeFormatted("\"x\" as String\n"); + }); + } + + @Test + public void formatPostfix() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val i = j++\n"); + it.setToBeFormatted("val i = j ++\n"); + }); + } + + @Test + public void testFeatureCallWithParentheses() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val it = \"xxxx\"\nval j = true && (startsWith(\"x\"))\n"); + it.setToBeFormatted("val it = \"xxxx\"\nval j = true&&(startsWith(\"x\"))\n"); + }); + } + + @Test + public void testMemberFeatureCallWithParentheses() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("val j = true && (class.startsWith(\"Hugo\"))\n"); + it.setToBeFormatted("val j = true&&(class.startsWith(\"Hugo\"))\n"); + }); + } + + @Test + public void testIssue527() { + xbaseFormatterTester.assertFormattedExpression((Procedure1) (FormatterTestRequest it) -> { + it.setExpectation("var veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryname = #[\n\t1, 2, 3, 4, 5]\nveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryname.\n\tmap [ l |\n\t\tveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryname\n\t]\n"); + it.setToBeFormatted("var veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryname = #[1,2,3,4,5]\nveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryname.map[l|veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryname]\n\n"); + }); + + } +} diff --git a/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/formatting/XbaseFormatterTest.xtend b/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/formatting/XbaseFormatterTest.xtend deleted file mode 100644 index 256ea5f6a5..0000000000 --- a/org.eclipse.xtext.xbase.tests/src/org/eclipse/xtext/xbase/tests/formatting/XbaseFormatterTest.xtend +++ /dev/null @@ -1,1763 +0,0 @@ -package org.eclipse.xtext.xbase.tests.formatting - -import com.google.inject.Inject -import org.eclipse.xtext.testing.InjectWith -import org.eclipse.xtext.testing.XtextRunner -import org.junit.Test -import org.junit.runner.RunWith - -import static org.eclipse.xtext.xbase.formatting2.XbaseFormatterPreferenceKeys.* - -@RunWith(typeof(XtextRunner)) -@InjectWith(typeof(XbaseFormatterTestInjectorProvider)) -class XbaseFormatterTest { - - @Inject extension XbaseFormatterTester - - @Test def formatGenerics() { - assertFormattedExpression [ - toBeFormatted = ''' - val x = >newArrayList() - ''' - ] - } - - @Test def formatBlockExpression() { - assertFormattedExpression [ - expectation = ''' - val x = newArrayList("A", "b"); - val y = 'foo'; - x.join - ''' - toBeFormatted = ''' - val x = newArrayList("A", "b") ; val y = 'foo' ; x.join - ''' - ] - } - - @Test def formatBlockExpressionPreserveNewLines() { - assertFormatted[ - expectation = ''' - { - - val x = newArrayList("A", "b"); - - val y = 'foo' - - x.join - - } - '''.toString.trim - toBeFormatted = ''' - { - - - val x = newArrayList("A", "b") ; - - - val y = 'foo' - - - x.join - - - } - ''' - ] - } - - @Test def formatClosures() { - assertFormattedExpression [ - toBeFormatted = ''' - val x = newArrayList("A", "b") - val y = x.filter[toUpperCase == it] - y.join - ''' - ] - } - - @Test def formatClosuresParenthesis() { - assertFormattedExpression [ - toBeFormatted = ''' - val x = newArrayList("A", "b") - val y = x.filter(toUpperCase == it) - y.join - ''' - ] - } - - @Test def formatClosuresParenthesis2() { - assertFormattedExpression [ - toBeFormatted = ''' - val x = newArrayList("A", "b") - val y = x.filter(foo|foo.toUpperCase == foo) - y.join - ''' - ] - } - - @Test def formatClosuresSemicolon() { - assertFormattedExpression [ - expectation = ''' - newArrayList("A", "b").filter[val b = it; b.toUpperCase == b] - ''' - toBeFormatted = ''' - newArrayList("A", "b").filter[ val b = it ; b.toUpperCase == b ] - ''' - ] - } - - @Test def formatClosuresEmpty() { - assertFormattedExpression [ - expectation = ''' - val x = newArrayList("A", "b") - val y = x.filter[] - y.join - ''' - toBeFormatted = ''' - val x = newArrayList("A", "b") val y = x.filter[ ] y.join - ''' - ] - } - - @Test def formatClosuresParam() { - assertFormattedExpression [ - toBeFormatted = ''' - val x = newArrayList("A", "b") - val y = x.filter[z|z.toUpperCase == z] - y.join - ''' - ] - } - - @Test def formatClosuresEmptyParam() { - assertFormattedExpression [ - toBeFormatted = ''' - val Iterable x = [|#[].iterator] - ''' - ] - } - - @Test def formatClosuresMultiLine() { - assertFormattedExpression [ - expectation = ''' - val x = newArrayList("A", "b") - val y = x.filter [ - val z = it - z.toUpperCase == z - ] - y.join - ''' - toBeFormatted = ''' - val x = newArrayList("A", "b") val y = x.filter [ - val z = it z.toUpperCase == z - ] y.join - ''' - ] - } - - @Test def formatClosuresMultiLine_02() { - assertFormattedExpression [ - expectation = ''' - val x = newArrayList("A", "b") - val y = x.filter [ - val z = it - z.toUpperCase == z - ] - y.join - ''' - toBeFormatted = ''' - val x = newArrayList("A", "b") val y = x.filter[ - val z = it z.toUpperCase == z - ] y.join - ''' - ] - } - - @Test def formatClosuresMultiLine03() { - assertFormattedExpression [ - expectation = ''' - new Thread [| - println("foo") - ] - ''' - toBeFormatted = ''' - new Thread[ | println("foo") - ] - ''' - ] - } - - @Test def formatClosuresMultiLineSemicolon() { - assertFormattedExpression [ - expectation = ''' - val x = newArrayList("A", "b") - val y = x.filter [ - val z = it; - z.toUpperCase == z; - ] - y.join - ''' - toBeFormatted = ''' - val x = newArrayList("A", "b") val y = x.filter [ - val z = it ; z.toUpperCase == z ; - ] y.join - ''' - ] - - } - - @Test def formatClosuresWrapIfNeeded() { - assertFormattedExpression [ - expectation = ''' - val x = newArrayList("A", "b") - val y = x.filter [ - val z = it - z.toUpperCase == z - z.toUpperCase == z - z.toUpperCase == z - ] - y.join - ''' - toBeFormatted = ''' - val x = newArrayList("A", "b") val y = x.filter [ val z = it z.toUpperCase == z z.toUpperCase == z z.toUpperCase == z ] y.join - ''' - ] - } - - @Test def formatClosuresParamMultiLine() { - assertFormattedExpression [ - expectation = ''' - val x = newArrayList("A", "b") - val y = x.filter [ z | - val w = z - w.toUpperCase == w - ] - y.join - ''' - toBeFormatted = ''' - val x = newArrayList("A", "b") val y = x.filter[ z | - val w = z w.toUpperCase == w - ] y.join - ''' - ] - } - - @Test def formatClosuresWithOperator() { - assertFormattedExpression [ - expectation = ''' - val x = new StringBuffer() => [ - append("x") - append("y") - ] - ''' - toBeFormatted = ''' - val x = new StringBuffer() => [ - append("x") - append("y") - ] - ''' - ] - } - - @Test def formatMultiLineClosureWithAssignment() { - assertFormattedExpression [ - expectation = ''' - x += foo.myBuilder [ - foo - bar - ] - ''' - toBeFormatted = ''' - x += foo.myBuilder [ - foo bar - ] - ''' - ] - } - - @Test def formatSynchronizedBlock_1() { - assertFormattedExpression [ - expectation = ''' - synchronized (new Object) { - } - ''' - toBeFormatted = ''' - synchronized(new Object){} - ''' - ] - } - - @Test def formatSynchronizedBlock_2() { - assertFormattedExpression [ - expectation = ''' - synchronized (new Object) { - } - ''' - toBeFormatted = ''' - synchronized ( new Object ) { } - ''' - ] - } - - @Test def formatIf1SL1() { - assertFormattedExpression [ - preferences[ - put(whitespaceBetweenKeywordAndParenthesisSL, true) - ] - toBeFormatted = ''' - if (true) println("foo") - ''' - ] - } - - @Test def formatIf1SL2() { - assertFormattedExpression [ - preferences[ - put(whitespaceBetweenKeywordAndParenthesisSL, false) - ] - toBeFormatted = ''' - if(true) println("foo") - ''' - ] - } - - @Test def formatIf1ML1() { - assertFormattedExpression [ - preferences[ - put(whitespaceBetweenKeywordAndParenthesisML, true) - ] - toBeFormatted = ''' - if (true) - println("foo") - ''' - ] - } - - @Test def formatIf1ML2() { - assertFormattedExpression [ - preferences[ - put(whitespaceBetweenKeywordAndParenthesisML, false) - ] - toBeFormatted = ''' - if(true) - println("foo") - ''' - ] - } - - @Test def formatIf1MLVar() { - assertFormattedExpression [ - expectation = ''' - var x = if (true) - println("foo") - else - println("bar") - ''' - toBeFormatted = ''' - var x = if(true) - println("foo") else println("bar") - ''' - ] - } - - @Test def formatIf1MLSemicolon1() { - assertFormattedExpression [ - expectation = ''' - if (true) - println("foo"); - ''' - toBeFormatted = ''' - if(true) - println("foo"); - ''' - ] - } - - @Test def formatIf1MLSemicolon2() { - assertFormattedExpression [ - expectation = ''' - if (true) - println("foo"); - println("bar") - ''' - toBeFormatted = ''' - if(true) - println("foo"); - println("bar") - ''' - ] - } - - @Test def formatIf2() { - assertFormattedExpression [ - toBeFormatted = ''' - if (true) { - println("foo") - } - ''' - ] - } - - @Test def formatIfElse1SL() { - assertFormattedExpression [ - expectation = ''' - if(true) println("foo") else println("bar") - ''' - toBeFormatted = ''' - if(true)println("foo")else println("bar") - ''' - ] - } - - @Test def formatIfElse1ML() { - assertFormattedExpression [ - expectation = ''' - if (true) - println("foo") - else - println("bar") - ''' - toBeFormatted = ''' - if(true) - println("foo") - else - println("bar") - ''' - ] - } - - @Test def formatIfElse2() { - assertFormattedExpression [ - toBeFormatted = ''' - if (true) { - println("foo") - } else { - println("bar") - } - ''' - ] - } - - @Test def formatIfElse3() { - assertFormattedExpression [ - preferences[ - put(bracesInNewLine, true) - ] - toBeFormatted = ''' - if (true) - { - println("foo") - } - else - { - println("bar") - } - ''' - ] - } - - @Test def formatIfElseIf1() { - assertFormattedExpression [ - expectation = ''' - if (true) - println("foo") - else if (false) - println("bar") - ''' - toBeFormatted = ''' - if(true) - println("foo") - else if(false) - println("bar") - ''' - ] - } - - @Test def formatIfElseIf2() { - assertFormattedExpression [ - expectation = ''' - if (true) { - println("foo") - } else if (false) { - println("bar") - } - ''' - toBeFormatted = ''' - if(true) { - println("foo") - } else if(false) { - println("bar") - } - ''' - ] - } - - @Test def formatIfElseIf3() { - assertFormattedExpression [ - expectation = ''' - if (true) { - println("foo") - } else if (false) - println("bar") - ''' - toBeFormatted = ''' - if(true) { - println("foo") - } else if(false) - println("bar") - ''' - ] - } - - @Test def formatFor1() { - assertFormattedExpression [ - expectation = ''' - for (i : 1 .. 2) - println(i) - ''' - toBeFormatted = ''' - for ( i : 1 .. 2 ) println(i) - ''' - ] - } - - @Test def formatFor2() { - assertFormattedExpression [ - preferences[ - put(bracesInNewLine, false) - ] - toBeFormatted = ''' - for (i : 1 .. 2) { - println(i) - } - ''' - ] - } - - @Test def formatFor3() { - assertFormattedExpression [ - preferences[ - put(bracesInNewLine, true) - ] - toBeFormatted = ''' - for (i : 1 .. 2) - { - println(i) - } - ''' - ] - } - - @Test def formatBasicFor() { - assertFormattedExpression [ - expectation = ''' - for (var i = 1; i < 10; i = i + 1) - println(i) - ''' - toBeFormatted = ''' - for ( var i = 1 ; i < 10; i = i + 1 ) println(i) - ''' - ] - } - - @Test def formatBasicFor2() { - assertFormattedExpression [ - expectation = ''' - for (;;) { - return true - } - ''' - toBeFormatted = ''' - for ( ; ; ) { return true } - ''' - ] - } - - @Test def formatBasicFor3() { - assertFormattedExpression [ - expectation = ''' - var int x - var int y - for (x = 1, y = 2;;) { - return x + y - } - ''' - toBeFormatted = ''' - var int x - var int y - for ( x = 1 , y = 2 ; ; ) { return x + y } - ''' - ] - } - - @Test def formatBasicFor4() { - assertFormattedExpression [ - expectation = ''' - val x = 1 - for (; x < 10;) - println(x) - ''' - toBeFormatted = ''' - val x = 1 - for ( ; x < 10 ; ) println(x) - ''' - ] - } - - @Test def formatBasicFor5() { - assertFormattedExpression [ - expectation = ''' - val x = 1 - for (;; x = x + 1, x = x + 2) - println(x) - ''' - toBeFormatted = ''' - val x = 1 - for ( ; ; x = x + 1 , x = x + 2 ) println(x) - ''' - ] - } - - @Test def formatBasicFor6() { - assertFormattedExpression [ - expectation = ''' - for (val x = 1;; x = x + 1, x = x + 2) - println(x) - ''' - toBeFormatted = ''' - for ( val x = 1 ; ; x = x + 1 , x = x + 2 ) println(x) - ''' - ] - } - - @Test def formatWhile11() { - assertFormattedExpression [ - preferences[ - put(whitespaceBetweenKeywordAndParenthesisML, true) - ] - toBeFormatted = ''' - while (true) - println("x") - ''' - ] - } - - @Test def formatWhile12() { - assertFormattedExpression [ - preferences[ - put(whitespaceBetweenKeywordAndParenthesisML, false) - ] - toBeFormatted = ''' - while(true) - println("x") - ''' - ] - } - - @Test def formatWhile2() { - assertFormattedExpression [ - preferences [ - put(bracesInNewLine, false) - ] - toBeFormatted = ''' - while (true) { - println("x") - } - ''' - ] - } - - @Test def formatWhile21() { - assertFormattedExpression [ - preferences[ - put(bracesInNewLine, true) - ] - toBeFormatted = ''' - while (true) - { - println("x") - } - ''' - ] - } - - @Test def formatDoWhile11() { - assertFormattedExpression [ - preferences[ - put(whitespaceBetweenKeywordAndParenthesisML, true) - ] - toBeFormatted = ''' - do - println("x") - while (true) - ''' - ] - } - - @Test def formatDoWhile12() { - assertFormattedExpression [ - preferences[ - put(whitespaceBetweenKeywordAndParenthesisML, false) - ] - toBeFormatted = ''' - do - println("x") - while(true) - ''' - ] - } - - @Test def formatDoWhile2() { - assertFormattedExpression [ - preferences[ - put(bracesInNewLine, false) - ] - toBeFormatted = ''' - do { - println("x") - } while (true) - ''' - ] - } - - @Test def formatDoWhile3() { - assertFormattedExpression [ - preferences [ - put(bracesInNewLine, true) - ] - toBeFormatted = ''' - do - { - println("x") - } - while (true) - ''' - ] - } - - @Test def formatSwitchSL() { - assertFormattedExpression [ - preferences [ - put(bracesInNewLine, false) - ] - toBeFormatted = ''' - switch 'x' { case 'x': println('x') case 'y': println('y') } - ''' - ] - } - - @Test def formatSwitchSL1() { - assertFormattedExpression [ - preferences [ - put(bracesInNewLine, true) - ] - toBeFormatted = ''' - switch 'x' { case 'x': println('x') case 'y': println('y') } - ''' - ] - } - - @Test def formatSwitchDefaultSL() { - assertFormattedExpression [ - preferences [ - put(bracesInNewLine, false) - ] - toBeFormatted = ''' - switch 'x' { case 'y': println('y') default: println('z') } - ''' - ] - } - - @Test def formatSwitchDefaultSL1() { - assertFormattedExpression [ - preferences [ - put(bracesInNewLine, true) - ] - toBeFormatted = ''' - switch 'x' { case 'y': println('y') default: println('z') } - ''' - ] - } - - @Test def formatSwitchCaseSL1() { - assertFormattedExpression [ - preferences [ - put(bracesInNewLine, true) - ] - toBeFormatted = ''' - switch 'x' - { - case 'x': println('x') - case 'y': println('y') - } - ''' - ] - } - - @Test def formatSwitchCaseSLParenthesis() { - assertFormattedExpression [ - expectation = ''' - switch 'x' { - case 'x': println('x') - case 'y': println('y') - } - ''' - toBeFormatted = ''' - switch 'x' { - case 'x': println('x') case 'y': println('y') - } - ''' - ] - } - - @Test def formatSwitchCaseDefaultSL1() { - assertFormattedExpression [ - preferences [ - put(bracesInNewLine, true) - ] - toBeFormatted = ''' - switch 'x' - { - case 'x': println('x') - case 'y': println('y') - default: println('z') - } - ''' - ] - } - - @Test def formatSwitchCaseDefaultSLParenthesis() { - assertFormattedExpression [ - expectation = ''' - switch 'x' { - case 'x': println('x') - case 'y': println('y') - default: println('z') - } - ''' - toBeFormatted = ''' - switch 'x' { - case 'x': println('x') case 'y': println('y') default : println('z') - } - ''' - ] - } - - @Test def formatSwitchML() { - assertFormattedExpression [ - expectation = ''' - switch 'x' { - case 'x': - println('x') - case 'y': - println('y') - } - ''' - toBeFormatted = ''' - switch 'x' { - case 'x': - println('x') case 'y': println('y') - } - ''' - ] - } - - @Test def formatSwitchDefaultML() { - assertFormattedExpression [ - expectation = ''' - switch 'x' { - case 'x': - println('x') - case 'y': - println('y') - default: - println('z') - } - ''' - toBeFormatted = ''' - switch 'x' { - case 'x': - println('x') case 'y': println('y') default : println('z') - } - ''' - ] - } - - @Test def formatSwitchDefault2ML() { - assertFormattedExpression [ - expectation = ''' - switch 'x' { - case 'x': - println('x') - case 'y': - println('y') - default: - println('z') - } - ''' - toBeFormatted = ''' - switch 'x' { - case 'x': println('x') case 'y': println('y') - default : - println('z') - } - ''' - ] - } - - @Test def formatSwitchDefault2MLFallThrough() { - assertFormattedExpression [ - expectation = ''' - switch 'x' { - case 'x', - case 'y': - println('y') - default: - println('z') - } - ''' - toBeFormatted = ''' - switch 'x' { - case 'x' , case 'y': println('y') - default : - println('z') - } - ''' - ] - } - - @Test def formatSwitchMLBlock() { - assertFormattedExpression [ - preferences [ - it.put(bracesInNewLine, false) - ] - expectation = ''' - switch 'x' { - case 'x': { - println('x') - } - case 'y': { - println('y') - } - } - ''' - toBeFormatted = ''' - switch 'x' { case 'x': { println('x') } case 'y': { println('y') } } - ''' - ] - } - - @Test def formatSwitchDefaultMLBlock() { - assertFormattedExpression [ - preferences [ - put(bracesInNewLine, false) - ] - expectation = ''' - switch 'x' { - case 'x': { - println('x') - } - case 'y': { - println('y') - } - default: { - println('z') - } - } - ''' - toBeFormatted = ''' - switch 'x' { case 'x': { println('x') } case 'y': { println('y') } default: { println('z') } } - ''' - ] - } - - @Test def formatSwitchMLBlock1() { - assertFormattedExpression [ - preferences [ - put(bracesInNewLine, true) - ] - expectation = ''' - switch 'x' - { - case 'x': - { - println('x') - } - case 'y': - { - println('y') - } - } - ''' - toBeFormatted = ''' - switch 'x' { case 'x': { println('x') } case 'y': { println('y') } } - ''' - ] - } - - @Test def formatFeatureCallNoParenthesis() { - assertFormattedExpression [ - toBeFormatted = ''' - val v1 = newArrayList - val v2 = newArrayList - ''' - ] - } - - @Test def formatFeatureCallNoParams() { - assertFormattedExpression [ - toBeFormatted = ''' - val v1 = newArrayList() - val v2 = newArrayList() - ''' - ] - } - - @Test def formatFeatureCall1() { - assertFormattedExpression [ - expectation = ''' - val ML2 = newArrayList(newArrayList(1, 2, 3, 4, 5, 6), - newArrayList(5, 6, 7, 8), newArrayList(9, 10, 11, 12), - newArrayList(13, 14, 15, 16)) - ''' - toBeFormatted = ''' - val ML2 = newArrayList(newArrayList(1, 2, 3, 4, 5, 6), newArrayList(5, 6, 7, 8), newArrayList(9, 10, 11, 12), newArrayList(13, 14, 15, 16)) - ''' - ] - } - - @Test def formatFeatureCall2() { - assertFormattedExpression [ - expectation = ''' - val ML2 = newArrayList(newArrayList(1, 2, 3, 4), - newArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120), - newArrayList(9, 10, 11, 12), newArrayList(13, 14, 15, 16)) - ''' - toBeFormatted = ''' - val ML2 = newArrayList(newArrayList(1, 2, 3, 4), newArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120), newArrayList(9, 10, 11, 12), newArrayList(13, 14, 15, 16)) - ''' - ] - } - - @Test def formatFeatureCallMultiline() { - assertFormattedExpression [ - expectation = ''' - val ML2 = newArrayList( - newArrayList(1, 2, 3, 4), - newArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120), - newArrayList(9), - newArrayList(10) - ) - ''' - toBeFormatted = ''' - val ML2 = newArrayList(newArrayList(1, 2, 3, 4), newArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120), newArrayList(9), newArrayList(10) - ) - ''' - ] - } - - @Test def formatConstructorCallNoParenthesis() { - assertFormattedExpression [ - toBeFormatted = ''' - val v1 = new ArrayList - val v2 = new ArrayList - ''' - ] - } - - @Test def formatConstructorCallClosure() { - assertFormattedExpression [ - toBeFormatted = ''' - new Thread[|println("foo")] - ''' - ] - } - - @Test def formatConstructorCallNoParams() { - assertFormattedExpression [ - toBeFormatted = ''' - val v1 = new ArrayList() - val v2 = new ArrayList() - ''' - ] - } - - @Test def formatConstructorCall1() { - assertFormattedExpression [ - expectation = ''' - val ML2 = new ArrayList(new ArrayList(1, 2, 3, 4, 5, 6), - new ArrayList(5, 6, 7, 8), new ArrayList(9, 10, 11, 12), - new ArrayList(13, 14, 15, 16)) - ''' - toBeFormatted = ''' - val ML2 = new ArrayList(new ArrayList(1, 2, 3, 4, 5, 6), new ArrayList(5, 6, 7, 8), new ArrayList(9, 10, 11, 12), new ArrayList(13, 14, 15, 16)) - ''' - ] - } - - @Test def formatConstructorCall2() { - assertFormattedExpression [ - expectation = ''' - val ML2 = new ArrayList(new ArrayList(1, 2, 3, 4), - new ArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120), - new ArrayList(9, 10, 11, 12), new ArrayList(13, 14, 15, 16)) - ''' - toBeFormatted = ''' - val ML2 = new ArrayList(new ArrayList(1, 2, 3, 4), new ArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120), new ArrayList(9, 10, 11, 12), new ArrayList(13, 14, 15, 16)) - ''' - ] - } - - @Test def formatConstructorCallMultiline() { - assertFormattedExpression [ - expectation = ''' - val ML2 = new ArrayList( - new ArrayList(1, 2, 3, 4), - new ArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109, - 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120), - new ArrayList(9, 10, 11, 12), - new ArrayList(13, 14, 15, 16) - ) - ''' - toBeFormatted = ''' - val ML2 = new ArrayList(new ArrayList(1, 2, 3, 4), new ArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120), new ArrayList(9, 10, 11, 12), new ArrayList(13, 14, 15, 16) - ) - ''' - ] - } - - @Test def formatMemberFeatureCallNoParenthesis() { - assertFormattedExpression [ - toBeFormatted = ''' - val v1 = "x".toString - val v2 = "x".toString - ''' - ] - } - - @Test def formatMemberFeatureCallNoParams() { - assertFormattedExpression [ - toBeFormatted = ''' - val v1 = "x".toString() - val v2 = "x".toString() - ''' - ] - } - - @Test def formatMemberFeatureCall1() { - assertFormattedExpression [ - expectation = ''' - val ML1 = "x".substring(0).substring(1).substring(2).substring(3). - substring(4).substring(5).substring(6).substring(7).substring(8). - substring(9).substring(10).substring(11) - ''' - toBeFormatted = ''' - val ML1 = "x".substring(0).substring(1).substring(2).substring(3).substring(4).substring(5).substring(6).substring(7).substring(8).substring(9).substring(10).substring(11) - ''' - ] - } - - @Test def formatMemberFeatureCall2() { - assertFormattedExpression [ - expectation = ''' - val ML1 = "x".substring(0).substring(1) - ''' - toBeFormatted = ''' - val ML1 = "x" - . - substring(0) - . - substring(1) - ''' - ] - } - - @Test def formatMemberFeatureCall21() { - assertFormattedExpression [ - expectation = ''' - val ML1 = "x".toString.toString - ''' - toBeFormatted = ''' - val ML1 = "x" - . - toString - . - toString - ''' - ] - } - - @Test def formatMemberFeatureCall3() { - assertFormattedExpression [ - expectation = ''' - val ML1 = "x".substring(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28) - ''' - toBeFormatted = ''' - val ML1 = "x".substring(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28) - ''' - ] - } - - @Test def formatMemberFeatureCall4() { - assertFormattedExpression [ - expectation = ''' - val ML1 = "x".substring(0, 1, 2) - ''' - toBeFormatted = ''' - val ML1 = "x".substring ( - - 0, - - 1, - - 2) - ''' - ] - } - - @Test def formatMemberFeatureCallMultiline() { - assertFormattedExpression [ - expectation = ''' - val ML1 = "x".substring( - 0, - 1, - 2 - ) - ''' - toBeFormatted = ''' - val ML1 = "x".substring ( - - 0, - - 1, - - 2 - ) - ''' - ] - } - - @Test def formatMemberFeatureCallBuilder1() { - assertFormattedExpression [ - expectation = ''' - newArrayList("x").map()[] - ''' - toBeFormatted = ''' - newArrayList("x") . map ( ) [ ] - ''' - ] - } - - @Test def formatMemberFeatureCallBuilder2() { - assertFormattedExpression [ - expectation = ''' - newArrayList("x").map()[lenght] - ''' - toBeFormatted = ''' - newArrayList("x") . map ( ) [ lenght ] - ''' - ] - } - - @Test def formatMemberFeatureCallBuilderMultiline1() { - assertFormattedExpression [ - expectation = ''' - newArrayList("x").map( - length - )[lenght] - ''' - toBeFormatted = ''' - newArrayList("x") . map ( length - ) [ lenght ] - ''' - ] - } - - @Test def formatMemberFeatureCallBuilderMultiline2() { - assertFormattedExpression [ - expectation = ''' - newArrayList("x").map(length) [ - length - ] - ''' - toBeFormatted = ''' - newArrayList("x") . map ( length ) [ length - ] - ''' - ] - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=461033 - */ - @Test def formatMemberFeatureCallParenthesized() { - assertFormattedExpression [ - expectation = ''' - val s = ("a" + "b").substring(1) - ''' - toBeFormatted = ''' - val s = ("a" + "b") . substring(1) - ''' - ] - } - - @Test def formatBinaryExpression1() { - assertFormattedExpression [ - expectation = ''' - val ML1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + - 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + - 30 + 31 + 32 + 33 + 34 + 35 + 36 - ''' - toBeFormatted = ''' - val ML1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 - ''' - ] - } - - @Test def formatBinaryExpression2() { - assertFormattedExpression [ - expectation = ''' - val ML1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + - 11 * 12 * 13 * 14 * 15 * 16 * 17 * 18 + 19 + 20 + 21 + 22 + 23 + 24 + - 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 - ''' - toBeFormatted = ''' - val ML1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 * 12 * 13 * 14 * 15 * 16 * 17 * 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 - ''' - ] - } - - @Test def formatXTypeLiteral() { - assertFormattedExpression [ - expectation = ''' - typeof(String) - ''' - toBeFormatted = ''' - typeof ( String ) - ''' - ] - } - - @Test def formatXTypeLiteralArray1() { - assertFormattedExpression [ - expectation = ''' - typeof(String[]) - ''' - toBeFormatted = ''' - typeof ( String [ ]) - ''' - ] - } - - @Test def formatXTypeLiteralArray2() { - assertFormattedExpression [ - expectation = ''' - typeof(String[][]) - ''' - toBeFormatted = ''' - typeof ( String [ ] [ ] ) - ''' - ] - } - - @Test def formatXThrowExpression() { - assertFormattedExpression [ - expectation = ''' - throw new RuntimeException() - ''' - toBeFormatted = ''' - throw new RuntimeException() - ''' - ] - } - - @Test def formatXReturnExpression1() { - assertFormattedExpression [ - expectation = ''' - return "foo" - ''' - toBeFormatted = ''' - return "foo" - ''' - ] - } - - @Test def formatXReturnExpression2() { - assertFormattedExpression [ - expectation = ''' - "foo" - return - ''' - toBeFormatted = ''' - "foo" return - ''' - ] - } - - @Test def formatXReturnExpression3() { - assertFormattedExpression [ - expectation = ''' - return; - ''' - toBeFormatted = ''' - return ; - ''' - ] - } - - @Test def formatTryFinallyExpression1() { - assertFormattedExpression [ - expectation = ''' - try - println("x") - finally - println("y") - ''' - toBeFormatted = ''' - try println("x") finally println("y") - ''' - ] - } - - @Test def formatTryFinallyExpression2() { - assertFormattedExpression [ - expectation = ''' - try { - println("x") - } finally { - println("y") - } - ''' - toBeFormatted = ''' - try { println("x") } finally { println("y") } - ''' - ] - } - - @Test def formatTryCatchExpression11() { - assertFormattedExpression [ - preferences [ - put(whitespaceBetweenKeywordAndParenthesisML, true) - ] - toBeFormatted = ''' - try - println("x") - catch (Exception e) - println("y") - ''' - ] - } - - @Test def formatTryCatchExpression12() { - assertFormattedExpression [ - preferences [ - put(whitespaceBetweenKeywordAndParenthesisML, false) - ] - toBeFormatted = ''' - try - println("x") - catch(Exception e) - println("y") - ''' - ] - } - - @Test def formatTryCatchExpression2() { - assertFormattedExpression [ - expectation = ''' - try { - println("x") - } catch (Exception e) { - println("y") - } - ''' - toBeFormatted = ''' - try { println("x") } catch ( Exception e ) { println("y") } - ''' - ] - } - - @Test def formatTryCatchFinallyExpression1() { - assertFormattedExpression [ - expectation = ''' - try - println("x") - catch (Exception e) - println("y") - finally - println("z") - ''' - toBeFormatted = ''' - try println("x") catch ( Exception e ) println("y") finally println("z") - ''' - ] - } - - @Test def formatTryCatchFinallyExpressionBug474022() { - assertFormattedExpression [ - preferences [ - put(bracesInNewLine, false) - ] - expectation = ''' - val i = try { - println("x") - 1 - } catch (Exception e) { - println("y") - 2 - } finally { - println("z") - } - ''' - toBeFormatted = ''' - val i = try { println("x") 1 } catch ( Exception e ) { println("y") 2 } finally { println("z") } - ''' - ] - } - - @Test def formatTryCatchFinallyExpression2() { - assertFormattedExpression [ - preferences [ - put(bracesInNewLine, false) - ] - expectation = ''' - try { - println("x") - } catch (Exception e) { - println("y") - } finally { - println("z") - } - ''' - toBeFormatted = ''' - try { println("x") } catch ( Exception e ) { println("y") } finally { println("z") } - ''' - ] - } - - @Test def formatTryCatchFinallyExpression3() { - assertFormattedExpression [ - preferences [ - put(bracesInNewLine, true) - ] - expectation = ''' - try - { - println("x") - } - catch (Exception e) - { - println("y") - } - finally - { - println("z") - } - ''' - toBeFormatted = ''' - try { println("x") } catch ( Exception e ) { println("y") } finally { println("z") } - ''' - ] - } - - @Test def formatTryCatchCatchFinallyExpression1() { - assertFormattedExpression [ - expectation = ''' - try - println("x") - catch (Exception e) - println("y") - catch (Exception f) - println("z") - finally - println("a") - ''' - toBeFormatted = ''' - try println("x") catch ( Exception e ) println("y") catch ( Exception f ) println("z") finally println("a") - ''' - ] - } - - @Test def formatTryCatchCatchFinallyExpression2() { - assertFormattedExpression [ - expectation = ''' - try { - println("x") - } catch (Exception e) { - println("y") - } catch (Exception f) { - println("z") - } finally { - println("a") - } - ''' - toBeFormatted = ''' - try { println("x") } catch ( Exception e ) { println("y") } catch ( Exception f ) { println("z") } finally { println("a") } - ''' - ] - } - - @Test def formatListLiteral1() { - assertFormattedExpression [ - expectation = ''' - #[12, 13, 14] - ''' - toBeFormatted = ''' - #[12, 13 , 14 ] - ''' - ] - } - - @Test def formatListLiteral3() { - assertFormattedExpression [ - expectation = ''' - #[ - 12, - 13, - 14 - ] - ''' - toBeFormatted = ''' - #[12, 13 , 14 - ] - ''' - ] - } - - @Test def formatEmptySwitchSL() { - assertFormattedExpression [ - expectation = ''' - switch null { } - ''' - toBeFormatted = ''' - switch null { } - ''' - ] - } - - @Test def formatEmptySwitchSL_2() { - assertFormattedExpression [ - expectation = ''' - switch null { default: 1 } - ''' - toBeFormatted = ''' - switch null { default : 1 } - ''' - ] - } - - @Test def formatEmptySwitchML() { - assertFormattedExpression [ - expectation = ''' - switch null { - } - ''' - toBeFormatted = ''' - switch null { - - - - } - ''' - ] - } - - @Test def formatEmptySwitchML_2() { - assertFormattedExpression [ - expectation = ''' - switch null { - default: 1 - } - ''' - toBeFormatted = ''' - switch null { - - - - default : 1 - - } - ''' - ] - } - - @Test def formatInstanceOf() { - assertFormattedExpression [ - expectation = ''' - "x".toString instanceof String - ''' - toBeFormatted = ''' - "x".toString instanceof String - ''' - ] - } - - @Test def formatCast() { - assertFormattedExpression [ - expectation = ''' - "x" as String - ''' - toBeFormatted = ''' - "x" as String - ''' - ] - } - - @Test def formatPostfix() { - assertFormattedExpression [ - expectation = ''' - val i = j++ - ''' - toBeFormatted = ''' - val i = j ++ - ''' - ] - } - - @Test def void testFeatureCallWithParentheses() { - assertFormattedExpression [ - expectation = ''' - val it = "xxxx" - val j = true && (startsWith("x")) - ''' - toBeFormatted = ''' - val it = "xxxx" - val j = true&&(startsWith("x")) - ''' - ] - } - - @Test def void testMemberFeatureCallWithParentheses() { - assertFormattedExpression [ - expectation = ''' - val j = true && (class.startsWith("Hugo")) - ''' - toBeFormatted = ''' - val j = true&&(class.startsWith("Hugo")) - ''' - ] - } - - @Test def void testIssue527() { - assertFormattedExpression[ - expectation = ''' - var veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryname = #[ - 1, 2, 3, 4, 5] - veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryname. - map [ l | - veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryname - ] - ''' - toBeFormatted = ''' - var veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryname = #[1,2,3,4,5] - veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryname.map[l|veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryname] - - ''' - ] - } -} diff --git a/org.eclipse.xtext.xbase.tests/xtend-gen/org/eclipse/xtext/xbase/tests/formatting/XbaseCommentFormatterTest.java b/org.eclipse.xtext.xbase.tests/xtend-gen/org/eclipse/xtext/xbase/tests/formatting/XbaseCommentFormatterTest.java deleted file mode 100644 index 349ea292e4..0000000000 --- a/org.eclipse.xtext.xbase.tests/xtend-gen/org/eclipse/xtext/xbase/tests/formatting/XbaseCommentFormatterTest.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.eclipse.xtext.xbase.tests.formatting; - -import com.google.inject.Inject; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.testing.InjectWith; -import org.eclipse.xtext.testing.XtextRunner; -import org.eclipse.xtext.testing.formatter.FormatterTestRequest; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(XtextRunner.class) -@InjectWith(XbaseFormatterTestInjectorProvider.class) -@SuppressWarnings("all") -public class XbaseCommentFormatterTest { - @Inject - @Extension - private XbaseFormatterTester _xbaseFormatterTester; - - @Test - public void commentInIfExpression() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("if (true)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"foo\")"); - _builder.newLine(); - _builder.append("else // if (true)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"bar\")"); - _builder.newLine(); - _builder.append("println(\"end\")"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void commentAfterForExpression1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("for (f : #[])"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("if (1 < 2) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.newLine(); - _builder.append("// foo"); - _builder.newLine(); - _builder.append("var lastOffset = \"\""); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void commentAfterForExpression3() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val ll = #[].map(e|e.toString) // error here"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } -} diff --git a/org.eclipse.xtext.xbase.tests/xtend-gen/org/eclipse/xtext/xbase/tests/formatting/XbaseFormatterTest.java b/org.eclipse.xtext.xbase.tests/xtend-gen/org/eclipse/xtext/xbase/tests/formatting/XbaseFormatterTest.java deleted file mode 100644 index fcde779f4c..0000000000 --- a/org.eclipse.xtext.xbase.tests/xtend-gen/org/eclipse/xtext/xbase/tests/formatting/XbaseFormatterTest.java +++ /dev/null @@ -1,2858 +0,0 @@ -package org.eclipse.xtext.xbase.tests.formatting; - -import com.google.inject.Inject; -import org.eclipse.xtend2.lib.StringConcatenation; -import org.eclipse.xtext.preferences.MapBasedPreferenceValues; -import org.eclipse.xtext.testing.InjectWith; -import org.eclipse.xtext.testing.XtextRunner; -import org.eclipse.xtext.testing.formatter.FormatterTestRequest; -import org.eclipse.xtext.xbase.formatting2.XbaseFormatterPreferenceKeys; -import org.eclipse.xtext.xbase.lib.Extension; -import org.eclipse.xtext.xbase.lib.Procedures.Procedure1; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(XtextRunner.class) -@InjectWith(XbaseFormatterTestInjectorProvider.class) -@SuppressWarnings("all") -public class XbaseFormatterTest { - @Inject - @Extension - private XbaseFormatterTester _xbaseFormatterTester; - - @Test - public void formatGenerics() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val x = >newArrayList()"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatBlockExpression() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val x = newArrayList(\"A\", \"b\");"); - _builder.newLine(); - _builder.append("val y = \'foo\';"); - _builder.newLine(); - _builder.append("x.join"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val x = newArrayList(\"A\", \"b\") ; val y = \'foo\' ; x.join"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatBlockExpressionPreserveNewLines() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("{"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("val x = newArrayList(\"A\", \"b\");"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("val y = \'foo\'"); - _builder.newLine(); - _builder.newLine(); - _builder.append("\t"); - _builder.append("x.join"); - _builder.newLine(); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder.toString().trim()); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append(" "); - _builder_1.append("{ "); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("val x = newArrayList(\"A\", \"b\") ;"); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("val y = \'foo\'"); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append(" "); - _builder_1.append("x.join"); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append(" "); - _builder_1.append("}"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormatted(_function); - } - - @Test - public void formatClosures() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val x = newArrayList(\"A\", \"b\")"); - _builder.newLine(); - _builder.append("val y = x.filter[toUpperCase == it]"); - _builder.newLine(); - _builder.append("y.join"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatClosuresParenthesis() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val x = newArrayList(\"A\", \"b\")"); - _builder.newLine(); - _builder.append("val y = x.filter(toUpperCase == it)"); - _builder.newLine(); - _builder.append("y.join"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatClosuresParenthesis2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val x = newArrayList(\"A\", \"b\")"); - _builder.newLine(); - _builder.append("val y = x.filter(foo|foo.toUpperCase == foo)"); - _builder.newLine(); - _builder.append("y.join"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatClosuresSemicolon() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("newArrayList(\"A\", \"b\").filter[val b = it; b.toUpperCase == b]"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("newArrayList(\"A\", \"b\").filter[ val b = it ; b.toUpperCase == b ]"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatClosuresEmpty() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val x = newArrayList(\"A\", \"b\")"); - _builder.newLine(); - _builder.append("val y = x.filter[]"); - _builder.newLine(); - _builder.append("y.join"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val x = newArrayList(\"A\", \"b\") val y = x.filter[ ] y.join"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatClosuresParam() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val x = newArrayList(\"A\", \"b\")"); - _builder.newLine(); - _builder.append("val y = x.filter[z|z.toUpperCase == z]"); - _builder.newLine(); - _builder.append("y.join"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatClosuresEmptyParam() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val Iterable x = [|#[].iterator]"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatClosuresMultiLine() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val x = newArrayList(\"A\", \"b\")"); - _builder.newLine(); - _builder.append("val y = x.filter ["); - _builder.newLine(); - _builder.append("\t"); - _builder.append("val z = it"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("z.toUpperCase == z"); - _builder.newLine(); - _builder.append("]"); - _builder.newLine(); - _builder.append("y.join"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val x = newArrayList(\"A\", \"b\") val y = x.filter ["); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("val z = it z.toUpperCase == z "); - _builder_1.newLine(); - _builder_1.append("] y.join"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatClosuresMultiLine_02() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val x = newArrayList(\"A\", \"b\")"); - _builder.newLine(); - _builder.append("val y = x.filter ["); - _builder.newLine(); - _builder.append("\t"); - _builder.append("val z = it"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("z.toUpperCase == z"); - _builder.newLine(); - _builder.append("]"); - _builder.newLine(); - _builder.append("y.join"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val x = newArrayList(\"A\", \"b\") val y = x.filter["); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("val z = it z.toUpperCase == z "); - _builder_1.newLine(); - _builder_1.append("] y.join"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatClosuresMultiLine03() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("new Thread [|"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"foo\")"); - _builder.newLine(); - _builder.append("]"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("new Thread[ | println(\"foo\")"); - _builder_1.newLine(); - _builder_1.append("]"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatClosuresMultiLineSemicolon() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val x = newArrayList(\"A\", \"b\")"); - _builder.newLine(); - _builder.append("val y = x.filter ["); - _builder.newLine(); - _builder.append("\t"); - _builder.append("val z = it;"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("z.toUpperCase == z;"); - _builder.newLine(); - _builder.append("]"); - _builder.newLine(); - _builder.append("y.join"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val x = newArrayList(\"A\", \"b\") val y = x.filter ["); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("val z = it ; z.toUpperCase == z ; "); - _builder_1.newLine(); - _builder_1.append("] y.join"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatClosuresWrapIfNeeded() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val x = newArrayList(\"A\", \"b\")"); - _builder.newLine(); - _builder.append("val y = x.filter ["); - _builder.newLine(); - _builder.append("\t"); - _builder.append("val z = it"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("z.toUpperCase == z"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("z.toUpperCase == z"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("z.toUpperCase == z"); - _builder.newLine(); - _builder.append("]"); - _builder.newLine(); - _builder.append("y.join"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val x = newArrayList(\"A\", \"b\") val y = x.filter [ val z = it z.toUpperCase == z z.toUpperCase == z z.toUpperCase == z ] y.join"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatClosuresParamMultiLine() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val x = newArrayList(\"A\", \"b\")"); - _builder.newLine(); - _builder.append("val y = x.filter [ z |"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("val w = z"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("w.toUpperCase == w"); - _builder.newLine(); - _builder.append("]"); - _builder.newLine(); - _builder.append("y.join"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val x = newArrayList(\"A\", \"b\") val y = x.filter[ z |"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("val w = z w.toUpperCase == w"); - _builder_1.newLine(); - _builder_1.append("] y.join"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatClosuresWithOperator() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val x = new StringBuffer() => ["); - _builder.newLine(); - _builder.append("\t"); - _builder.append("append(\"x\")"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("append(\"y\")"); - _builder.newLine(); - _builder.append("]"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val x = new StringBuffer() => ["); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("append(\"x\")"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("append(\"y\")"); - _builder_1.newLine(); - _builder_1.append("]"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatMultiLineClosureWithAssignment() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("x += foo.myBuilder ["); - _builder.newLine(); - _builder.append("\t"); - _builder.append("foo"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("bar"); - _builder.newLine(); - _builder.append("]"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("x += foo.myBuilder ["); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("foo bar"); - _builder_1.newLine(); - _builder_1.append("]"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatSynchronizedBlock_1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("synchronized (new Object) {"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("synchronized(new Object){}"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatSynchronizedBlock_2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("synchronized (new Object) {"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("synchronized ( new Object ) { }"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatIf1SL1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisSL, Boolean.valueOf(true)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("if (true) println(\"foo\")"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatIf1SL2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisSL, Boolean.valueOf(false)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("if(true) println(\"foo\")"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatIf1ML1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(true)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("if (true)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"foo\")"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatIf1ML2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(false)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("if(true)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"foo\")"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatIf1MLVar() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("var x = if (true)"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\"foo\")"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("else"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\"bar\")"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("var x = if(true)"); - _builder_1.newLine(); - _builder_1.append("println(\"foo\") else println(\"bar\")"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatIf1MLSemicolon1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("if (true)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"foo\");"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("if(true)"); - _builder_1.newLine(); - _builder_1.append("println(\"foo\");"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatIf1MLSemicolon2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("if (true)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"foo\");"); - _builder.newLine(); - _builder.append("println(\"bar\")"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("if(true)"); - _builder_1.newLine(); - _builder_1.append("println(\"foo\");"); - _builder_1.newLine(); - _builder_1.append("println(\"bar\")"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatIf2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("if (true) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"foo\")"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatIfElse1SL() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("if(true) println(\"foo\") else println(\"bar\")"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("if(true)println(\"foo\")else println(\"bar\")"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatIfElse1ML() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("if (true)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"foo\")"); - _builder.newLine(); - _builder.append("else"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"bar\")"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("if(true)"); - _builder_1.newLine(); - _builder_1.append("println(\"foo\")"); - _builder_1.newLine(); - _builder_1.append("else"); - _builder_1.newLine(); - _builder_1.append("println(\"bar\")"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatIfElse2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("if (true) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"foo\")"); - _builder.newLine(); - _builder.append("} else {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"bar\")"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatIfElse3() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("if (true)"); - _builder.newLine(); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"foo\")"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.append("else"); - _builder.newLine(); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"bar\")"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatIfElseIf1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("if (true)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"foo\")"); - _builder.newLine(); - _builder.append("else if (false)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"bar\")"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("if(true)"); - _builder_1.newLine(); - _builder_1.append("println(\"foo\")"); - _builder_1.newLine(); - _builder_1.append("else if(false)"); - _builder_1.newLine(); - _builder_1.append("println(\"bar\")"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatIfElseIf2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("if (true) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"foo\")"); - _builder.newLine(); - _builder.append("} else if (false) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"bar\")"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("if(true) {"); - _builder_1.newLine(); - _builder_1.append("println(\"foo\")"); - _builder_1.newLine(); - _builder_1.append("} else if(false) {"); - _builder_1.newLine(); - _builder_1.append("println(\"bar\")"); - _builder_1.newLine(); - _builder_1.append("}"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatIfElseIf3() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("if (true) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"foo\")"); - _builder.newLine(); - _builder.append("} else if (false)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"bar\")"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("if(true) {"); - _builder_1.newLine(); - _builder_1.append("println(\"foo\")"); - _builder_1.newLine(); - _builder_1.append("} else if(false)"); - _builder_1.newLine(); - _builder_1.append("println(\"bar\")"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatFor1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("for (i : 1 .. 2)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(i)"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("for ( i : 1 .. 2 ) println(i)"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatFor2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(false)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("for (i : 1 .. 2) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(i)"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatFor3() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("for (i : 1 .. 2)"); - _builder.newLine(); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(i)"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatBasicFor() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("for (var i = 1; i < 10; i = i + 1)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(i)"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("for ( var i = 1 ; i < 10; i = i + 1 ) println(i)"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatBasicFor2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("for (;;) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("return true"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("for ( ; ; ) { return true }"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatBasicFor3() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("var int x"); - _builder.newLine(); - _builder.append("var int y"); - _builder.newLine(); - _builder.append("for (x = 1, y = 2;;) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("return x + y"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("var int x"); - _builder_1.newLine(); - _builder_1.append("var int y "); - _builder_1.newLine(); - _builder_1.append("for ( x = 1 , y = 2 ; ; ) { return x + y }"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatBasicFor4() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val x = 1"); - _builder.newLine(); - _builder.append("for (; x < 10;)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(x)"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val x = 1"); - _builder_1.newLine(); - _builder_1.append("for ( ; x < 10 ; ) println(x)"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatBasicFor5() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val x = 1"); - _builder.newLine(); - _builder.append("for (;; x = x + 1, x = x + 2)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(x)"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val x = 1"); - _builder_1.newLine(); - _builder_1.append("for ( ; ; x = x \t+ 1 , x = x + 2 ) println(x)"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatBasicFor6() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("for (val x = 1;; x = x + 1, x = x + 2)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(x)"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("for (\t\t\tval \t\tx \t\t= \t\t1\t\t; ; x = x \t+ 1 , x = x + 2 ) println(x)"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatWhile11() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(true)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("while (true)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"x\")"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatWhile12() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(false)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("while(true)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"x\")"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatWhile2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(false)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("while (true) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"x\")"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatWhile21() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("while (true)"); - _builder.newLine(); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"x\")"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatDoWhile11() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(true)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("do"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"x\")"); - _builder.newLine(); - _builder.append("while (true)"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatDoWhile12() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(false)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("do"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"x\")"); - _builder.newLine(); - _builder.append("while(true)"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatDoWhile2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(false)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("do {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"x\")"); - _builder.newLine(); - _builder.append("} while (true)"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatDoWhile3() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("do"); - _builder.newLine(); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"x\")"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.append("while (true)"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatSwitchSL() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(false)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch \'x\' { case \'x\': println(\'x\') case \'y\': println(\'y\') }"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatSwitchSL1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch \'x\' { case \'x\': println(\'x\') case \'y\': println(\'y\') }"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatSwitchDefaultSL() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(false)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch \'x\' { case \'y\': println(\'y\') default: println(\'z\') }"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatSwitchDefaultSL1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch \'x\' { case \'y\': println(\'y\') default: println(\'z\') }"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatSwitchCaseSL1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch \'x\'"); - _builder.newLine(); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'x\': println(\'x\')"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'y\': println(\'y\')"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatSwitchCaseSLParenthesis() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch \'x\' {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'x\': println(\'x\')"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'y\': println(\'y\')"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("switch \'x\' { "); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("case \'x\': println(\'x\') case \'y\': println(\'y\')"); - _builder_1.newLine(); - _builder_1.append("}"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatSwitchCaseDefaultSL1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch \'x\'"); - _builder.newLine(); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'x\': println(\'x\')"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'y\': println(\'y\')"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("default: println(\'z\')"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatSwitchCaseDefaultSLParenthesis() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch \'x\' {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'x\': println(\'x\')"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'y\': println(\'y\')"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("default: println(\'z\')"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("switch \'x\' { "); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("case \'x\': println(\'x\') case \'y\': println(\'y\') default : println(\'z\')"); - _builder_1.newLine(); - _builder_1.append("}"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatSwitchML() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch \'x\' {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'x\':"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\'x\')"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'y\':"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\'y\')"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("switch \'x\' { "); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("case \'x\': "); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("println(\'x\') case \'y\': println(\'y\')"); - _builder_1.newLine(); - _builder_1.append("}"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatSwitchDefaultML() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch \'x\' {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'x\':"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\'x\')"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'y\':"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\'y\')"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("default:"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\'z\')"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("switch \'x\' { "); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("case \'x\': "); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("println(\'x\') case \'y\': println(\'y\') default : println(\'z\')"); - _builder_1.newLine(); - _builder_1.append("}"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatSwitchDefault2ML() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch \'x\' {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'x\':"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\'x\')"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'y\':"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\'y\')"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("default:"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\'z\')"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("switch \'x\' { "); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("case \'x\': println(\'x\') case \'y\': println(\'y\') "); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("default : "); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("println(\'z\')"); - _builder_1.newLine(); - _builder_1.append("}"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatSwitchDefault2MLFallThrough() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch \'x\' {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'x\',"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'y\':"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\'y\')"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("default:"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\'z\')"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("switch \'x\' { "); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("case \'x\' , case \'y\': println(\'y\') "); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("default : "); - _builder_1.newLine(); - _builder_1.append("\t\t"); - _builder_1.append("println(\'z\')"); - _builder_1.newLine(); - _builder_1.append("}"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatSwitchMLBlock() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(false)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch \'x\' {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'x\': {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\'x\')"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'y\': {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\'y\')"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("switch \'x\' { case \'x\': { println(\'x\') } case \'y\': { println(\'y\') } }"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatSwitchDefaultMLBlock() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(false)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch \'x\' {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'x\': {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\'x\')"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'y\': {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\'y\')"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("default: {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\'z\')"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("switch \'x\' { case \'x\': { println(\'x\') } case \'y\': { println(\'y\') } default: { println(\'z\') } }"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatSwitchMLBlock1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch \'x\'"); - _builder.newLine(); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'x\':"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\'x\')"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("case \'y\':"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\'y\')"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("switch \'x\' { case \'x\': { println(\'x\') } case \'y\': { println(\'y\') } }"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatFeatureCallNoParenthesis() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val v1 = newArrayList"); - _builder.newLine(); - _builder.append("val v2 = newArrayList"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatFeatureCallNoParams() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val v1 = newArrayList()"); - _builder.newLine(); - _builder.append("val v2 = newArrayList()"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatFeatureCall1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val ML2 = newArrayList(newArrayList(1, 2, 3, 4, 5, 6),"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("newArrayList(5, 6, 7, 8), newArrayList(9, 10, 11, 12),"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("newArrayList(13, 14, 15, 16))"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val ML2 = newArrayList(newArrayList(1, 2, 3, 4, 5, 6), newArrayList(5, 6, 7, 8), newArrayList(9, 10, 11, 12), newArrayList(13, 14, 15, 16))"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatFeatureCall2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val ML2 = newArrayList(newArrayList(1, 2, 3, 4),"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("newArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109,"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120),"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("newArrayList(9, 10, 11, 12), newArrayList(13, 14, 15, 16))"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val ML2 = newArrayList(newArrayList(1, 2, 3, 4), newArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120), newArrayList(9, 10, 11, 12), newArrayList(13, 14, 15, 16))"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatFeatureCallMultiline() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val ML2 = newArrayList("); - _builder.newLine(); - _builder.append("\t"); - _builder.append("newArrayList(1, 2, 3, 4),"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("newArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109,"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120),"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("newArrayList(9),"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("newArrayList(10)"); - _builder.newLine(); - _builder.append(")"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val ML2 = newArrayList(newArrayList(1, 2, 3, 4), newArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120), newArrayList(9), newArrayList(10)"); - _builder_1.newLine(); - _builder_1.append(")"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatConstructorCallNoParenthesis() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val v1 = new ArrayList"); - _builder.newLine(); - _builder.append("val v2 = new ArrayList"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatConstructorCallClosure() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("new Thread[|println(\"foo\")]"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatConstructorCallNoParams() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val v1 = new ArrayList()"); - _builder.newLine(); - _builder.append("val v2 = new ArrayList()"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatConstructorCall1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val ML2 = new ArrayList(new ArrayList(1, 2, 3, 4, 5, 6),"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("new ArrayList(5, 6, 7, 8), new ArrayList(9, 10, 11, 12),"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("new ArrayList(13, 14, 15, 16))"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val ML2 = new ArrayList(new ArrayList(1, 2, 3, 4, 5, 6), new ArrayList(5, 6, 7, 8), new ArrayList(9, 10, 11, 12), new ArrayList(13, 14, 15, 16))"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatConstructorCall2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val ML2 = new ArrayList(new ArrayList(1, 2, 3, 4),"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("new ArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109,"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120),"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("new ArrayList(9, 10, 11, 12), new ArrayList(13, 14, 15, 16))"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val ML2 = new ArrayList(new ArrayList(1, 2, 3, 4), new ArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120), new ArrayList(9, 10, 11, 12), new ArrayList(13, 14, 15, 16))"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatConstructorCallMultiline() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val ML2 = new ArrayList("); - _builder.newLine(); - _builder.append("\t"); - _builder.append("new ArrayList(1, 2, 3, 4),"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("new ArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109,"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120),"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("new ArrayList(9, 10, 11, 12),"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("new ArrayList(13, 14, 15, 16)"); - _builder.newLine(); - _builder.append(")"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val ML2 = new ArrayList(new ArrayList(1, 2, 3, 4), new ArrayList(5, 6, 7, 8, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120), new ArrayList(9, 10, 11, 12), new ArrayList(13, 14, 15, 16)"); - _builder_1.newLine(); - _builder_1.append(")"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatMemberFeatureCallNoParenthesis() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val v1 = \"x\".toString"); - _builder.newLine(); - _builder.append("val v2 = \"x\".toString"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatMemberFeatureCallNoParams() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val v1 = \"x\".toString()"); - _builder.newLine(); - _builder.append("val v2 = \"x\".toString()"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatMemberFeatureCall1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val ML1 = \"x\".substring(0).substring(1).substring(2).substring(3)."); - _builder.newLine(); - _builder.append("\t"); - _builder.append("substring(4).substring(5).substring(6).substring(7).substring(8)."); - _builder.newLine(); - _builder.append("\t"); - _builder.append("substring(9).substring(10).substring(11)"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val ML1 = \"x\".substring(0).substring(1).substring(2).substring(3).substring(4).substring(5).substring(6).substring(7).substring(8).substring(9).substring(10).substring(11)"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatMemberFeatureCall2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val ML1 = \"x\".substring(0).substring(1)"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val ML1 = \"x\""); - _builder_1.newLine(); - _builder_1.append("."); - _builder_1.newLine(); - _builder_1.append("substring(0)"); - _builder_1.newLine(); - _builder_1.append("."); - _builder_1.newLine(); - _builder_1.append("substring(1)"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatMemberFeatureCall21() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val ML1 = \"x\".toString.toString"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val ML1 = \"x\""); - _builder_1.newLine(); - _builder_1.append("."); - _builder_1.newLine(); - _builder_1.append("toString"); - _builder_1.newLine(); - _builder_1.append("."); - _builder_1.newLine(); - _builder_1.append("toString"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatMemberFeatureCall3() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val ML1 = \"x\".substring(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28)"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val ML1 = \"x\".substring(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28)"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatMemberFeatureCall4() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val ML1 = \"x\".substring(0, 1, 2)"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val ML1 = \"x\".substring ("); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("0, "); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("1, "); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("2)"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatMemberFeatureCallMultiline() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val ML1 = \"x\".substring("); - _builder.newLine(); - _builder.append("\t"); - _builder.append("0,"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("1,"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("2"); - _builder.newLine(); - _builder.append(")"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val ML1 = \"x\".substring ("); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("0, "); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("1, "); - _builder_1.newLine(); - _builder_1.newLine(); - _builder_1.append("2"); - _builder_1.newLine(); - _builder_1.append(")"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatMemberFeatureCallBuilder1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("newArrayList(\"x\").map()[]"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("newArrayList(\"x\") . map ( ) [ ]"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatMemberFeatureCallBuilder2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("newArrayList(\"x\").map()[lenght]"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("newArrayList(\"x\") . map ( ) [ lenght ]"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatMemberFeatureCallBuilderMultiline1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("newArrayList(\"x\").map("); - _builder.newLine(); - _builder.append("\t"); - _builder.append("length"); - _builder.newLine(); - _builder.append(")[lenght]"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("newArrayList(\"x\") . map ( length "); - _builder_1.newLine(); - _builder_1.append(") [ lenght ]"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatMemberFeatureCallBuilderMultiline2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("newArrayList(\"x\").map(length) ["); - _builder.newLine(); - _builder.append("\t"); - _builder.append("length"); - _builder.newLine(); - _builder.append("]"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("newArrayList(\"x\") . map ( length ) [ length "); - _builder_1.newLine(); - _builder_1.append("]"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - /** - * https://bugs.eclipse.org/bugs/show_bug.cgi?id=461033 - */ - @Test - public void formatMemberFeatureCallParenthesized() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val s = (\"a\" + \"b\").substring(1)"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val s = (\"a\" + \"b\") . substring(1)"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatBinaryExpression1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val ML1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 +"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 +"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("30 + 31 + 32 + 33 + 34 + 35 + 36"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val ML1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 "); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatBinaryExpression2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val ML1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 +"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("11 * 12 * 13 * 14 * 15 * 16 * 17 * 18 + 19 + 20 + 21 + 22 + 23 + 24 +"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val ML1 = 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 * 12 * 13 * 14 * 15 * 16 * 17 * 18 + 19 + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 + 30 + 31 + 32 + 33 + 34 + 35 + 36 "); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatXTypeLiteral() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("typeof(String)"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("typeof ( String )"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatXTypeLiteralArray1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("typeof(String[])"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("typeof ( String [ ])"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatXTypeLiteralArray2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("typeof(String[][])"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("typeof ( String [ ] [ ] )"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatXThrowExpression() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("throw new RuntimeException()"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("throw new RuntimeException()"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatXReturnExpression1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("return \"foo\""); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("return \"foo\""); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatXReturnExpression2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("\"foo\""); - _builder.newLine(); - _builder.append("return"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("\"foo\" return"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatXReturnExpression3() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("return;"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("return ;"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatTryFinallyExpression1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("try"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"x\")"); - _builder.newLine(); - _builder.append("finally"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"y\")"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("try println(\"x\") finally println(\"y\")"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatTryFinallyExpression2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("try {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"x\")"); - _builder.newLine(); - _builder.append("} finally {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"y\")"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("try { println(\"x\") } finally { println(\"y\") }"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatTryCatchExpression11() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(true)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("try"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"x\")"); - _builder.newLine(); - _builder.append("catch (Exception e)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"y\")"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatTryCatchExpression12() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.whitespaceBetweenKeywordAndParenthesisML, Boolean.valueOf(false)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("try"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"x\")"); - _builder.newLine(); - _builder.append("catch(Exception e)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"y\")"); - _builder.newLine(); - it.setToBeFormatted(_builder); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatTryCatchExpression2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("try {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"x\")"); - _builder.newLine(); - _builder.append("} catch (Exception e) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"y\")"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("try { println(\"x\") } catch ( Exception e ) { println(\"y\") }"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatTryCatchFinallyExpression1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("try"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"x\")"); - _builder.newLine(); - _builder.append("catch (Exception e)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"y\")"); - _builder.newLine(); - _builder.append("finally"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"z\")"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("try println(\"x\") catch ( Exception e ) println(\"y\") finally println(\"z\")"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatTryCatchFinallyExpressionBug474022() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(false)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val i = try {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\"x\")"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("1"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("} catch (Exception e) {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\"y\")"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("2"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("} finally {"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("println(\"z\")"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val i = try { println(\"x\") 1 } catch ( Exception e ) { println(\"y\") 2 } finally { println(\"z\") }"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatTryCatchFinallyExpression2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(false)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("try {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"x\")"); - _builder.newLine(); - _builder.append("} catch (Exception e) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"y\")"); - _builder.newLine(); - _builder.append("} finally {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"z\")"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("try { println(\"x\") } catch ( Exception e ) { println(\"y\") } finally { println(\"z\") }"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatTryCatchFinallyExpression3() { - final Procedure1 _function = (FormatterTestRequest it) -> { - final Procedure1 _function_1 = (MapBasedPreferenceValues it_1) -> { - it_1.put(XbaseFormatterPreferenceKeys.bracesInNewLine, Boolean.valueOf(true)); - }; - it.preferences(_function_1); - StringConcatenation _builder = new StringConcatenation(); - _builder.append("try"); - _builder.newLine(); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"x\")"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.append("catch (Exception e)"); - _builder.newLine(); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"y\")"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - _builder.append("finally"); - _builder.newLine(); - _builder.append("{"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"z\")"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("try { println(\"x\") } catch ( Exception e ) { println(\"y\") } finally { println(\"z\") }"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatTryCatchCatchFinallyExpression1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("try"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"x\")"); - _builder.newLine(); - _builder.append("catch (Exception e)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"y\")"); - _builder.newLine(); - _builder.append("catch (Exception f)"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"z\")"); - _builder.newLine(); - _builder.append("finally"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"a\")"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("try println(\"x\") catch ( Exception e ) println(\"y\") catch ( Exception f ) println(\"z\") finally println(\"a\")"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatTryCatchCatchFinallyExpression2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("try {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"x\")"); - _builder.newLine(); - _builder.append("} catch (Exception e) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"y\")"); - _builder.newLine(); - _builder.append("} catch (Exception f) {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"z\")"); - _builder.newLine(); - _builder.append("} finally {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("println(\"a\")"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("try { println(\"x\") } catch ( Exception e ) { println(\"y\") } catch ( Exception f ) { println(\"z\") } finally { println(\"a\") }"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatListLiteral1() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("#[12, 13, 14]"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("#[12, 13 ,\t14\t\t]"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatListLiteral3() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("#["); - _builder.newLine(); - _builder.append("\t"); - _builder.append("12,"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("13,"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("14"); - _builder.newLine(); - _builder.append("]"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("#[12, 13 ,\t14\t\t"); - _builder_1.newLine(); - _builder_1.append("]"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatEmptySwitchSL() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch null { }"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("switch null { }"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatEmptySwitchSL_2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch null { default: 1 }"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("switch null { default : 1 }"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatEmptySwitchML() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch null {"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("switch null { "); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.newLine(); - _builder_1.append("}"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatEmptySwitchML_2() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("switch null {"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("default: 1"); - _builder.newLine(); - _builder.append("}"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("switch null { "); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.append("default : 1"); - _builder_1.newLine(); - _builder_1.append("\t"); - _builder_1.newLine(); - _builder_1.append("}"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatInstanceOf() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("\"x\".toString instanceof String"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("\"x\".toString instanceof String"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatCast() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("\"x\" as String"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("\"x\" as String"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void formatPostfix() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val i = j++"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val i = j ++"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void testFeatureCallWithParentheses() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val it = \"xxxx\""); - _builder.newLine(); - _builder.append("val j = true && (startsWith(\"x\"))"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val it = \"xxxx\""); - _builder_1.newLine(); - _builder_1.append("val j = true&&(startsWith(\"x\"))"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void testMemberFeatureCallWithParentheses() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("val j = true && (class.startsWith(\"Hugo\"))"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("val j = true&&(class.startsWith(\"Hugo\"))"); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } - - @Test - public void testIssue527() { - final Procedure1 _function = (FormatterTestRequest it) -> { - StringConcatenation _builder = new StringConcatenation(); - _builder.append("var veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryname = #["); - _builder.newLine(); - _builder.append("\t"); - _builder.append("1, 2, 3, 4, 5]"); - _builder.newLine(); - _builder.append("veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryname."); - _builder.newLine(); - _builder.append("\t"); - _builder.append("map [ l |"); - _builder.newLine(); - _builder.append("\t\t"); - _builder.append("veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryname"); - _builder.newLine(); - _builder.append("\t"); - _builder.append("]"); - _builder.newLine(); - it.setExpectation(_builder); - StringConcatenation _builder_1 = new StringConcatenation(); - _builder_1.append("var veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryname = #[1,2,3,4,5]"); - _builder_1.newLine(); - _builder_1.append("veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryname.map[l|veryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryveryname]"); - _builder_1.newLine(); - _builder_1.newLine(); - it.setToBeFormatted(_builder_1); - }; - this._xbaseFormatterTester.assertFormattedExpression(_function); - } -}