PY-61639 Move PyLanguageCodeStyleSettingsProvider to python.syntax

GitOrigin-RevId: 547f75fe15a4164ee317fe16b693233ca620a558
This commit is contained in:
Petr
2024-02-06 17:51:07 +01:00
committed by intellij-monorepo-bot
parent ff4e0c707d
commit da4a4b066b
12 changed files with 93 additions and 64 deletions

View File

@@ -575,7 +575,6 @@ windowWithActions.closeWindow=Close window
# "Stop" button title
windowWithActions.stopProcess=Stop currently running process
formatter.imports.panel.title=Imports
formatter.imports.panel.optimize.imports=Optimize Imports
formatter.imports.panel.sort.imports=Sort import statements
formatter.imports.panel.sort.names.in.from.imports=Sort imported names in "from" imports
@@ -594,30 +593,6 @@ formatter.panel.use.continuation.indent.for.parameters=Method declaration parame
formatter.panel.use.continuation.indent.for.arguments=Method call arguments
formatter.panel.use.continuation.indent.for.collection.literals=Collections and comprehensions
formatter.left.bracket = Left bracket
formatter.around.eq.in.named.parameter = Around = in named parameter
formatter.around.eq.in.keyword.argument = Around = in keyword argument
formatter.braces = Braces
formatter.before.backslash = Before '\\'
formatter.before.hash = Before '#'
formatter.after.hash = After '#'
formatter.around.top.level.imports = After top-level imports:
formatter.after.local.imports=After local imports:
formatter.before.first.method=Before the first method:
formatter.around.top.level.classes.and.function=Around top-level classes and functions:
formatter.around.multiplicative.operators=Multiplicative operators (*, @, /, %)
formatter.around.power.operator=Power operator (**)
formatter.single.clause.statements=Single-clause statements
formatter.multi.clause.statements=Multi-clause statements
formatter.force.new.line.after.colon=Force new line after colon
formatter.align.when.multiline=Align when multiline
formatter.collections.and.comprehensions=Collections and Comprehensions
formatter.from.import.statements="From" Import Statements
formatter.from.import.statements.force.parentheses.if.multiline=Force parentheses if multiline
formatter.from.import.statements.force.comma.if.multline=Force trailing comma if multiline
formatter.dictionary.literals=Dictionary literals
formatter.hang.closing.brackets=Hang closing brackets
smartKeys.insert.self.in.method=Insert 'self' when defining a method
smartKeys.insert.type.placeholder.in.docstring.stub=Insert type placeholders in the documentation comment stub
smartKeys.wrap.in.parentheses.instead.of.backslash=Use parentheses instead of backslashes for breaking lines
@@ -671,7 +646,6 @@ configurable.PyIntegratedToolsModulesConfigurable.display.name=Python Integrated
configurable.PythonSdkEditorTab.display.name=Python SDK
configurable.PyDebuggerConfigurable.display.name=Python Debugger
configurable.PyActiveSdkModuleConfigurable.python.interpreter.display.name=Python Interpreter
configurable.PyLanguageCodeStyleSettingsProvider.display.name=Python
configurable.PyUserTypeRenderersConfigurable.display.name=Python Type Renderers
flask.name=Flask
settings.default.remote.interpreter=Default Python Remote Interpreter

View File

@@ -1,5 +1,6 @@
<idea-plugin>
<extensions defaultExtensionNs="com.intellij">
<enterHandlerDelegate implementation="com.jetbrains.python.editor.PythonEnterHandler"/>
<langCodeStyleSettingsProvider implementation="com.jetbrains.python.formatter.PyLanguageCodeStyleSettingsProvider"/>
</extensions>
</idea-plugin>

View File

@@ -0,0 +1,28 @@
formatter.imports.panel.title=Imports
formatter.left.bracket = Left bracket
formatter.around.eq.in.named.parameter = Around = in named parameter
formatter.around.eq.in.keyword.argument = Around = in keyword argument
formatter.braces = Braces
formatter.before.backslash = Before '\\'
formatter.before.hash = Before '#'
formatter.after.hash = After '#'
formatter.around.top.level.imports = After top-level imports:
formatter.after.local.imports=After local imports:
formatter.before.first.method=Before the first method:
formatter.around.top.level.classes.and.function=Around top-level classes and functions:
formatter.around.multiplicative.operators=Multiplicative operators (*, @, /, %)
formatter.around.power.operator=Power operator (**)
formatter.single.clause.statements=Single-clause statements
formatter.multi.clause.statements=Multi-clause statements
formatter.force.new.line.after.colon=Force new line after colon
formatter.align.when.multiline=Align when multiline
formatter.collections.and.comprehensions=Collections and Comprehensions
formatter.from.import.statements="From" Import Statements
formatter.from.import.statements.force.parentheses.if.multiline=Force parentheses if multiline
formatter.from.import.statements.force.comma.if.multline=Force trailing comma if multiline
formatter.dictionary.literals=Dictionary literals
formatter.hang.closing.brackets=Hang closing brackets
configurable.PyLanguageCodeStyleSettingsProvider.display.name=Python

