Examples of GoExpr


Examples of ro.redeul.google.go.lang.psi.expressions.GoExpr

        }

        private static SwitchElements create(Document document, GoSwitchExpressionStatement se) {
            GoSimpleStatement simpleStatement = se.getSimpleStatement();
            String ss = simpleStatement == null ? "" : simpleStatement.getText();
            GoExpr expression = se.getExpression();
            boolean expressionIsTrue = expression == null || "true".equals(expression.getText());
            boolean expressionIsFalse = expression != null && "false".equals(expression.getText());
            String es = expressionIsTrue || expressionIsFalse ? "" : expression.getText();
            CaseElement defaultCase = null;
            List<CaseElement> cases = new ArrayList<CaseElement>();
            for (GoSwitchExpressionClause clause : se.getClauses()) {
                CaseElement c = CaseElement.create(document, clause, expressionIsFalse);
                if (clause.isDefault()) {
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.expressions.GoExpr

    }

    @Override
    @NotNull
    public GoExpr[] getExpressions() {
        GoExpr goExprs[] = findChildrenByClass(GoExpr.class);
//        if (goExprs.length == 0 && !hasInitializers()) {
//
//            // Omitting the list of expressions is therefore equivalent to repeating the previous list
//            // So we will find the previous list and clone it.
//
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.expressions.GoExpr

            }

            goExprs = new GoExpr[expressions.size()];
            Integer iotaValue = getConstSpecIndex();
            for (int i = 0; i < expressions.size(); i++) {
                GoExpr expression = expressions.get(i);
                goExprs[i] = (GoExpr) expression.copy();
                setIotaValue(goExprs[i], iotaValue);
            }
        }

        if (goExprs.length <= identifierIndex)
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.expressions.GoExpr

        super(node);
    }

    @Override
    public int getArrayLength() {
        GoExpr child = GoPsiUtils.findChildOfClass(this, GoExpr.class);
        if (child != null) {
            Number value = getNumberValueFromLiteralExpr(child);
            if (value != null && (value instanceof Integer || value.intValue() == value.floatValue()))
                return value.intValue();
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.expressions.GoExpr

        super(node);
    }

    @Override
    public GoLiteralIdentifier getKey() {
        GoExpr keyExpression = getIndex();

        if (keyExpression == null)
            return null;

        if (keyExpression instanceof GoLiteralExpression) {
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.expressions.GoExpr

        GoIfStatement stmt = findParentOfType(element, GoIfStatement.class);
        if (stmt == null) {
            return false;
        }

        GoExpr condition = stmt.getExpression();
        GoBlockStatement thenBlock = stmt.getThenBlock();
        return !(condition == null || thenBlock == null || element.getTextOffset() >= thenBlock.getTextOffset()) && stmt.getElseIfStatement() == null;

    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.expressions.GoExpr

        return findChildByClass(GoPrimaryExpression.class, 0);
    }

    @Override
    public GoExpr getFirstIndex() {
        GoExpr expr = findChildByClass(GoExpr.class, 1);
        if ( expr != null && hasPrevSiblingOfType(expr, GoTokenTypes.pLBRACK)) {
            return expr;
        }

        return null;
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.expressions.GoExpr

        }

        final Document document = editor.getDocument();
        RangeMarker stmtRange = document.createRangeMarker(stmt.getTextRange());

        GoExpr condition = stmt.getExpression();
        boolean parentIsFunctionDeclaration = isFunctionBlock(stmt.getParent());
        GoBlockStatement thenBlock = stmt.getThenBlock();

        final int rightCurlyPosition = blockRightCurlyPosition(thenBlock);
        final int leftCurlyPosition = blockLeftCurlyPosition(thenBlock);
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.expressions.GoExpr

        reformatPositions(statement.getContainingFile(), range);
    }

    public static void moveSimpleStatementOut(Editor editor, GoIfStatement ifStatement) {
        final GoSimpleStatement simpleStatement = ifStatement.getSimpleStatement();
        final GoExpr condition = ifStatement.getExpression();
        if (simpleStatement == null || condition == null) {
            return;
        }

        moveDependentSimpleStatementsFirst(editor, ifStatement, simpleStatement);

        PsiElement outermostIf = ifStatement;
        while (outermostIf instanceof GoIfStatement && outermostIf.getParent() instanceof GoIfStatement) {
            outermostIf = outermostIf.getParent();
        }

        final Document document = editor.getDocument();
        RangeMarker range = document.createRangeMarker(outermostIf.getTextOffset(), condition.getTextOffset());
        final PsiElement finalOutermostIf = outermostIf;
        WriteCommandAction writeCommandAction = new WriteCommandAction(ifStatement.getContainingFile().getProject()) {
            @Override
            protected void run(@NotNull Result result) throws Throwable {
                document.deleteString(simpleStatement.getTextOffset(), condition.getTextOffset());
                document.insertString(finalOutermostIf.getTextOffset(), simpleStatement.getText() + "\n");
            }
        };
        writeCommandAction.execute();
        reformatPositions(ifStatement.getContainingFile(), range);
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.expressions.GoExpr

        return null;
    }

    @Override
    public GoExpr getSecondIndex() {
        GoExpr expressions[] = findChildrenByClass(GoExpr.class);

        PsiElement firstColon = expressions[0].getNextSibling();

        while (firstColon != null &&
                firstColon.getNode().getElementType() != GoTokenTypes.oCOLON
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.