Bug 578446 - [formatter] Keep braced code on one line: settings for new
switch constructs - UI

Change-Id: I8d0c9f6c6800fa4caef60e4399e3b5a7ad0834d2
Signed-off-by: Mateusz Matela <mateusz.matela@gmail.com>
Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/190167
Tested-by: JDT Bot <jdt-bot@eclipse.org>
diff --git a/org.eclipse.jdt.ui/preview/formatter.java b/org.eclipse.jdt.ui/preview/formatter.java
index fe69605..23f2087 100644
--- a/org.eclipse.jdt.ui/preview/formatter.java
+++ b/org.eclipse.jdt.ui/preview/formatter.java
@@ -723,6 +723,25 @@
 }
 //--PREVIEW--END--org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line
 
+//--PREVIEW--START--org.eclipse.jdt.core.formatter.keep_switch_body_block_on_one_line
+//--PREVIEW--START--org.eclipse.jdt.core.formatter.keep_switch_case_with_arrow_on_one_line
+class Example { void example(int empty, int tiny, int small, int notSoSmall) {
+	switch (empty) {}
+	switch (tiny) { case 1 -> {} }
+	switch (tiny) {
+		case 2 -> {
+			doSomething();
+		}
+	}
+	switch (small) { case 1 -> {} case 2 -> { doSomething(); } }
+	switch (notSoSmall) { case tiny -> { doSomething(); } case small -> { doFirstThing(); doSecondThing(); } }
+	return switch (tiny) {
+		default -> "result";
+	};
+}}
+//--PREVIEW--END--org.eclipse.jdt.core.formatter.keep_switch_body_block_on_one_line
+//--PREVIEW--END--org.eclipse.jdt.core.formatter.keep_switch_case_with_arrow_on_one_line
+
 //--PREVIEW--START--org.eclipse.jdt.core.formatter.keep_code_block_on_one_line
 class Example {
 	static {
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java
index 74a1729..8a43c07 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.java
@@ -250,6 +250,8 @@
 	public static String FormatterModifyDialog_newLines_pref_keep_record_constructor_declaration_on_one_line;
 	public static String FormatterModifyDialog_newLines_pref_keep_record_declaration_on_one_line;
 	public static String FormatterModifyDialog_newLines_pref_keep_simple_getter_setter_on_one_line;
+	public static String FormatterModifyDialog_newLines_pref_keep_switch_body_block_on_one_line;
+	public static String FormatterModifyDialog_newLines_pref_keep_switch_case_with_arrow_on_one_line;
 	public static String FormatterModifyDialog_newLines_pref_keep_type_declaration_on_one_line;
 	public static String FormatterModifyDialog_newLines_pref_local_variables;
 	public static String FormatterModifyDialog_newLines_pref_methods;
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties
index b106ecd..55f1a35 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterMessages.properties
@@ -447,6 +447,8 @@
 FormatterModifyDialog_newLines_pref_keep_record_constructor_declaration_on_one_line=Record constructor declaration
 FormatterModifyDialog_newLines_pref_keep_record_declaration_on_one_line=Record declaration
 FormatterModifyDialog_newLines_pref_keep_simple_getter_setter_on_one_line=Keep simple getters and setters on one line
+FormatterModifyDialog_newLines_pref_keep_switch_body_block_on_one_line=Switch expression/statement with arrows
+FormatterModifyDialog_newLines_pref_keep_switch_case_with_arrow_on_one_line=Switch case with arrow
 FormatterModifyDialog_newLines_pref_keep_type_declaration_on_one_line=Class declaration
 
 FormatterModifyDialog_newLines_pref_end_of_file=At end of file
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterModifyDialog.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterModifyDialog.java
index f6edc44..edb73b1 100644
--- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterModifyDialog.java
+++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/FormatterModifyDialog.java
@@ -1410,6 +1410,8 @@
 					pref.addDependant(guardianPref, valueAcceptor(oneLineOptions[0], oneLineOptions[1], oneLineOptions[4]));
 				})
 				.pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_lambda_body_block_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_LAMBDA_BODY_BLOCK_ON_ONE_LINE)
+				.pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_switch_case_with_arrow_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_SWITCH_CASE_WITH_ARROW_ON_ONE_LINE)
+				.pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_switch_body_block_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_SWITCH_BODY_BLOCK_ON_ONE_LINE)
 				.pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_code_block_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_CODE_BLOCK_ON_ONE_LINE)
 				.gap()
 				.pref(FormatterMessages.FormatterModifyDialog_newLines_pref_keep_method_body_on_one_line, DefaultCodeFormatterConstants.FORMATTER_KEEP_METHOD_BODY_ON_ONE_LINE, pref -> {