mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
failing test for alignment in binary expressions
This commit is contained in:
@@ -33,7 +33,7 @@ public class PyBlock implements ASTBlock {
|
||||
private final Wrap _wrap;
|
||||
private final CodeStyleSettings mySettings;
|
||||
private List<PyBlock> _subBlocks = null;
|
||||
private final Alignment _childListAlignment;
|
||||
private Alignment myChildAlignment;
|
||||
private static final boolean DUMP_FORMATTING_BLOCKS = false;
|
||||
|
||||
private static final TokenSet ourListElementTypes = TokenSet.create(PyElementTypes.LIST_LITERAL_EXPRESSION,
|
||||
@@ -61,7 +61,6 @@ public class PyBlock implements ASTBlock {
|
||||
_node = node;
|
||||
_wrap = wrap;
|
||||
mySettings = settings;
|
||||
_childListAlignment = Alignment.createAlignment();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -74,6 +73,13 @@ public class PyBlock implements ASTBlock {
|
||||
return _node.getTextRange();
|
||||
}
|
||||
|
||||
private Alignment getAlignmentForChildren() {
|
||||
if (myChildAlignment == null) {
|
||||
myChildAlignment = Alignment.createAlignment();
|
||||
}
|
||||
return myChildAlignment;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<Block> getSubBlocks() {
|
||||
if (_subBlocks == null) {
|
||||
@@ -131,9 +137,12 @@ public class PyBlock implements ASTBlock {
|
||||
wrap = Wrap.createWrap(WrapType.NORMAL, true);
|
||||
}
|
||||
if (needListAlignment(child)) {
|
||||
childAlignment = _childListAlignment;
|
||||
childAlignment = getAlignmentForChildren();
|
||||
}
|
||||
}
|
||||
else if (parentType == PyElementTypes.BINARY_EXPRESSION && PyElementTypes.EXPRESSIONS.contains(childType)) {
|
||||
childAlignment = getAlignmentForChildren();
|
||||
}
|
||||
if (parentType == PyElementTypes.LIST_LITERAL_EXPRESSION) {
|
||||
if (childType == PyTokenTypes.RBRACKET || childType == PyTokenTypes.LBRACKET) {
|
||||
childIndent = Indent.getNoneIndent();
|
||||
@@ -452,7 +461,7 @@ public class PyBlock implements ASTBlock {
|
||||
|
||||
private Alignment getChildAlignment() {
|
||||
if (ourListElementTypes.contains(_node.getElementType())) {
|
||||
return _childListAlignment;
|
||||
return getAlignmentForChildren();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
if isintance(True, bool) and\
|
||||
isinstance(1, int): pass
|
||||
@@ -0,0 +1,2 @@
|
||||
if isintance(True, bool) and\
|
||||
isinstance(1, int): pass
|
||||
@@ -76,6 +76,10 @@ public class PyFormatterTest extends PyLightFixtureTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testAlignInBinaryExpression() {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() {
|
||||
myFixture.configureByFile("formatter/" + getTestName(true) + ".py");
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
|
||||
Reference in New Issue
Block a user