Examples of GoFunctionDeclaration


Examples of ro.redeul.google.go.lang.psi.toplevel.GoFunctionDeclaration

public class GoPsiStatementsTest extends GoPsiTestCase {

    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.toplevel.GoFunctionDeclaration

    }

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

Examples of ro.redeul.google.go.lang.psi.toplevel.GoFunctionDeclaration

    public void testReturnMultiple() 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(
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.toplevel.GoFunctionDeclaration

    }

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

Examples of ro.redeul.google.go.lang.psi.toplevel.GoFunctionDeclaration

    }

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

Examples of ro.redeul.google.go.lang.psi.toplevel.GoFunctionDeclaration

public class GoPsiFunctionTest extends GoPsiTestCase {

    public void testNoParams() throws Exception {
        GoFile file = get(parse("package main; func a() { }"));

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

        assertEquals(func.getParameters().length, 0);
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.toplevel.GoFunctionDeclaration

    }

    public void testOneParam() throws Exception {
        GoFile file = get(parse("package main; func a(a int) { }"));

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

        assertEquals(func.getParameters().length, 1);
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.toplevel.GoFunctionDeclaration

    }

    public void testOneParamVariadic() throws Exception {
        GoFile file = get(parse("package main; func a(a ...int) { }"));

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

        assertEquals(func.getParameters().length, 1);
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.toplevel.GoFunctionDeclaration

        final GoLiteralExpression expression = findParentOfType(element, GoLiteralExpression.class);
        assertNotNull(expression);
        assertInstanceOf(expression.getLiteral(), GoLiteralIdentifier.class);

        GoFunctionDeclaration goFunctionDeclaration = GoExpressionUtils.resolveToFunctionDeclaration(expression);
        assertNotNull(goFunctionDeclaration);
        final GoPsiType type = goFunctionDeclaration.getParameters()[1].getType();

        CommandProcessor.getInstance().executeCommand(project, new Runnable() {
            @Override
            public void run() {
                new CastTypeFix(expression, GoTypes.fromPsi(type)).invoke(project, file, editor, expression, expression);
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.toplevel.GoFunctionDeclaration

    public void testSimple() throws Exception{ doTest(); }

    @Override
    protected void invoke(Project project, Editor editor, GoFile file) {
        PsiElement element = file.findElementAt(editor.getSelectionModel().getSelectionStart());
        GoFunctionDeclaration function = findParentOfType(element, GoFunctionDeclaration.class);
        assertNotNull(function);

        new AddReturnStmtFix(function).invoke(project, file, editor, function, function);
    }
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.