support "Spaces before method declaration parentheses" option for Python (PY-4241)

This commit is contained in:
Dmitry Jemerov
2011-08-08 19:48:41 +02:00
parent e43654efe1
commit d96d067e02
5 changed files with 17 additions and 0 deletions
@@ -381,6 +381,9 @@ public class PyBlock implements ASTBlock {
if (type2 == PyElementTypes.ARGUMENT_LIST) {
return getSpacingForOption(mySettings.SPACE_BEFORE_METHOD_CALL_PARENTHESES);
}
if (type2 == PyElementTypes.PARAMETER_LIST) {
return getSpacingForOption(mySettings.SPACE_BEFORE_METHOD_PARENTHESES);
}
if (type1 == PyTokenTypes.EQ || type2 == PyTokenTypes.EQ) {
if (parentType == PyElementTypes.ASSIGNMENT_STATEMENT) {
@@ -33,6 +33,7 @@ public class PyLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettin
public void customizeSettings(@NotNull CodeStyleSettingsCustomizable consumer, @NotNull SettingsType settingsType) {
if (settingsType == SettingsType.SPACING_SETTINGS) {
consumer.showStandardOptions("SPACE_BEFORE_METHOD_CALL_PARENTHESES",
"SPACE_BEFORE_METHOD_PARENTHESES",
"SPACE_AROUND_ASSIGNMENT_OPERATORS",
"SPACE_AROUND_EQUALITY_OPERATORS",
"SPACE_AROUND_RELATIONAL_OPERATORS",
@@ -0,0 +1,4 @@
def foo(bar, baz):
pass
foo(True, False)
@@ -0,0 +1,4 @@
def foo (bar, baz):
pass
foo(True, False)
@@ -117,6 +117,11 @@ public class PyFormatterTest extends PyLightFixtureTestCase {
doTest();
}
public void testSpaceInMethodDeclaration() { // PY-4241
CodeStyleSettingsManager.getInstance().getSettings(myFixture.getProject()).SPACE_BEFORE_METHOD_PARENTHESES = true;
doTest();
}
public void testPsiFormatting() { // IDEA-69724
String initial =
"def method_name(\n" +