Review refactor for moving new line when method body is not empty

IDEA-126070

GitOrigin-RevId: 7f0e4ae5c25b765a01b9074f0b06332151ea54b6
This commit is contained in:
Georgii Ustinov
2024-01-04 12:13:11 +00:00
committed by intellij-monorepo-bot
parent a8e0525924
commit fe8e13c09e
3 changed files with 15 additions and 3 deletions
@@ -240,7 +240,7 @@ public final class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeSty
JavaBundle.message("checkbox.do.not.wrap.after.single.annotation"), parameterAnnotationsWrapping);
consumer.showCustomOption(JavaCodeStyleSettings.class, "NEW_LINE_WHEN_BODY_NON_EMPTY",
JavaBundle.message("new.line.when.body.is.not.empty"),
JavaBundle.message("new.line.when.body.is.presented"),
ApplicationBundle.message("wrapping.method.parentheses"));
// Record components
@@ -644,7 +644,7 @@ public final class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeSty
private int f1 = 1;
private String field2 = "";
public void foo1(int i1, int i2, int i3, int i4, int i5, int i6, int i7) {}
public void fooNonEmptyBody(int i1, int i2, int i3, int i4, int i5, int i6, int i7) {int x = 1;}
public void fooNonEmptyBody() {int x = 1;}
public static void longerMethod() throws Exception1, Exception2, Exception3 {
// todo something
int
@@ -250,4 +250,16 @@ public class JavaFormatterNewLineTest extends AbstractJavaFormatterTest {
public void foo() { }
""");
}
public void testDoNotMoveSimpleMethodBodyOnNewLineWhenNonEmptyAndSettingsDisabled() {
getJavaSettings().NEW_LINE_WHEN_BODY_NON_EMPTY = false;
getSettings().KEEP_SIMPLE_METHODS_IN_ONE_LINE = true;
getSettings().SPACE_WITHIN_BRACES = true;
doClassTest("""
public void foo() {int x = 1;}
""",
"""
public void foo() { int x = 1; }
""");
}
}
@@ -1315,7 +1315,7 @@ unscramble.unscrambled.stacktrace.tab=<Stacktrace>
unscramble.unscrambled.threaddump.tab=<Threads>
unscramble.unscrambler.combobox=Un&scrambler:
unscramble.use.unscrambler.checkbox=&Unscramble stack trace
new.line.when.body.is.not.empty=New line when body isn't empty
new.line.when.body.is.presented=New line when body is presented
unwrap.anonymous=Unwrap 'anonymous...'
unwrap.array.initializer=Unwrap array initializer
unwrap.conditional=Unwrap 'f ? a : b'