blank line between statement and function (PY-1007)

This commit is contained in:
Dmitry Jemerov
2010-05-18 12:29:21 +04:00
parent 1a4d4fdd3c
commit ddf5bebe61
4 changed files with 13 additions and 1 deletions

View File

@@ -201,7 +201,8 @@ public class PyBlock implements ASTBlock {
if (type1 == PyElementTypes.CLASS_DECLARATION) {
return getBlankLinesForOption(mySettings.BLANK_LINES_AROUND_CLASS);
}
if (type1 == PyElementTypes.FUNCTION_DECLARATION || (type2 == PyElementTypes.FUNCTION_DECLARATION && type1 == PyElementTypes.CLASS_DECLARATION)) {
if (type1 == PyElementTypes.FUNCTION_DECLARATION ||
(type2 == PyElementTypes.FUNCTION_DECLARATION && isStatementOrDeclaration(type1))) {
return getBlankLinesForOption(mySettings.BLANK_LINES_AROUND_METHOD);
}
if (isImportStatement(type1) && (isStatementOrDeclaration(type2) && !isImportStatement(type2))) {

View File

@@ -0,0 +1,3 @@
class C:
x = 1
def foo(self): pass

View File

@@ -0,0 +1,4 @@
class C:
x = 1
def foo(self): pass

View File

@@ -40,6 +40,10 @@ public class PyFormatterTest extends PyLightFixtureTestCase {
doTest();
}
public void testBlankLineBeforeFunction() throws Exception {
doTest();
}
private void doTest() throws Exception {
myFixture.configureByFile("formatter/" + getTestName(true) + ".py");
ApplicationManager.getApplication().runWriteAction(new Runnable() {