mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
optional alignment for multiline import statements (PY-7394)
This commit is contained in:
@@ -184,7 +184,12 @@ public class PyBlock implements ASTBlock {
|
||||
else if (parentType == PyElementTypes.FROM_IMPORT_STATEMENT) {
|
||||
if ((childType == PyElementTypes.IMPORT_ELEMENT || childType == PyTokenTypes.RPAR) &&
|
||||
_node.findChildByType(PyTokenTypes.LPAR) != null) {
|
||||
childAlignment = getAlignmentForChildren();
|
||||
if (myContext.getPySettings().ALIGN_MULTILINE_IMPORTS) {
|
||||
childAlignment = getAlignmentForChildren();
|
||||
}
|
||||
else {
|
||||
childIndent = Indent.getNormalIndent();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (parentType == PyElementTypes.KEY_VALUE_EXPRESSION) {
|
||||
|
||||
@@ -17,6 +17,7 @@ public class PyCodeStyleSettings extends CustomCodeStyleSettings {
|
||||
public int BLANK_LINES_AROUND_TOP_LEVEL_CLASSES_FUNCTIONS = 2;
|
||||
|
||||
public boolean ALIGN_COLLECTIONS_AND_COMPREHENSIONS = true;
|
||||
public boolean ALIGN_MULTILINE_IMPORTS = true;
|
||||
|
||||
public PyCodeStyleSettings(CodeStyleSettings container) {
|
||||
super("Python", container);
|
||||
|
||||
@@ -75,6 +75,8 @@ public class PyLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettin
|
||||
"ALIGN_MULTILINE_PARAMETERS_IN_CALLS");
|
||||
consumer.showCustomOption(PyCodeStyleSettings.class, "ALIGN_COLLECTIONS_AND_COMPREHENSIONS", "Align when multiline",
|
||||
"Collections and Comprehensions");
|
||||
consumer.showCustomOption(PyCodeStyleSettings.class, "ALIGN_MULTILINE_IMPORTS", "Align when multiline",
|
||||
"Import Statements");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +114,9 @@ public class PyLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettin
|
||||
" def foo(self):\n" +
|
||||
" pass";
|
||||
@SuppressWarnings("FieldCanBeLocal")
|
||||
private static String WRAP_SETTINGS_PREVIEW = "long_expression = component_one + component_two + component_three + component_four + component_five + component_six\n\n" +
|
||||
private static String WRAP_SETTINGS_PREVIEW = "from foo import (bar,\n" +
|
||||
" baz)\n\n" +
|
||||
"long_expression = component_one + component_two + component_three + component_four + component_five + component_six\n\n" +
|
||||
"def xyzzy(long_parameter_1,\n" +
|
||||
"long_parameter_2):\n" +
|
||||
" pass\n\n" +
|
||||
|
||||
Reference in New Issue
Block a user