mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
honor space after comma option in formatter (PY-486)
This commit is contained in:
@@ -215,6 +215,10 @@ public class PyBlock implements ASTBlock {
|
||||
if (type1 == PyTokenTypes.COLON && type2 == PyElementTypes.STATEMENT_LIST) {
|
||||
return Spacing.createSpacing(1, Integer.MAX_VALUE, 0, true, 0);
|
||||
}
|
||||
|
||||
if (type1 == PyTokenTypes.COMMA) {
|
||||
return getSpacingForOption(mySettings.SPACE_AFTER_COMMA);
|
||||
}
|
||||
/*
|
||||
if (type1 == PyTokenTypes.COLON && type2 == PyElementTypes.STATEMENT_LIST) {
|
||||
return Spacing.createSpacing(0, Integer.MAX_VALUE, 1, true, Integer.MAX_VALUE);
|
||||
@@ -239,6 +243,11 @@ public class PyBlock implements ASTBlock {
|
||||
return null;
|
||||
}
|
||||
|
||||
private Spacing getSpacingForOption(boolean isOptionSet) {
|
||||
int spaces = isOptionSet ? 1 : 0;
|
||||
return Spacing.createSpacing(spaces, spaces, 0, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
|
||||
}
|
||||
|
||||
private static boolean isStatementOrDeclaration(final IElementType type) {
|
||||
return PyElementTypes.STATEMENTS.contains(type) ||
|
||||
type == PyElementTypes.CLASS_DECLARATION ||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
import os,sys
|
||||
@@ -0,0 +1 @@
|
||||
import os, sys
|
||||
@@ -16,6 +16,10 @@ public class PyFormatterTest extends PyLightFixtureTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testSpaceAfterComma() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
myFixture.configureByFile("formatter/" + getTestName(true) + ".py");
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
|
||||
Reference in New Issue
Block a user