diff --git a/python/python-syntax/resources/messages/PySyntaxBundle.properties b/python/python-syntax/resources/messages/PySyntaxBundle.properties index f5ed4527eb8a..5ae37a0f6379 100644 --- a/python/python-syntax/resources/messages/PySyntaxBundle.properties +++ b/python/python-syntax/resources/messages/PySyntaxBundle.properties @@ -42,10 +42,10 @@ formatter.panel.injected.fragments=Injected fragments: formatter.panel.format.injected.fragments=Format injected fragments formatter.panel.injected.fragments.use.continuation.indent=Add indent -formatter.panel.use.continuation.indent.for.title=Use continuation indent for -formatter.panel.use.continuation.indent.for.parameters=Method declaration parameters -formatter.panel.use.continuation.indent.for.arguments=Method call arguments -formatter.panel.use.continuation.indent.for.collection.literals=Collections and comprehensions +formatter.use.continuation.indent=Use continuation indent +formatter.function.declaration.parameters=Function declaration parameters +formatter.function.call.arguments=Function call arguments + configurable.PyLanguageCodeStyleSettingsProvider.display.name=Python formatter.force.trailing.comma.if.multiline=Force trailing comma if multiline diff --git a/python/python-syntax/src/com/jetbrains/python/formatter/PyLanguageCodeStyleSettingsProvider.java b/python/python-syntax/src/com/jetbrains/python/formatter/PyLanguageCodeStyleSettingsProvider.java index e79514191e6b..d040430b1de1 100644 --- a/python/python-syntax/src/com/jetbrains/python/formatter/PyLanguageCodeStyleSettingsProvider.java +++ b/python/python-syntax/src/com/jetbrains/python/formatter/PyLanguageCodeStyleSettingsProvider.java @@ -108,6 +108,9 @@ public final class PyLanguageCodeStyleSettingsProvider extends LanguageCodeStyle "METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE", "ALIGN_MULTILINE_PARAMETERS_IN_CALLS"); + consumer.renameStandardOption("METHOD_PARAMETERS_WRAP", PySyntaxBundle.message("formatter.function.declaration.parameters")); + consumer.renameStandardOption("CALL_PARAMETERS_WRAP", PySyntaxBundle.message("formatter.function.call.arguments")); + consumer.showCustomOption(PyCodeStyleSettings.class, "USE_TRAILING_COMMA_IN_ARGUMENTS_LIST", PySyntaxBundle.message("formatter.force.trailing.comma.if.multiline"), @@ -118,6 +121,18 @@ public final class PyLanguageCodeStyleSettingsProvider extends LanguageCodeStyle PySyntaxBundle.message("formatter.force.trailing.comma.if.multiline"), ApplicationBundle.message("wrapping.method.parameters")); + // "Use continuation indent" checkboxes + consumer.showCustomOption(PyCodeStyleSettings.class, "USE_CONTINUATION_INDENT_FOR_PARAMETERS", + PySyntaxBundle.message("formatter.use.continuation.indent"), + getInstance().WRAPPING_METHOD_PARAMETERS); + consumer.showCustomOption(PyCodeStyleSettings.class, "USE_CONTINUATION_INDENT_FOR_ARGUMENTS", + PySyntaxBundle.message("formatter.use.continuation.indent"), + getInstance().WRAPPING_METHOD_ARGUMENTS_WRAPPING); + consumer.showCustomOption(PyCodeStyleSettings.class, "USE_CONTINUATION_INDENT_FOR_COLLECTION_AND_COMPREHENSIONS", + PySyntaxBundle.message("formatter.use.continuation.indent"), + PySyntaxBundle.message("formatter.collections.and.comprehensions")); + + consumer.showCustomOption(PyCodeStyleSettings.class, "NEW_LINE_AFTER_COLON", PySyntaxBundle.message("formatter.single.clause.statements"), PySyntaxBundle.message("formatter.force.new.line.after.colon")); diff --git a/python/python-syntax/src/com/jetbrains/python/formatter/PyOtherCodeStylePanel.form b/python/python-syntax/src/com/jetbrains/python/formatter/PyOtherCodeStylePanel.form index aafa891f1f65..9b2913a1e754 100644 --- a/python/python-syntax/src/com/jetbrains/python/formatter/PyOtherCodeStylePanel.form +++ b/python/python-syntax/src/com/jetbrains/python/formatter/PyOtherCodeStylePanel.form @@ -55,43 +55,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/python/python-syntax/src/com/jetbrains/python/formatter/PyOtherCodeStylePanel.java b/python/python-syntax/src/com/jetbrains/python/formatter/PyOtherCodeStylePanel.java index bfe54cc1b66b..f455f7774e3e 100644 --- a/python/python-syntax/src/com/jetbrains/python/formatter/PyOtherCodeStylePanel.java +++ b/python/python-syntax/src/com/jetbrains/python/formatter/PyOtherCodeStylePanel.java @@ -44,9 +44,6 @@ public class PyOtherCodeStylePanel extends CodeStyleAbstractPanel { private final JPanel myPanel; private final JBCheckBox myAddTrailingBlankLineCheckbox; - private final JBCheckBox myUseContinuationIndentForParameters; - private final JBCheckBox myUseContinuationIndentForArguments; - private final JBCheckBox myUseContinuationIndentForCollectionsAndComprehensions; private final ComboBox myDictAlignmentCombo; private final JPanel myPreviewPanel; private final JBCheckBox myFormatInjectedFragments; @@ -92,37 +89,6 @@ public class PyOtherCodeStylePanel extends CodeStyleAbstractPanel { panel1.add(myDictAlignmentCombo, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - final JPanel panel2 = new JPanel(); - panel2.setLayout(new GridLayoutManager(3, 2, new Insets(0, 0, 0, 0), -1, -1)); - panel2.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); - panel1.add(panel2, new GridConstraints(1, 0, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, - GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, - GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, - 0, false)); - panel2.setBorder(IdeBorderFactory.PlainSmallWithIndent.createTitledBorder(BorderFactory.createEtchedBorder(), - this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", - "formatter.panel.use.continuation.indent.for.title"), - TitledBorder.DEFAULT_JUSTIFICATION, - TitledBorder.DEFAULT_POSITION, null, null)); - myUseContinuationIndentForArguments = new JBCheckBox(); - this.$$$loadButtonText$$$(myUseContinuationIndentForArguments, this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", - "formatter.panel.use.continuation.indent.for.arguments")); - panel2.add(myUseContinuationIndentForArguments, - new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, - GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - myUseContinuationIndentForParameters = new JBCheckBox(); - this.$$$loadButtonText$$$(myUseContinuationIndentForParameters, this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", - "formatter.panel.use.continuation.indent.for.parameters")); - panel2.add(myUseContinuationIndentForParameters, - new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, - GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); - myUseContinuationIndentForCollectionsAndComprehensions = new JBCheckBox(); - this.$$$loadButtonText$$$(myUseContinuationIndentForCollectionsAndComprehensions, - this.$$$getMessageFromBundle$$$("messages/PySyntaxBundle", - "formatter.panel.use.continuation.indent.for.collection.literals")); - panel2.add(myUseContinuationIndentForCollectionsAndComprehensions, - new GridConstraints(2, 0, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, - GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JPanel panel3 = new JPanel(); panel3.setLayout(new GridLayoutManager(2, 1, new Insets(0, 0, 0, 0), -1, -1)); panel3.putClientProperty("BorderFactoryClass", "com.intellij.ui.IdeBorderFactory$PlainSmallWithIndent"); @@ -169,20 +135,6 @@ public class PyOtherCodeStylePanel extends CodeStyleAbstractPanel { } }); - myUseContinuationIndentForParameters.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - somethingChanged(); - } - }); - - myUseContinuationIndentForArguments.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - somethingChanged(); - } - }); - myFormatInjectedFragments.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { @@ -324,10 +276,6 @@ public class PyOtherCodeStylePanel extends CodeStyleAbstractPanel { } } myAddTrailingBlankLineCheckbox.setSelected(pySettings.BLANK_LINE_AT_FILE_END); - myUseContinuationIndentForParameters.setSelected(pySettings.USE_CONTINUATION_INDENT_FOR_PARAMETERS); - myUseContinuationIndentForArguments.setSelected(pySettings.USE_CONTINUATION_INDENT_FOR_ARGUMENTS); - myUseContinuationIndentForCollectionsAndComprehensions.setSelected( - pySettings.USE_CONTINUATION_INDENT_FOR_COLLECTION_AND_COMPREHENSIONS); myFormatInjectedFragments.setSelected(pySettings.FORMAT_INJECTED_FRAGMENTS); myAddIndentInsideInjections.setSelected(pySettings.ADD_INDENT_INSIDE_INJECTIONS); } @@ -337,9 +285,6 @@ public class PyOtherCodeStylePanel extends CodeStyleAbstractPanel { final PyCodeStyleSettings customSettings = getCustomSettings(settings); customSettings.DICT_ALIGNMENT = getDictAlignmentAsInt(); customSettings.BLANK_LINE_AT_FILE_END = ensureTrailingBlankLine(); - customSettings.USE_CONTINUATION_INDENT_FOR_PARAMETERS = useContinuationIndentForParameters(); - customSettings.USE_CONTINUATION_INDENT_FOR_ARGUMENTS = useContinuationIndentForArguments(); - customSettings.USE_CONTINUATION_INDENT_FOR_COLLECTION_AND_COMPREHENSIONS = useContinuationIndentForCollectionLiterals(); customSettings.FORMAT_INJECTED_FRAGMENTS = formatInjectedFragments(); customSettings.ADD_INDENT_INSIDE_INJECTIONS = addIndentInsideInjections(); } @@ -349,9 +294,6 @@ public class PyOtherCodeStylePanel extends CodeStyleAbstractPanel { final PyCodeStyleSettings customSettings = getCustomSettings(settings); return customSettings.DICT_ALIGNMENT != getDictAlignmentAsInt() || customSettings.BLANK_LINE_AT_FILE_END != ensureTrailingBlankLine() || - customSettings.USE_CONTINUATION_INDENT_FOR_PARAMETERS != useContinuationIndentForParameters() || - customSettings.USE_CONTINUATION_INDENT_FOR_ARGUMENTS != useContinuationIndentForArguments() || - customSettings.USE_CONTINUATION_INDENT_FOR_COLLECTION_AND_COMPREHENSIONS != useContinuationIndentForCollectionLiterals() || customSettings.FORMAT_INJECTED_FRAGMENTS != formatInjectedFragments() || customSettings.ADD_INDENT_INSIDE_INJECTIONS != addIndentInsideInjections(); } @@ -373,14 +315,6 @@ public class PyOtherCodeStylePanel extends CodeStyleAbstractPanel { return myAddTrailingBlankLineCheckbox.isSelected(); } - private boolean useContinuationIndentForParameters() { - return myUseContinuationIndentForParameters.isSelected(); - } - - private boolean useContinuationIndentForArguments() { - return myUseContinuationIndentForArguments.isSelected(); - } - private boolean formatInjectedFragments() { return myFormatInjectedFragments.isSelected(); } @@ -389,10 +323,6 @@ public class PyOtherCodeStylePanel extends CodeStyleAbstractPanel { return myAddIndentInsideInjections.isSelected(); } - protected boolean useContinuationIndentForCollectionLiterals() { - return myUseContinuationIndentForCollectionsAndComprehensions.isSelected(); - } - public static final String PREVIEW = """ x = max( 1,