Rename JavaCodeStyleSettings option for moving simple methods to the new line

IDEA-126070

GitOrigin-RevId: c4df6085aec282617344b1876cb8cc3c7bff5629
This commit is contained in:
Georgii Ustinov
2023-12-14 13:37:58 +02:00
committed by intellij-monorepo-bot
parent fe8e13c09e
commit b255a19d17
5 changed files with 10 additions and 10 deletions

View File

@@ -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;

View File

@@ -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"));

View File

@@ -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) {

View File

@@ -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.*"

View File

@@ -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("""