no space after star in star expression (PY-1523)

This commit is contained in:
Dmitry Jemerov
2010-08-17 13:25:42 +04:00
parent 4684b8c13e
commit e446210a0d
4 changed files with 17 additions and 1 deletions

View File

@@ -285,7 +285,9 @@ public class PyBlock implements ASTBlock {
return getSpacingForOption(mySettings.SPACE_AROUND_ADDITIVE_OPERATORS);
}
if (isAround(type1, type2, PyTokenTypes.MULTIPLICATIVE_OPERATIONS) || type1 == PyTokenTypes.EXP || type2 == PyTokenTypes.EXP) {
if (parentType == PyElementTypes.NAMED_PARAMETER || parentType == PyElementTypes.STAR_ARGUMENT_EXPRESSION) {
if (parentType == PyElementTypes.NAMED_PARAMETER ||
parentType == PyElementTypes.STAR_ARGUMENT_EXPRESSION ||
parentType == PyElementTypes.STAR_EXPRESSION) {
return Spacing.createSpacing(0, 0, 0, mySettings.KEEP_LINE_BREAKS, mySettings.KEEP_BLANK_LINES_IN_CODE);
}
return getSpacingForOption(mySettings.SPACE_AROUND_MULTIPLICATIVE_OPERATORS);

View File

@@ -0,0 +1 @@
a, * b, c = range(5)

View File

@@ -0,0 +1 @@
a, *b, c = range(5)

View File

@@ -3,6 +3,8 @@ package com.jetbrains.python;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.psi.codeStyle.CodeStyleManager;
import com.jetbrains.python.fixtures.PyLightFixtureTestCase;
import com.jetbrains.python.psi.LanguageLevel;
import com.jetbrains.python.psi.impl.PythonLanguageLevelPusher;
/**
* @author yole
@@ -52,6 +54,16 @@ public class PyFormatterTest extends PyLightFixtureTestCase {
doTest();
}
public void testStarExpression() { // PY-1523
PythonLanguageLevelPusher.setForcedLanguageLevel(myFixture.getProject(), LanguageLevel.PYTHON30);
try {
doTest();
}
finally {
PythonLanguageLevelPusher.setForcedLanguageLevel(myFixture.getProject(), null);
}
}
private void doTest() {
myFixture.configureByFile("formatter/" + getTestName(true) + ".py");
ApplicationManager.getApplication().runWriteAction(new Runnable() {