Examples of GoBlockStatement


Examples of ro.redeul.google.go.lang.psi.statements.GoBlockStatement

    public void testReturnNothing() throws Exception {

        GoFile file = get(parse("package main; func a() { return }"));
        GoFunctionDeclaration func = childAt(0,
                                             file.getFunctions());
        GoBlockStatement blockStmt = get(func.getBlock());
        GoReturnStatement returnStmt =
            castAs(GoReturnStatement.class,
                   0, blockStmt.getStatements());

        assertTrue(returnStmt.getExpressions().length == 0);
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.statements.GoBlockStatement

    public void testReturnLiteral() throws Exception {

        GoFile file = get(parse("package main; func a() { return 1}"));
        GoFunctionDeclaration func = childAt(0,
                                             file.getFunctions());
        GoBlockStatement blockStmt = get(func.getBlock());
        GoReturnStatement returnStmt =
            castAs(GoReturnStatement.class,
                   0, blockStmt.getStatements());

        assertNotNull(castAs(GoLiteralExpression.class,
                             0, returnStmt.getExpressions()));
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.statements.GoBlockStatement

        GoFile file = get(parse("package main; func a() { return 1,2}"));

        GoFunctionDeclaration func =
            childAt(0, file.getFunctions());

        GoBlockStatement blockStmt = get(func.getBlock());

        GoReturnStatement returnStmt =
            castAs(GoReturnStatement.class, 0, blockStmt.getStatements());

        assertNotNull(
            castAs(GoLiteralExpression.class, 0, returnStmt.getExpressions()));

        assertNotNull(
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.statements.GoBlockStatement

    public void testReturnLiteral2() throws Exception {

        GoFile file = get(parse("package main; func a() { return \"a\";\n}"));
        GoFunctionDeclaration func = childAt(0,
                                             file.getFunctions());
        GoBlockStatement blockStmt = get(func.getBlock());
        GoReturnStatement returnStmt =
            castAs(GoReturnStatement.class,
                   0, blockStmt.getStatements());

        assertNotNull(castAs(GoLiteralExpression.class,
                             0, returnStmt.getExpressions()));
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.statements.GoBlockStatement

    public void testReturnAddExpression() throws Exception {

        GoFile file = get(parse("package main; func a() { return 1+2 }"));
        GoFunctionDeclaration func = childAt(0,
                                             file.getFunctions());
        GoBlockStatement blockStmt = get(func.getBlock());
        GoReturnStatement returnStmt =
            castAs(GoReturnStatement.class,
                   0, blockStmt.getStatements());

        assertNotNull(castAs(GoAdditiveExpression.class,
                             0, returnStmt.getExpressions()));
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.statements.GoBlockStatement

                                    "func test() {\n" +
                                    "   v := 5\n" +
                                    "   println(v + 1)\n" +
                                    "}"));

        GoBlockStatement block =
            get(
                childAt(0,
                        file.getFunctions()
                ).getBlock()
            );

        castAs(GoShortVarDeclaration.class, 0, block.getStatements());
        castAs(GoExpressionStatement.class, 1, block.getStatements());
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.statements.GoBlockStatement

    @Override
    protected void walkSolver(ShortVarSolver solver) {
        GoShortVarDeclaration varDeclaration = getAs(GoShortVarDeclaration.class, getElement().getParent());

        GoBlockStatement blockStatement = getAs(GoBlockStatement.class, varDeclaration.getParent());

        if ( blockStatement != null)
            blockStatement.processDeclarations(solver, ResolveStates.initial(), varDeclaration, this.getElement());
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.statements.GoBlockStatement

        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.statements.GoBlockStatement

        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);
        if (rightCurlyPosition < 0 || leftCurlyPosition < 0) {
            return;
        }

        GoBlockStatement elseBlock = stmt.getElseBlock();
        boolean hasElseBlock = elseBlock != null;

        List<PsiElement> siblings = getSiblings(stmt);
        if (hasElseBlock) {
            swapThenAndElseBlock(document, condition, thenBlock, elseBlock);
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.statements.GoBlockStatement

            !isNodeOfType(leftExpr, GoElementTypes.REL_EXPRESSION) ||
            !isNodeOfType(rightExpr, GoElementTypes.REL_EXPRESSION)) {
            return;
        }

        GoBlockStatement then = ifStmt.getThenBlock();
        TextRange thenRange = then.getTextRange();
        Document doc = editor.getDocument();
        RangeMarker thenRangeMarker = doc.createRangeMarker(thenRange);

        int lineStartOffset = doc.getLineStartOffset(doc.getLineNumber(thenRange.getEndOffset()));
        doc.insertString(lineStartOffset, "}\n");
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.