From d657d89ed10535acf41f0a93073dd9a10bc914b7 Mon Sep 17 00:00:00 2001 From: Georgii Ustinov Date: Thu, 16 Nov 2023 12:28:33 +0200 Subject: [PATCH] [Java. Formatting] Add field in settings for moving semicolon to the newline in long call chains IDEA-291765 GitOrigin-RevId: 916e53119ab293a78a56be3c13c7a62fbb8cbbf6 --- .../ide/JavaLanguageCodeStyleSettingsProvider.java | 5 +++++ .../intellij/psi/codeStyle/JavaCodeStyleSettings.java | 11 +++++++++++ java/openapi/resources/messages/JavaBundle.properties | 1 + 3 files changed, 17 insertions(+) diff --git a/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java b/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java index fb3f5421c356..49966399cc59 100644 --- a/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java +++ b/java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java @@ -197,6 +197,11 @@ public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSett "BUILDER_METHODS", "KEEP_BUILDER_METHODS_INDENTS"); + consumer.showCustomOption(JavaCodeStyleSettings.class, + "WRAP_SEMICOLON_AFTER_CALL_CHAIN", + JavaBundle.message("wrapping.semicolon.after.call.chain"), + getInstance().WRAPPING_CALL_CHAIN); + consumer.showCustomOption(JavaCodeStyleSettings.class, "ANNOTATION_PARAMETER_WRAP", JavaBundle.message("wrapping.annotation.parameters"), diff --git a/java/java-impl/src/com/intellij/psi/codeStyle/JavaCodeStyleSettings.java b/java/java-impl/src/com/intellij/psi/codeStyle/JavaCodeStyleSettings.java index ca3338e9a0df..c9038c8b3969 100644 --- a/java/java-impl/src/com/intellij/psi/codeStyle/JavaCodeStyleSettings.java +++ b/java/java-impl/src/com/intellij/psi/codeStyle/JavaCodeStyleSettings.java @@ -144,6 +144,17 @@ public class JavaCodeStyleSettings extends CustomCodeStyleSettings implements Im public PackageEntryTable IMPORT_LAYOUT_TABLE = new PackageEntryTable(); + /** + *
+   * builder.add()
+   *        .sub()
+   *        .multiply()
+   * ;
+   * ^
+   * 
+ */ + public boolean WRAP_SEMICOLON_AFTER_CALL_CHAIN = false; + @WrapConstant public int RECORD_COMPONENTS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED; public boolean ALIGN_MULTILINE_RECORDS = true; diff --git a/java/openapi/resources/messages/JavaBundle.properties b/java/openapi/resources/messages/JavaBundle.properties index 80aef144170e..dfbadc1387fb 100644 --- a/java/openapi/resources/messages/JavaBundle.properties +++ b/java/openapi/resources/messages/JavaBundle.properties @@ -1312,6 +1312,7 @@ wrapping.deconstruction.patterns=Deconstruction patterns align.types.in.multi.catch=Align types in multi-catch wrapping.text.blocks=Text blocks wrapping.switch.statement.or.expression='switch' statement/expression +wrapping.semicolon.after.call.chain=Move ';' to the new line wrong.package.statement=Wrong package statement title.code.vision=Code vision title.code.vision.inlay.hints=Code Vision