mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
failing test for PY-10319
This commit is contained in:
@@ -152,7 +152,7 @@ public class PyBlock implements ASTBlock {
|
||||
if (ourListElementTypes.contains(parentType)) {
|
||||
// wrapping in non-parenthesized tuple expression is not allowed (PY-1792)
|
||||
if ((parentType != PyElementTypes.TUPLE_EXPRESSION || grandparentType == PyElementTypes.PARENTHESIZED_EXPRESSION) &&
|
||||
!ourBrackets.contains(childType) && childType != PyTokenTypes.COMMA && !isSliceOperand(child)) {
|
||||
!ourBrackets.contains(childType) && childType != PyTokenTypes.COMMA && !isSliceOperand(child) /*&& !isSubscriptionOperand(child)*/) {
|
||||
wrap = Wrap.createWrap(WrapType.NORMAL, true);
|
||||
}
|
||||
if (needListAlignment(child) && !isEmptyList(_node.getPsi())) {
|
||||
@@ -257,6 +257,11 @@ public class PyBlock implements ASTBlock {
|
||||
return new PyBlock(this, child, childAlignment, childIndent, wrap, myContext);
|
||||
}
|
||||
|
||||
private static boolean isSubscriptionOperand(ASTNode child) {
|
||||
return child.getTreeParent().getElementType() == PyElementTypes.SUBSCRIPTION_EXPRESSION &&
|
||||
child.getPsi() == ((PySubscriptionExpression) child.getTreeParent().getPsi()).getOperand();
|
||||
}
|
||||
|
||||
private boolean isInControlStatement() {
|
||||
return PsiTreeUtil.getParentOfType(_node.getPsi(), PyStatementPart.class, false, PyStatementList.class) != null ||
|
||||
PsiTreeUtil.getParentOfType(_node.getPsi(), PyWithItem.class) != null;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
id = 1 if looooooooooooooooooooooooong_vaaaaaaaaaaaaaaaar == 'loooooooooooooooong_vaaaaaaaaaaaaaaaaaaaaaaaaaalue' else list('foo')[0]
|
||||
@@ -0,0 +1,2 @@
|
||||
id = 1 if looooooooooooooooooooooooong_vaaaaaaaaaaaaaaaar == 'loooooooooooooooong_vaaaaaaaaaaaaaaaaaaaaaaaaaalue' else list(
|
||||
'foo')[0]
|
||||
@@ -337,12 +337,27 @@ public class PyFormatterTest extends PyTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void _testWrapBeforeElse() { // PY-10319
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
private void doTest(final boolean reformatText) {
|
||||
myFixture.configureByFile("formatter/" + getTestName(true) + ".py");
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CodeStyleManager.getInstance(myFixture.getProject()).reformat(myFixture.getFile());
|
||||
CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(myFixture.getProject());
|
||||
PsiFile file = myFixture.getFile();
|
||||
if (reformatText) {
|
||||
codeStyleManager.reformatText(file, 0, file.getTextLength());
|
||||
}
|
||||
else {
|
||||
codeStyleManager.reformat(file);
|
||||
}
|
||||
}
|
||||
});
|
||||
myFixture.checkResultByFile("formatter/" + getTestName(true) + "_after.py");
|
||||
|
||||
Reference in New Issue
Block a user