Examples of GoBinaryExpression


Examples of ro.redeul.google.go.lang.psi.expressions.binary.GoBinaryExpression

            }
        }

        if ( expr instanceof GoLogicalOrExpression) {
            GoBinaryExpression be = (GoLogicalOrExpression) expr;

            String lhs = flipAndAddParenthesesIfItsAndExpr(be.getLeftOperand());
            String rhs = flipAndAddParenthesesIfItsAndExpr(be.getRightOperand());
            return lhs + " && " + rhs;
        }

        if ( expr instanceof GoLogicalAndExpression) {
            GoBinaryExpression be = (GoBinaryExpression) expr;

            return flip(be.getLeftOperand()) + " || " + flip(be.getRightOperand());
        }

        if (expr instanceof GoLiteralExpression) {
            GoLiteral literal = ((GoLiteralExpression) expr).getLiteral();
            if (literal instanceof GoLiteralIdentifier) {
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.expressions.binary.GoBinaryExpression

    );

    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;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.