Examples of GoFile


Examples of ro.redeul.google.go.lang.psi.GoFile

        assertEquals(func.getParameters().length, 1);
    }

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

        assertEquals(func.getParameters().length, 1);
    }

    public void testUnnamedParamVariadic() throws Exception {
        GoFile file = get(parse("package main; func a(...int) { }"));
        GoFunctionParameter param =
            childAt(0,
                    childAt(0,
                            file.getFunctions()
                    ).getParameters()
            );

        assertEquals(param.isVariadic(), true);
    }
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoFile

import static ro.redeul.google.go.util.GoPsiTestUtils.getAs;

public class GoPsiCallsTest extends GoPsiTestCase {

    public void testNoParams() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "func main() {" +
                      " f()" +
                      "}"));

        GoCallOrConvExpression expr =
            getAs(GoCallOrConvExpression.class,
                  castAs(GoExpressionStatement.class, 0,
                         get(
                             get(
                                 file.getMainFunction()
                             ).getBlock()
                         ).getStatements()
                  ).getExpression()
            );
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoFile

        assertEquals("f", get(expr.getBaseExpression()).getText());
        assertEquals(0, expr.getArguments().length);
    }

    public void testOneParam() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "func main() {" +
                      " f(1)" +
                      "}"));

        GoCallOrConvExpression expr =
            getAs(GoCallOrConvExpression.class,
                  castAs(GoExpressionStatement.class, 0,
                         get(
                             get(
                                 file.getMainFunction()
                             ).getBlock()
                         ).getStatements()
                  ).getExpression()
            );
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoFile

        assertEquals(1, expr.getArguments().length);
        assertEquals("1", childAt(0, expr.getArguments()).getText());
    }

    public void testTwoParams() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "func main() {" +
                      " f(1, 2)" +
                      "}"));

        GoCallOrConvExpression expr =
            getAs(GoCallOrConvExpression.class,
                  castAs(GoExpressionStatement.class, 0,
                         get(
                             get(
                                 file.getMainFunction()
                             ).getBlock()
                         ).getStatements()
                  ).getExpression()
            );
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoFile

        assertEquals("1", childAt(0, expr.getArguments()).getText());
        assertEquals("2", childAt(1, expr.getArguments()).getText());
    }

    public void testTwoParamsNil() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "func main() {" +
                      " f(nil, 2)" +
                      "}"));

        GoCallOrConvExpression expr =
            getAs(GoCallOrConvExpression.class,
                  castAs(GoExpressionStatement.class, 0,
                         get(
                             get(
                                 file.getMainFunction()
                             ).getBlock()
                         ).getStatements()
                  ).getExpression()
            );
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoFile

        assertEquals("nil", childAt(0, expr.getArguments()).getText());
        assertEquals("2", childAt(1, expr.getArguments()).getText());
    }

    public void testTwoParamsNilString() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "import \"fmt\"\n" +
                      "func main() {\n" +
                      "     fmt.Fprintf(nil, \"/*begin*/%f/*end.Missing parameter*/\\n\")\n" +
                      "}"));

        GoCallOrConvExpression expr =
            getAs(GoCallOrConvExpression.class,
                  castAs(GoExpressionStatement.class, 0,
                         get(
                             get(
                                 file.getMainFunction()
                             ).getBlock()
                         ).getStatements()
                  ).getExpression()
            );

View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoFile

import static ro.redeul.google.go.util.GoPsiTestUtils.getAs;

public class GoPsiForStatementTest extends GoPsiTestCase {

    public void testForWithClauseNullCondition() throws Exception {
        GoFile file = get(parse("" +
                                    "package main;\n" +
                                    "func test() {\n" +
                                    "   for ;; {}\n" +
                                    "}"));

        GoForWithClausesStatement forStmt =
            castAs(GoForWithClausesStatement.class, 0,
                   get(
                       childAt(0,
                               file.getFunctions()
                       ).getBlock()
                   ).getStatements()
            );

        assertNull(forStmt.getCondition());
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoFile

        assertNull(forStmt.getCondition());
    }

    public void testForWithClauseNotNullCondition() throws Exception {
        GoFile file = get(parse("" +
                                    "package main;\n" +
                                    "func test() {\n" +
                                    "   for ;e; {}\n" +
                                    "}"));

        GoForWithClausesStatement forStmt =
            castAs(GoForWithClausesStatement.class, 0,
                   get(
                       childAt(0,
                               file.getFunctions()
                       ).getBlock()
                   ).getStatements()
            );

        getAs(GoLiteralExpression.class, forStmt.getCondition());
View Full Code Here

Examples of ro.redeul.google.go.lang.psi.GoFile

        getAs(GoLiteralExpression.class, forStmt.getCondition());
    }

    public void testForWithClauseNotNullConditionAdditive() throws Exception {
        GoFile file = get(parse("" +
                                    "package main;\n" +
                                    "func test() {\n" +
                                    "   for ;e+f; {}\n" +
                                    "}"));

        GoForWithClausesStatement forStmt =
            castAs(GoForWithClausesStatement.class, 0,
                   get(
                       childAt(0,
                               file.getFunctions()
                       ).getBlock()
                   ).getStatements()
            );

        getAs(GoAdditiveExpression.class, forStmt.getCondition());
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.