View File

@@ -0,0 +1,28 @@
package com.jetbrains.python;
import com.intellij.DynamicBundle;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.PropertyKey;
import java.util.function.Supplier;
public class PySyntaxBundle extends DynamicBundle {
@NonNls private static final String BUNDLE = "messages.PySyntaxBundle";
public static final PySyntaxBundle INSTANCE = new PySyntaxBundle();
private PySyntaxBundle() {
super(BUNDLE);
}
@NotNull
public static @Nls String message(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) {
return INSTANCE.getMessage(key, params);
}
@NotNull
public static Supplier<@Nls String> messagePointer(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, Object @NotNull ... params) {
return INSTANCE.getLazyMessage(key, params);
}
}

View File

@@ -9,7 +9,7 @@ import com.intellij.openapi.util.NlsContexts.TabTitle;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.ui.components.JBCheckBox;
import com.intellij.ui.components.JBRadioButton;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.PySyntaxBundle;
import com.jetbrains.python.PythonFileType;
import com.jetbrains.python.PythonLanguage;
import org.jetbrains.annotations.NotNull;
@@ -44,7 +44,7 @@ public class PyImportsCodeStylePanel extends CodeStyleAbstractPanel {
@Override
protected @TabTitle @NotNull String getTabTitle() {
return PyBundle.message("formatter.imports.panel.title");
return PySyntaxBundle.message("formatter.imports.panel.title");
}
@NotNull

View File

@@ -8,7 +8,7 @@ import com.intellij.application.options.SmartIndentOptionsEditor;
import com.intellij.lang.Language;
import com.intellij.openapi.application.ApplicationBundle;
import com.intellij.psi.codeStyle.*;
import com.jetbrains.python.PyBundle;
import com.jetbrains.python.PySyntaxBundle;
import com.jetbrains.python.PythonLanguage;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -54,26 +54,26 @@ public final class PyLanguageCodeStyleSettingsProvider extends LanguageCodeStyle
"SPACE_BEFORE_COMMA",
"SPACE_BEFORE_SEMICOLON");
consumer.showCustomOption(PyCodeStyleSettings.class, "SPACE_BEFORE_LBRACKET",
PyBundle.message("formatter.left.bracket"), getInstance().SPACES_BEFORE_PARENTHESES);
PySyntaxBundle.message("formatter.left.bracket"), getInstance().SPACES_BEFORE_PARENTHESES);
consumer.showCustomOption(PyCodeStyleSettings.class, "SPACE_AROUND_POWER_OPERATOR",
PyBundle.message("formatter.around.power.operator"), getInstance().SPACES_AROUND_OPERATORS);
PySyntaxBundle.message("formatter.around.power.operator"), getInstance().SPACES_AROUND_OPERATORS);
consumer.showCustomOption(PyCodeStyleSettings.class, "SPACE_AROUND_EQ_IN_NAMED_PARAMETER",
PyBundle.message("formatter.around.eq.in.named.parameter"), getInstance().SPACES_AROUND_OPERATORS);
PySyntaxBundle.message("formatter.around.eq.in.named.parameter"), getInstance().SPACES_AROUND_OPERATORS);
consumer.showCustomOption(PyCodeStyleSettings.class, "SPACE_AROUND_EQ_IN_KEYWORD_ARGUMENT",
PyBundle.message("formatter.around.eq.in.keyword.argument"), getInstance().SPACES_AROUND_OPERATORS);
consumer.showCustomOption(PyCodeStyleSettings.class, "SPACE_WITHIN_BRACES", PyBundle.message("formatter.braces"),
PySyntaxBundle.message("formatter.around.eq.in.keyword.argument"), getInstance().SPACES_AROUND_OPERATORS);
consumer.showCustomOption(PyCodeStyleSettings.class, "SPACE_WITHIN_BRACES", PySyntaxBundle.message("formatter.braces"),
getInstance().SPACES_WITHIN);
consumer.showCustomOption(PyCodeStyleSettings.class, "SPACE_BEFORE_PY_COLON",
ApplicationBundle.message("checkbox.spaces.before.colon"), getInstance().SPACES_OTHER);
consumer.showCustomOption(PyCodeStyleSettings.class, "SPACE_AFTER_PY_COLON",
ApplicationBundle.message("checkbox.spaces.after.colon"), getInstance().SPACES_OTHER);
consumer.showCustomOption(PyCodeStyleSettings.class, "SPACE_BEFORE_BACKSLASH",
PyBundle.message("formatter.before.backslash"), getInstance().SPACES_OTHER);
PySyntaxBundle.message("formatter.before.backslash"), getInstance().SPACES_OTHER);
consumer.showCustomOption(PyCodeStyleSettings.class, "SPACE_BEFORE_NUMBER_SIGN",
PyBundle.message("formatter.before.hash"), getInstance().SPACES_OTHER);
PySyntaxBundle.message("formatter.before.hash"), getInstance().SPACES_OTHER);
consumer.showCustomOption(PyCodeStyleSettings.class, "SPACE_AFTER_NUMBER_SIGN",
PyBundle.message("formatter.after.hash"), getInstance().SPACES_OTHER);
consumer.renameStandardOption("SPACE_AROUND_MULTIPLICATIVE_OPERATORS", PyBundle.message("formatter.around.multiplicative.operators"));
PySyntaxBundle.message("formatter.after.hash"), getInstance().SPACES_OTHER);
consumer.renameStandardOption("SPACE_AROUND_MULTIPLICATIVE_OPERATORS", PySyntaxBundle.message("formatter.around.multiplicative.operators"));
}
else if (settingsType == SettingsType.BLANK_LINES_SETTINGS) {
consumer.showStandardOptions("BLANK_LINES_AROUND_CLASS",
@@ -81,14 +81,14 @@ public final class PyLanguageCodeStyleSettingsProvider extends LanguageCodeStyle
"BLANK_LINES_AFTER_IMPORTS",
"KEEP_BLANK_LINES_IN_DECLARATIONS",
"KEEP_BLANK_LINES_IN_CODE");
consumer.renameStandardOption("BLANK_LINES_AFTER_IMPORTS", PyBundle.message("formatter.around.top.level.imports"));
consumer.renameStandardOption("BLANK_LINES_AFTER_IMPORTS", PySyntaxBundle.message("formatter.around.top.level.imports"));
consumer.showCustomOption(PyCodeStyleSettings.class, "BLANK_LINES_AROUND_TOP_LEVEL_CLASSES_FUNCTIONS",
PyBundle.message("formatter.around.top.level.classes.and.function"), getInstance().BLANK_LINES);
PySyntaxBundle.message("formatter.around.top.level.classes.and.function"), getInstance().BLANK_LINES);
consumer.showCustomOption(PyCodeStyleSettings.class, "BLANK_LINES_AFTER_LOCAL_IMPORTS",
PyBundle.message("formatter.after.local.imports"), getInstance().BLANK_LINES);
PySyntaxBundle.message("formatter.after.local.imports"), getInstance().BLANK_LINES);
consumer.showCustomOption(PyCodeStyleSettings.class, "BLANK_LINES_BEFORE_FIRST_METHOD",
PyBundle.message("formatter.before.first.method"), getInstance().BLANK_LINES);
PySyntaxBundle.message("formatter.before.first.method"), getInstance().BLANK_LINES);
}
else if (settingsType == SettingsType.WRAPPING_AND_BRACES_SETTINGS) {
consumer.showStandardOptions("RIGHT_MARGIN",
@@ -104,43 +104,43 @@ public final class PyLanguageCodeStyleSettingsProvider extends LanguageCodeStyle
"METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE",
"ALIGN_MULTILINE_PARAMETERS_IN_CALLS");
consumer.showCustomOption(PyCodeStyleSettings.class, "NEW_LINE_AFTER_COLON",
PyBundle.message("formatter.single.clause.statements"),
PyBundle.message("formatter.force.new.line.after.colon"));
PySyntaxBundle.message("formatter.single.clause.statements"),
PySyntaxBundle.message("formatter.force.new.line.after.colon"));
consumer.showCustomOption(PyCodeStyleSettings.class, "NEW_LINE_AFTER_COLON_MULTI_CLAUSE",
PyBundle.message("formatter.multi.clause.statements"),
PyBundle.message("formatter.force.new.line.after.colon"));
PySyntaxBundle.message("formatter.multi.clause.statements"),
PySyntaxBundle.message("formatter.force.new.line.after.colon"));
consumer.showCustomOption(PyCodeStyleSettings.class, "ALIGN_COLLECTIONS_AND_COMPREHENSIONS",
PyBundle.message("formatter.align.when.multiline"),
PyBundle.message("formatter.collections.and.comprehensions"));
PySyntaxBundle.message("formatter.align.when.multiline"),
PySyntaxBundle.message("formatter.collections.and.comprehensions"));
consumer.showCustomOption(PyCodeStyleSettings.class, "FROM_IMPORT_WRAPPING",
PyBundle.message("formatter.from.import.statements"), null, getInstance().WRAP_OPTIONS, WRAP_VALUES);
PySyntaxBundle.message("formatter.from.import.statements"), null, getInstance().WRAP_OPTIONS, WRAP_VALUES);
consumer.showCustomOption(PyCodeStyleSettings.class, "ALIGN_MULTILINE_IMPORTS",
PyBundle.message("formatter.align.when.multiline"),
PyBundle.message("formatter.from.import.statements"));
PySyntaxBundle.message("formatter.align.when.multiline"),
PySyntaxBundle.message("formatter.from.import.statements"));
consumer.showCustomOption(PyCodeStyleSettings.class, "FROM_IMPORT_NEW_LINE_AFTER_LEFT_PARENTHESIS",
ApplicationBundle.message("wrapping.new.line.after.lpar"),
PyBundle.message("formatter.from.import.statements"));
PySyntaxBundle.message("formatter.from.import.statements"));
consumer.showCustomOption(PyCodeStyleSettings.class, "FROM_IMPORT_NEW_LINE_BEFORE_RIGHT_PARENTHESIS",
ApplicationBundle.message("wrapping.rpar.on.new.line"),
PyBundle.message("formatter.from.import.statements"));
PySyntaxBundle.message("formatter.from.import.statements"));
consumer.showCustomOption(PyCodeStyleSettings.class, "FROM_IMPORT_PARENTHESES_FORCE_IF_MULTILINE",
PyBundle.message("formatter.from.import.statements.force.parentheses.if.multiline"),
PyBundle.message("formatter.from.import.statements"));
PySyntaxBundle.message("formatter.from.import.statements.force.parentheses.if.multiline"),
PySyntaxBundle.message("formatter.from.import.statements"));
consumer.showCustomOption(PyCodeStyleSettings.class, "FROM_IMPORT_TRAILING_COMMA_IF_MULTILINE",
PyBundle.message("formatter.from.import.statements.force.comma.if.multline"),
PyBundle.message("formatter.from.import.statements"));
PySyntaxBundle.message("formatter.from.import.statements.force.comma.if.multline"),
PySyntaxBundle.message("formatter.from.import.statements"));
consumer.showCustomOption(PyCodeStyleSettings.class, "DICT_WRAPPING",
PyBundle.message("formatter.dictionary.literals"), null, getInstance().WRAP_OPTIONS, WRAP_VALUES);
PySyntaxBundle.message("formatter.dictionary.literals"), null, getInstance().WRAP_OPTIONS, WRAP_VALUES);
consumer.showCustomOption(PyCodeStyleSettings.class, "DICT_NEW_LINE_AFTER_LEFT_BRACE",
ApplicationBundle.message("wrapping.new.line.after.lbrace"),
PyBundle.message("formatter.dictionary.literals"));
PySyntaxBundle.message("formatter.dictionary.literals"));
consumer.showCustomOption(PyCodeStyleSettings.class, "DICT_NEW_LINE_BEFORE_RIGHT_BRACE",
ApplicationBundle.message("wrapping.rbrace.on.new.line"),
PyBundle.message("formatter.dictionary.literals"));
PySyntaxBundle.message("formatter.dictionary.literals"));
consumer
.showCustomOption(PyCodeStyleSettings.class, "HANG_CLOSING_BRACKETS", PyBundle.message("formatter.hang.closing.brackets"), null);
.showCustomOption(PyCodeStyleSettings.class, "HANG_CLOSING_BRACKETS", PySyntaxBundle.message("formatter.hang.closing.brackets"), null);
}
}
@@ -173,7 +173,7 @@ public final class PyLanguageCodeStyleSettingsProvider extends LanguageCodeStyle
@Override
public CodeStyleConfigurable createConfigurable(@NotNull CodeStyleSettings baseSettings, @NotNull CodeStyleSettings modelSettings) {
return new CodeStyleAbstractConfigurable(baseSettings, modelSettings,
PyBundle.message("configurable.PyLanguageCodeStyleSettingsProvider.display.name")) {
PySyntaxBundle.message("configurable.PyLanguageCodeStyleSettingsProvider.display.name")) {
@Override
protected @NotNull CodeStyleAbstractPanel createPanel(final @NotNull CodeStyleSettings settings) {
return new PyCodeStyleMainPanel(getCurrentSettings(), settings);

View File

@@ -316,8 +316,6 @@
<refactoring.changeSignatureUsageProcessor
implementation="com.jetbrains.python.refactoring.changeSignature.PyChangeSignatureUsageProcessor" id="Python"/>
<langCodeStyleSettingsProvider implementation="com.jetbrains.python.formatter.PyLanguageCodeStyleSettingsProvider"/>
<analyzeStacktraceFilter implementation="com.jetbrains.python.run.PythonTracebackFilter"/>
<analyzeStacktraceFilter implementation="com.jetbrains.python.run.PyRemoteAnalyzeStacktraceFilter"/>