Examples of GoSimpleStatement


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

        }
        return String.format("if %s; %s", simpleStatement, expression);
    }

    private String getSimpleStatement(GoIfStatement outer, GoIfStatement inner) {
        GoSimpleStatement statement = outer.getSimpleStatement();
        if (statement != null) {
            return statement.getText();
        }

        statement = inner.getSimpleStatement();
        if (statement != null) {
            return statement.getText();
        }

        return "";
    }
View Full Code Here

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

            }
            return sb.toString();
        }

        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;
View Full Code Here

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

                                       PsiElement lastParent,
                                       @NotNull PsiElement place) {
        if (lastParent == null)
            return true;

        GoSimpleStatement statement = getSimpleStatement();
        if (statement != null && lastParent != statement) {
            if (!statement.processDeclarations(processor, state, null, place))
                return false;
        }

        return true;
    }
View Full Code Here

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

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

        GoSimpleStatement ss = stmt.getSimpleStatement();
        return ss != null && ss.getTextRange().contains(element.getTextRange());
    }
View Full Code Here

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

    }

    private static boolean isInSwitchStatement(PsiElement element) {
        GoSwitchExpressionStatement seStmt = findParentOfType(element, GoSwitchExpressionStatement.class);
        if (seStmt != null) {
            GoSimpleStatement ss = seStmt.getSimpleStatement();
            return ss != null && ss.getTextRange().contains(element.getTextRange());
        }

        GoSwitchTypeStatement stStmt = findParentOfType(element, GoSwitchTypeStatement.class);
        if (stStmt != null) {
            GoSimpleStatement ss = stStmt.getSimpleStatement();
            return ss != null && ss.getTextRange().contains(element.getTextRange());
        }
        return false;
    }
View Full Code Here

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

            writeCommandAction.execute();


            flipCondition(document, condition);

            GoSimpleStatement simpleStatement = stmt.getSimpleStatement();
            if (simpleStatement != null) {
                extractSimpleStatement(stmt, document, condition, simpleStatement);
            }
        } else {
            WriteCommandAction writeCommandAction = new WriteCommandAction(element.getContainingFile().getProject()) {
View Full Code Here

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

        int end = semi.getTextOffset();
        move(editor, forStatement, simpleStatement.getText(), start, end);
    }

    private static void moveSimpleStatementOut(Editor editor, GoSwitchTypeStatement stStmt) {
        GoSimpleStatement simpleStatement = stStmt.getSimpleStatement();
        PsiElement endElement = stStmt.getTypeGuard();
        endElement = endElement.getPrevSibling();

        if (simpleStatement == null || endElement == null) {
            return;
        }

        int start = simpleStatement.getTextOffset();
        int end = endElement.getTextRange().getEndOffset();
        move(editor, stStmt, simpleStatement.getText(), start, end);
    }
View Full Code Here

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

        int end = endElement.getTextRange().getEndOffset();
        move(editor, stStmt, simpleStatement.getText(), start, end);
    }

    private static void moveSimpleStatementOut(Editor editor, GoSwitchExpressionStatement seStmt) {
        GoSimpleStatement simpleStatement = seStmt.getSimpleStatement();
        PsiElement endElement = seStmt.getExpression();
        if (endElement == null) {
            endElement = findChildOfType(seStmt, GoTokenTypes.oSEMI);
        } else {
            endElement = endElement.getPrevSibling();
        }

        if (simpleStatement == null || endElement == null) {
            return;
        }

        int start = simpleStatement.getTextOffset();
        int end = endElement.getTextRange().getEndOffset();
        move(editor, seStmt, simpleStatement.getText(), start, end);
    }
View Full Code Here

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

        writeCommandAction.execute();
        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.statements.GoSimpleStatement

    @Override
    public boolean processDeclarations(@NotNull PsiScopeProcessor processor,
                                       @NotNull ResolveState state,
                                       PsiElement lastParent,
                                       @NotNull PsiElement place) {
        GoSimpleStatement initStatement = getSimpleStatement();
        return lastParent == null || initStatement == null || lastParent == initStatement || initStatement.processDeclarations(processor, state, null, place);

    }
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.