From b255a19d170c578b3f28b83964a7ca8076abe597 Mon Sep 17 00:00:00 2001 From: Georgii Ustinov Date: Thu, 14 Dec 2023 13:37:58 +0200 Subject: [PATCH] Rename JavaCodeStyleSettings option for moving simple methods to the new line IDEA-126070 GitOrigin-RevId: c4df6085aec282617344b1876cb8cc3c7bff5629 --- .../psi/codeStyle/JavaCodeStyleSettings.java | 2 +- .../ide/JavaLanguageCodeStyleSettingsProvider.java | 2 +- .../formatter/java/JavaSpacePropertyProcessor.java | 2 +- java/java-tests/testData/codeStyle/jsonExport.json | 2 +- .../psi/formatter/java/JavaFormatterNewLineTest.java | 12 ++++++------ 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/java/java-frontback-impl/src/com/intellij/psi/codeStyle/JavaCodeStyleSettings.java b/java/java-frontback-impl/src/com/intellij/psi/codeStyle/JavaCodeStyleSettings.java index 3c282f095c46..a8b57aee3293 100644 --- a/java/java-frontback-impl/src/com/intellij/psi/codeStyle/JavaCodeStyleSettings.java +++ b/java/java-frontback-impl/src/com/intellij/psi/codeStyle/JavaCodeStyleSettings.java @@ -131,7 +131,7 @@ public class JavaCodeStyleSettings extends CustomCodeStyleSettings implements Im public boolean SPACE_BEFORE_COLON_IN_FOREACH = true; public boolean SPACE_INSIDE_ONE_LINE_ENUM_BRACES = false; - public boolean NEW_LINE_WHEN_BODY_NON_EMPTY = false; + public boolean NEW_LINE_WHEN_BODY_IS_PRESENTED = false; public boolean useFqNamesInJavadocAlways() { return CLASS_NAMES_IN_JAVADOC == FULLY_QUALIFY_NAMES_ALWAYS; diff --git a/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java b/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java index cf84d11cdf03..c27b4213e86b 100644 --- a/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java +++ b/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java @@ -239,7 +239,7 @@ public final class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeSty consumer.showCustomOption(JavaCodeStyleSettings.class, "DO_NOT_WRAP_AFTER_SINGLE_ANNOTATION_IN_PARAMETER", JavaBundle.message("checkbox.do.not.wrap.after.single.annotation"), parameterAnnotationsWrapping); - consumer.showCustomOption(JavaCodeStyleSettings.class, "NEW_LINE_WHEN_BODY_NON_EMPTY", + consumer.showCustomOption(JavaCodeStyleSettings.class, "NEW_LINE_WHEN_BODY_IS_PRESENTED", JavaBundle.message("new.line.when.body.is.presented"), ApplicationBundle.message("wrapping.method.parentheses")); diff --git a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java index c79fafce7c74..4f5aabb7f2d0 100644 --- a/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java +++ b/java/java-impl/src/com/intellij/psi/formatter/java/JavaSpacePropertyProcessor.java @@ -395,7 +395,7 @@ public final class JavaSpacePropertyProcessor extends JavaElementVisitor { if (!mySettings.KEEP_SIMPLE_METHODS_IN_ONE_LINE) return false; PsiCodeBlock body = method.getBody(); return body != null && !body.textContains('\n') && - (!myJavaSettings.NEW_LINE_WHEN_BODY_NON_EMPTY || body.isEmpty()); + (!myJavaSettings.NEW_LINE_WHEN_BODY_IS_PRESENTED || body.isEmpty()); } private static int getMethodHeaderStartOffset(@NotNull PsiMethod method) { diff --git a/java/java-tests/testData/codeStyle/jsonExport.json b/java/java-tests/testData/codeStyle/jsonExport.json index 32b7388ed4eb..f7cf5ac7f42b 100644 --- a/java/java-tests/testData/codeStyle/jsonExport.json +++ b/java/java-tests/testData/codeStyle/jsonExport.json @@ -149,7 +149,7 @@ "new_line_after_lparen_in_annotation": false, "new_line_after_lparen_in_deconstruction_pattern": true, "new_line_after_lparen_in_record_header": false, - "new_line_when_body_non_empty": false, + "new_line_when_body_is_presented": false, "packages_to_use_import_on_demand": [ "java.awt.*", "javax.swing.*" diff --git a/java/java-tests/testSrc/com/intellij/java/psi/formatter/java/JavaFormatterNewLineTest.java b/java/java-tests/testSrc/com/intellij/java/psi/formatter/java/JavaFormatterNewLineTest.java index 81fd59219c5b..d7f7fec5ea09 100644 --- a/java/java-tests/testSrc/com/intellij/java/psi/formatter/java/JavaFormatterNewLineTest.java +++ b/java/java-tests/testSrc/com/intellij/java/psi/formatter/java/JavaFormatterNewLineTest.java @@ -225,8 +225,8 @@ public class JavaFormatterNewLineTest extends AbstractJavaFormatterTest { doClassTest(methodWithAnnotationAndVisibility, methodWithAnnotationAndVisibility); } - public void testMoveSimpleMethodBodyOnNewLineWhenNonEmpty() { - getJavaSettings().NEW_LINE_WHEN_BODY_NON_EMPTY = true; + public void testMoveSimpleMethodBodyOnNewLineWhenPresent() { + getJavaSettings().NEW_LINE_WHEN_BODY_IS_PRESENTED = true; getSettings().KEEP_SIMPLE_METHODS_IN_ONE_LINE = true; getSettings().SPACE_WITHIN_BRACES = true; doClassTest(""" @@ -239,8 +239,8 @@ public class JavaFormatterNewLineTest extends AbstractJavaFormatterTest { """); } - public void testDoNotMoveSimpleMethodBodyOnNewLineWhenEmpty() { - getJavaSettings().NEW_LINE_WHEN_BODY_NON_EMPTY = true; + public void testDoNotMoveSimpleMethodBodyOnNewLineWhenAbsent() { + getJavaSettings().NEW_LINE_WHEN_BODY_IS_PRESENTED = true; getSettings().KEEP_SIMPLE_METHODS_IN_ONE_LINE = true; getSettings().SPACE_WITHIN_BRACES = true; doClassTest(""" @@ -251,8 +251,8 @@ public class JavaFormatterNewLineTest extends AbstractJavaFormatterTest { """); } - public void testDoNotMoveSimpleMethodBodyOnNewLineWhenNonEmptyAndSettingsDisabled() { - getJavaSettings().NEW_LINE_WHEN_BODY_NON_EMPTY = false; + public void testDoNotMoveSimpleMethodBodyOnNewLineWhenAbsentAndSettingsDisabled() { + getJavaSettings().NEW_LINE_WHEN_BODY_IS_PRESENTED = false; getSettings().KEEP_SIMPLE_METHODS_IN_ONE_LINE = true; getSettings().SPACE_WITHIN_BRACES = true; doClassTest("""