);
public GoBinaryExpressionBlock(ASTNode node, Alignment alignment, Wrap wrap, CommonCodeStyleSettings settings) {
super(node, alignment, Indent.getNormalIndent(), wrap, settings);
GoBinaryExpression psi = node.getPsi(GoBinaryExpression.class);
if (psi == null) {
spacing = BASIC_SPACING_KEEP_LINE_BREAKS;
return;
}
ASTNode parentElement = node.getTreeParent();
ASTNode preParentElement = node;
IElementType parentElementType = parentElement.getElementType();
boolean inARelation = false;
if (parentElementType == REL_EXPRESSION) {
inARelation = true;
}
while (parentElementType != BUILTIN_CALL_EXPRESSION
&& parentElementType != EXPRESSION_LIST
&& !STATEMENTS.contains(parentElementType)
&& parentElementType != CONST_DECLARATION
&& parentElementType != VAR_DECLARATION
) {
preParentElement = parentElement;
parentElement = parentElement.getTreeParent();
if (parentElement == null) {
return;
}
parentElementType = parentElement.getElementType();
if (parentElementType == REL_EXPRESSION) {
inARelation = true;
}
}
if (inARelation) {
spacing = EMPTY_SPACING_KEEP_LINE_BREAKS;
return;
}
if (parentElementType == EXPRESSION_LIST) {
if (inTheSameLine(psi.getLeftOperand().getNode(), psi.getRightOperand().getNode())
&& !(node.getElementType() == LOG_OR_EXPRESSION || node.getElementType() == LOG_AND_EXPRESSION || node.getElementType() == REL_EXPRESSION)
) {
spacing = EMPTY_SPACING_KEEP_LINE_BREAKS;
} else {
spacing = BASIC_SPACING_KEEP_LINE_BREAKS;
}
return;
}
if (STATEMENTS.contains(parentElementType)
|| parentElementType == CONST_DECLARATION
|| parentElementType == VAR_DECLARATION
) {
try {
if (preParentElement.getElementType() == ADD_EXPRESSION
&& node != preParentElement
&& preParentElement.getPsi(GoAdditiveExpression.class).op() == GoAdditiveExpression.Op.BitOr) {
spacing = EMPTY_SPACING_KEEP_LINE_BREAKS;
return;
}
} catch (NullPointerException ignored) {
}
if (preParentElement.getElementType() == SLICE_EXPRESSION) {
spacing = EMPTY_SPACING_KEEP_LINE_BREAKS;
return;
}
spacing = BASIC_SPACING_KEEP_LINE_BREAKS;
return;
}
ASTNode expression = node;
ASTNode expressionChild = node;
while (expression.getElementType() != BUILTIN_CALL_EXPRESSION) {
expressionChild = expression;
expression = expression.getTreeParent();
}
ASTNode elem = expressionChild;
boolean isAlone = true;
while (!elem.getElementType().toString().equals(")")) {
elem = elem.getTreeNext();
if (elem.getElementType().toString().equals(",")) {
isAlone = false;
}
}
if (!isAlone) {
if (inTheSameLine(psi.getLeftOperand().getNode(), psi.getRightOperand().getNode())) {
spacing = EMPTY_SPACING_KEEP_LINE_BREAKS;
} else {
spacing = BASIC_SPACING_KEEP_LINE_BREAKS;
}
return;