From cb3c8df1715cf6ede580edf979ce6db48524ec8b Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Wed, 10 Jun 2026 16:13:21 +0200 Subject: [PATCH] IDEA-378172 [java]: put elements on separate lines for annotations and array initializers GitOrigin-RevId: 5278e8f5a9bcc8ec6bb88a897c414242a9f19048 --- .../resources/META-INF/JavaPlugin.xml | 4 ++ .../impl/lists/JavaListSplitJoinContexts.kt | 11 ++-- ...aSplitJoinAnnotationAttributesContext.java | 62 +++++++++++++++++++ .../JavaSplitJoinArrayInitializerContext.java | 49 +++++++++++++++ .../afterJoinAnnotationAttributes.java | 11 ++++ .../afterJoinArrayElements.java | 8 +++ .../afterJoinArrayInitializer.java | 6 ++ .../afterSplitAnnotationAttributes.java | 13 ++++ .../afterSplitAnnotationAttributesBreak.java | 15 +++++ .../afterSplitArrayElements.java | 9 +++ .../afterSplitArrayElementsBreak.java | 11 ++++ .../afterSplitArrayInitializer.java | 8 +++ .../afterSplitArrayInitializer2.java | 8 +++ .../afterSplitArrayInitializerBreak.java | 10 +++ .../beforeJoinAnnotationAttributes.java | 15 +++++ .../beforeJoinArrayElements.java | 11 ++++ .../beforeJoinArrayInitializer.java | 8 +++ .../beforeSplitAnnotationAttributes.java | 11 ++++ .../beforeSplitAnnotationAttributesBreak.java | 11 ++++ .../beforeSplitArrayElements.java | 8 +++ .../beforeSplitArrayElementsBreak.java | 8 +++ .../beforeSplitArrayInitializer.java | 6 ++ .../beforeSplitArrayInitializer2.java | 6 ++ .../beforeSplitArrayInitializerBreak.java | 6 ++ .../resources/messages/JavaBundle.properties | 4 ++ 25 files changed, 313 insertions(+), 6 deletions(-) create mode 100644 java/java-impl/src/com/intellij/codeInsight/intention/impl/lists/JavaSplitJoinAnnotationAttributesContext.java create mode 100644 java/java-impl/src/com/intellij/codeInsight/intention/impl/lists/JavaSplitJoinArrayInitializerContext.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterJoinAnnotationAttributes.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterJoinArrayElements.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterJoinArrayInitializer.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitAnnotationAttributes.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitAnnotationAttributesBreak.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayElements.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayElementsBreak.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayInitializer.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayInitializer2.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayInitializerBreak.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeJoinAnnotationAttributes.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeJoinArrayElements.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeJoinArrayInitializer.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitAnnotationAttributes.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitAnnotationAttributesBreak.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayElements.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayElementsBreak.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayInitializer.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayInitializer2.java create mode 100644 java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayInitializerBreak.java diff --git a/java/java-backend/resources/META-INF/JavaPlugin.xml b/java/java-backend/resources/META-INF/JavaPlugin.xml index 504db5f86771..192909d6f609 100644 --- a/java/java-backend/resources/META-INF/JavaPlugin.xml +++ b/java/java-backend/resources/META-INF/JavaPlugin.xml @@ -944,6 +944,10 @@ implementationClass="com.intellij.codeInsight.intention.impl.lists.JavaSplitJoinParametersContext"/> + + diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/lists/JavaListSplitJoinContexts.kt b/java/java-impl/src/com/intellij/codeInsight/intention/impl/lists/JavaListSplitJoinContexts.kt index 71e38ae99923..3e8498f3b467 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/lists/JavaListSplitJoinContexts.kt +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/lists/JavaListSplitJoinContexts.kt @@ -1,4 +1,4 @@ -// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package com.intellij.codeInsight.intention.impl.lists import com.intellij.application.options.CodeStyle @@ -18,15 +18,14 @@ import com.intellij.psi.PsiParameterList import com.intellij.psi.PsiRecordHeader import com.intellij.psi.util.PsiTreeUtil - -public abstract class AbstractJavaSplitJoinContext : CommaListSplitJoinContext() { +internal abstract class AbstractJavaSplitJoinContext : CommaListSplitJoinContext() { override fun isValidIntermediateElement(data: ListWithElements, element: PsiElement): Boolean { return super.isValidIntermediateElement(data, element) || element is PsiComment && element.tokenType === JavaTokenType.C_STYLE_COMMENT } } -public class JavaSplitJoinArgumentsContext : AbstractJavaSplitJoinContext() { +internal class JavaSplitJoinArgumentsContext : AbstractJavaSplitJoinContext() { override fun extractData(context: PsiElement): ListWithElements? = getCallArgumentsList(context)?.let { ListWithElements(it, it.expressions.asList()) } @@ -51,7 +50,7 @@ public class JavaSplitJoinArgumentsContext : AbstractJavaSplitJoinContext() { override fun getSplitText(data: ListWithElements): String = JavaBundle.message("intention.family.put.arguments.on.separate.lines") } -public class JavaSplitJoinParametersContext : AbstractJavaSplitJoinContext() { +internal class JavaSplitJoinParametersContext : AbstractJavaSplitJoinContext() { override fun extractData(context: PsiElement): ListWithElements? = PsiTreeUtil.getParentOfType(context, PsiParameterList::class.java, false)?.let { ListWithElements(it, it.parameters.toList()) } @@ -65,7 +64,7 @@ public class JavaSplitJoinParametersContext : AbstractJavaSplitJoinContext() { override fun getJoinText(data: ListWithElements): String = JavaBundle.message("intention.family.put.parameters.on.one.line") } -public class JavaSplitJoinRecordComponentsContext : AbstractJavaSplitJoinContext() { +internal class JavaSplitJoinRecordComponentsContext : AbstractJavaSplitJoinContext() { override fun extractData(context: PsiElement): ListWithElements? = PsiTreeUtil.getParentOfType(context, PsiRecordHeader::class.java, false, PsiCodeBlock::class.java, PsiExpression::class.java) ?.let { ListWithElements(it, it.recordComponents.toList()) } diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/lists/JavaSplitJoinAnnotationAttributesContext.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/lists/JavaSplitJoinAnnotationAttributesContext.java new file mode 100644 index 000000000000..d12c926aaebb --- /dev/null +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/lists/JavaSplitJoinAnnotationAttributesContext.java @@ -0,0 +1,62 @@ +// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.codeInsight.intention.impl.lists; + +import com.intellij.application.options.CodeStyle; +import com.intellij.java.JavaBundle; +import com.intellij.lang.java.JavaLanguage; +import com.intellij.openapi.editor.actions.lists.JoinOrSplit; +import com.intellij.openapi.editor.actions.lists.ListWithElements; +import com.intellij.psi.PsiAnnotationParameterList; +import com.intellij.psi.PsiArrayInitializerMemberValue; +import com.intellij.psi.PsiElement; +import com.intellij.psi.codeStyle.JavaCodeStyleSettings; +import com.intellij.psi.util.PsiTreeUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +/** + * @author Bas Leijdekkers + */ +final class JavaSplitJoinAnnotationAttributesContext extends AbstractJavaSplitJoinContext { + @Override + public @Nullable ListWithElements extractData(@NotNull PsiElement context) { + PsiElement parent = PsiTreeUtil.getParentOfType(context, PsiAnnotationParameterList.class, PsiArrayInitializerMemberValue.class); + return switch (parent) { + case PsiAnnotationParameterList list -> new ListWithElements(parent, List.of(list.getAttributes())); + case PsiArrayInitializerMemberValue value -> new ListWithElements(parent, List.of(value.getInitializers())); + case null, default -> null; + }; + } + + @Override + public boolean needHeadBreak(@NotNull ListWithElements data, @NotNull PsiElement firstElement, @NotNull JoinOrSplit mode) { + if (mode == JoinOrSplit.JOIN) return false; + return data.getList() instanceof PsiArrayInitializerMemberValue + ? CodeStyle.getLanguageSettings(firstElement.getContainingFile(), JavaLanguage.INSTANCE).ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE + : CodeStyle.getCustomSettings(firstElement.getContainingFile(), JavaCodeStyleSettings.class).NEW_LINE_AFTER_LPAREN_IN_ANNOTATION; + } + + @Override + public boolean needTailBreak(@NotNull ListWithElements data, @NotNull PsiElement lastElement, @NotNull JoinOrSplit mode) { + if (mode == JoinOrSplit.JOIN) return false; + return data.getList() instanceof PsiArrayInitializerMemberValue + ? CodeStyle.getLanguageSettings(lastElement.getContainingFile(), JavaLanguage.INSTANCE).ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE + : CodeStyle.getCustomSettings(lastElement.getContainingFile(), JavaCodeStyleSettings.class).RPAREN_ON_NEW_LINE_IN_ANNOTATION; + } + + @Override + public @NotNull String getJoinText(@NotNull ListWithElements data) { + return data.getList() instanceof PsiArrayInitializerMemberValue + ? JavaBundle.message("intention.family.put.array.initializer.expressions.on.one.line") + : JavaBundle.message("intention.family.put.annotation.attributes.on.one.line"); + } + + @Override + public @NotNull String getSplitText(@NotNull ListWithElements data) { + return data.getList() instanceof PsiArrayInitializerMemberValue + ? JavaBundle.message("intention.family.put.array.initializer.expressions.on.separate.lines") + : JavaBundle.message("intention.family.put.annotation.attributes.on.separate.lines"); + } +} diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/lists/JavaSplitJoinArrayInitializerContext.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/lists/JavaSplitJoinArrayInitializerContext.java new file mode 100644 index 000000000000..d63778f8383c --- /dev/null +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/lists/JavaSplitJoinArrayInitializerContext.java @@ -0,0 +1,49 @@ +// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.codeInsight.intention.impl.lists; + +import com.intellij.application.options.CodeStyle; +import com.intellij.java.JavaBundle; +import com.intellij.lang.java.JavaLanguage; +import com.intellij.openapi.editor.actions.lists.JoinOrSplit; +import com.intellij.openapi.editor.actions.lists.ListWithElements; +import com.intellij.psi.PsiArrayInitializerExpression; +import com.intellij.psi.PsiElement; +import com.intellij.psi.util.PsiTreeUtil; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +/** + * @author Bas Leijdekkers + */ +final class JavaSplitJoinArrayInitializerContext extends AbstractJavaSplitJoinContext { + + @Override + public @Nullable ListWithElements extractData(@NotNull PsiElement context) { + PsiArrayInitializerExpression expression = PsiTreeUtil.getParentOfType(context, PsiArrayInitializerExpression.class, false); + return expression == null ? null : new ListWithElements(expression, List.of(expression.getInitializers())); + } + + @Override + public boolean needHeadBreak(@NotNull ListWithElements data, @NotNull PsiElement firstElement, @NotNull JoinOrSplit mode) { + return mode == JoinOrSplit.SPLIT && + CodeStyle.getLanguageSettings(firstElement.getContainingFile(), JavaLanguage.INSTANCE).ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE; + } + + @Override + public boolean needTailBreak(@NotNull ListWithElements data, @NotNull PsiElement lastElement, @NotNull JoinOrSplit mode) { + return mode == JoinOrSplit.SPLIT && + CodeStyle.getLanguageSettings(lastElement.getContainingFile(), JavaLanguage.INSTANCE).ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE; + } + + @Override + public @NotNull String getSplitText(@NotNull ListWithElements data) { + return JavaBundle.message("intention.family.put.array.initializer.expressions.on.separate.lines"); + } + + @Override + public @NotNull String getJoinText(@NotNull ListWithElements data) { + return JavaBundle.message("intention.family.put.array.initializer.expressions.on.one.line"); + } +} diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterJoinAnnotationAttributes.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterJoinAnnotationAttributes.java new file mode 100644 index 000000000000..92690ec1a6c9 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterJoinAnnotationAttributes.java @@ -0,0 +1,11 @@ +// "Put annotation attributes on one line" "true-preview" + + +class X { + + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Success response", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON, schema = @Schema(implementation = Procedure.class, type = "array"))), + @ApiResponse(responseCode = "400", description = "Bad request", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON)) + }) + void x() {} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterJoinArrayElements.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterJoinArrayElements.java new file mode 100644 index 000000000000..077404dc0005 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterJoinArrayElements.java @@ -0,0 +1,8 @@ +// "Put array elements on one line" "true-preview" + + +class X { + + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Success response", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON, schema = @Schema(implementation = Procedure.class, type = "array"))), @ApiResponse(responseCode = "400", description = "Bad request", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON))}) + void x() {} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterJoinArrayInitializer.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterJoinArrayInitializer.java new file mode 100644 index 000000000000..54d688b84cc5 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterJoinArrayInitializer.java @@ -0,0 +1,6 @@ +// "Put array elements on one line" "true-preview" + +class X { + + String[] ss = new String[] {"one", "two", "three"}; +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitAnnotationAttributes.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitAnnotationAttributes.java new file mode 100644 index 000000000000..8aee6cf75a35 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitAnnotationAttributes.java @@ -0,0 +1,13 @@ +// "Put annotation attributes on separate lines" "true-preview" + + +class X { + + @ApiResponses(value = { + @ApiResponse(responseCode = "200", + description = "Success response", + content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON, schema = @Schema(implementation = Procedure.class, type = "array"))), + @ApiResponse(responseCode = "400", description = "Bad request", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON)) + }) + void x() {} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitAnnotationAttributesBreak.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitAnnotationAttributesBreak.java new file mode 100644 index 000000000000..170c8c522fd0 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitAnnotationAttributesBreak.java @@ -0,0 +1,15 @@ +// "Put annotation attributes on separate lines" "true-preview" + + +class X { + + @ApiResponses(value = { + @ApiResponse( + responseCode = "200", + description = "Success response", + content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON, schema = @Schema(implementation = Procedure.class, type = "array")) + ), + @ApiResponse(responseCode = "400", description = "Bad request", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON)) + }) + void x() {} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayElements.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayElements.java new file mode 100644 index 000000000000..0557e03fba11 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayElements.java @@ -0,0 +1,9 @@ +// "Put array elements on separate lines" "true-preview" + + +class X { + + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Success response", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON, schema = @Schema(implementation = Procedure.class, type = "array"))), + @ApiResponse(responseCode = "400", description = "Bad request", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON))}) + void x() {} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayElementsBreak.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayElementsBreak.java new file mode 100644 index 000000000000..9e45d6e7ce10 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayElementsBreak.java @@ -0,0 +1,11 @@ +// "Put array elements on separate lines" "true-preview" + + +class X { + + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Success response", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON, schema = @Schema(implementation = Procedure.class, type = "array"))), + @ApiResponse(responseCode = "400", description = "Bad request", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON)) + }) + void x() {} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayInitializer.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayInitializer.java new file mode 100644 index 000000000000..0f9dd96e6e08 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayInitializer.java @@ -0,0 +1,8 @@ +// "Put array elements on separate lines" "true-preview" + +class X { + + String[] ss = new String[] {"one", + "two", + "three"}; +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayInitializer2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayInitializer2.java new file mode 100644 index 000000000000..14afe347ed97 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayInitializer2.java @@ -0,0 +1,8 @@ +// "Put array elements on separate lines" "true-preview" + +class X { + + String[] ss = {"one", + "two", + "three"}; +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayInitializerBreak.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayInitializerBreak.java new file mode 100644 index 000000000000..eb7920eb2de4 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/afterSplitArrayInitializerBreak.java @@ -0,0 +1,10 @@ +// "Put array elements on separate lines" "true-preview" + +class X { + + String[] ss = new String[] { + "one", + "two", + "three" + }; +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeJoinAnnotationAttributes.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeJoinAnnotationAttributes.java new file mode 100644 index 000000000000..c2b900c1c195 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeJoinAnnotationAttributes.java @@ -0,0 +1,15 @@ +// "Put annotation attributes on one line" "true-preview" + + +class X { + + @ApiResponses(value = { + @ApiResponse( + responseCode = "200", + description = "Success response", + content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON, schema = @Schema(implementation = Procedure.class, type = "array")) + ), + @ApiResponse(responseCode = "400", description = "Bad request", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON)) + }) + void x() {} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeJoinArrayElements.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeJoinArrayElements.java new file mode 100644 index 000000000000..f665722f8a76 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeJoinArrayElements.java @@ -0,0 +1,11 @@ +// "Put array elements on one line" "true-preview" + + +class X { + + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Success response", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON, schema = @Schema(implementation = Procedure.class, type = "array"))), + @ApiResponse(responseCode = "400", description = "Bad request", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON)) + }) + void x() {} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeJoinArrayInitializer.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeJoinArrayInitializer.java new file mode 100644 index 000000000000..1be2ab7a7a72 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeJoinArrayInitializer.java @@ -0,0 +1,8 @@ +// "Put array elements on one line" "true-preview" + +class X { + + String[] ss = new String[] {"one", + "two", + "three"}; +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitAnnotationAttributes.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitAnnotationAttributes.java new file mode 100644 index 000000000000..4824f8ec6a4f --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitAnnotationAttributes.java @@ -0,0 +1,11 @@ +// "Put annotation attributes on separate lines" "true-preview" + + +class X { + + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Success response", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON, schema = @Schema(implementation = Procedure.class, type = "array"))), + @ApiResponse(responseCode = "400", description = "Bad request", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON)) + }) + void x() {} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitAnnotationAttributesBreak.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitAnnotationAttributesBreak.java new file mode 100644 index 000000000000..4824f8ec6a4f --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitAnnotationAttributesBreak.java @@ -0,0 +1,11 @@ +// "Put annotation attributes on separate lines" "true-preview" + + +class X { + + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = "Success response", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON, schema = @Schema(implementation = Procedure.class, type = "array"))), + @ApiResponse(responseCode = "400", description = "Bad request", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON)) + }) + void x() {} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayElements.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayElements.java new file mode 100644 index 000000000000..3b4e87d01542 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayElements.java @@ -0,0 +1,8 @@ +// "Put array elements on separate lines" "true-preview" + + +class X { + + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Success response", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON, schema = @Schema(implementation = Procedure.class, type = "array"))), @ApiResponse(responseCode = "400", description = "Bad request", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON))}) + void x() {} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayElementsBreak.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayElementsBreak.java new file mode 100644 index 000000000000..3b4e87d01542 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayElementsBreak.java @@ -0,0 +1,8 @@ +// "Put array elements on separate lines" "true-preview" + + +class X { + + @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Success response", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON, schema = @Schema(implementation = Procedure.class, type = "array"))), @ApiResponse(responseCode = "400", description = "Bad request", content = @Content(mediaType = PageAttributes.MediaType.APPLICATION_JSON))}) + void x() {} +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayInitializer.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayInitializer.java new file mode 100644 index 000000000000..ac01e1c41e93 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayInitializer.java @@ -0,0 +1,6 @@ +// "Put array elements on separate lines" "true-preview" + +class X { + + String[] ss = new String[] {"one", "two", "three"}; +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayInitializer2.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayInitializer2.java new file mode 100644 index 000000000000..de977a854e51 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayInitializer2.java @@ -0,0 +1,6 @@ +// "Put array elements on separate lines" "true-preview" + +class X { + + String[] ss = {"one", "two", "three"}; +} \ No newline at end of file diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayInitializerBreak.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayInitializerBreak.java new file mode 100644 index 000000000000..ac01e1c41e93 --- /dev/null +++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/splitJoinLines/beforeSplitArrayInitializerBreak.java @@ -0,0 +1,6 @@ +// "Put array elements on separate lines" "true-preview" + +class X { + + String[] ss = new String[] {"one", "two", "three"}; +} \ No newline at end of file diff --git a/java/openapi/resources/messages/JavaBundle.properties b/java/openapi/resources/messages/JavaBundle.properties index 602efda841cd..d2f074b16632 100644 --- a/java/openapi/resources/messages/JavaBundle.properties +++ b/java/openapi/resources/messages/JavaBundle.properties @@ -877,6 +877,10 @@ intention.family.put.parameters.on.one.line=Put parameters on one line intention.family.put.parameters.on.separate.lines=Put parameters on separate lines intention.family.put.record.components.on.one.line=Put record components on one line intention.family.put.record.components.on.separate.lines=Put record components on separate lines +intention.family.put.array.initializer.expressions.on.one.line=Put array elements on one line +intention.family.put.array.initializer.expressions.on.separate.lines=Put array elements on separate lines +intention.family.put.annotation.attributes.on.one.line=Put annotation attributes on one line +intention.family.put.annotation.attributes.on.separate.lines=Put annotation attributes on separate lines intention.family.replace.optional.ispresent.condition.with.functional.style.expression=Replace Optional presence condition with functional style expression intention.family.sort.content=Sort content intention.family.swap.if.statements=Swap 'if' statements