Examples of GoFile


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

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

    public void testForWithRangeKeyNotNullConditionAdditive() throws Exception {
        GoFile file = get(parse("" +
                                    "package main;\n" +
                                    "func main() {\n" +
                                    "    for i := range data {\n" +
                                    "        println(i)\n" +
                                    "    }\n" +
                                    "}"));

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

        assertEquals("i", get(forStmt.getKey()).getText());
View Full Code Here

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

        assertNull(forStmt.getValue());
        assertEquals("data", get(forStmt.getRangeExpression()).getText());
    }

    public void testForWithRangeKeyValueNoRange() throws Exception {
        GoFile file = get(parse("" +
                                    "package main;\n" +
                                    "func main() {\n" +
                                    "    for key, value := range {\n" +
                                    "        println(i)\n" +
                                    "    }\n" +
                                    "}"));

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

        assertEquals("key", get(forStmt.getKey()).getText());
View Full Code Here

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

        assertEquals("value", get(forStmt.getValue()).getText());
        assertNull(forStmt.getRangeExpression());
    }

    public void testForWithRange() throws Exception {
        GoFile file = get(parse("" +
                                    "package main;\n" +
                                    "func main() {\n" +
                                    "    for key, value := range data {\n" +
                                    "        println(i)\n" +
                                    "    }\n" +
                                    "}"));

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

        assertEquals("key", get(forStmt.getKey()).getText());
View Full Code Here

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

        assertEquals("value", get(forStmt.getValue()).getText());
        assertEquals("data", get(forStmt.getRangeExpression()).getText());
    }

    public void testForWithRange2() throws Exception {
        GoFile file = get(parse("" +
                                    "package main;\n" +
                                    "func main() {\n" +
                                    "    for key, value = range data {\n" +
                                    "        println(i)\n" +
                                    "    }\n" +
                                    "}"));

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

        assertEquals("key", get(forStmt.getKey()).getText());
View Full Code Here

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

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

public class GoPsiSwitchExpressionsTest extends GoPsiTestCase {

    public void testDefault() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "func main() int {\n" +
                      "     switch {\n" +
                      "         default:\n" +
                      "             return 1\n" +
                      "     }\n" +
                      "     return nil\n" +
                      "}\n"));

        GoSwitchExpressionStatement exprSwitch =
            castAs(GoSwitchExpressionStatement.class, 0,
                   get(
                       get(
                           file.getMainFunction()
                       ).getBlock()
                   ).getStatements()
            );

        assertNull(exprSwitch.getExpression());
View Full Code Here

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

        assertEquals("return 1", castAs(GoReturnStatement.class, 0, clause.getStatements()).getText());
    }

    public void testWithStatement() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "func main() int {\n" +
                      "     switch x := 1; x {\n" +
                      "         default:\n" +
                      "             return x\n" +
                      "     }\n" +
                      "     return nil\n" +
                      "}\n"));

        GoSwitchExpressionStatement exprSwitch =
            castAs(GoSwitchExpressionStatement.class, 0,
                   get(
                       get(
                           file.getMainFunction()
                       ).getBlock()
                   ).getStatements()
            );

        assertEquals("x := 1", get(exprSwitch.getSimpleStatement()).getText());
View Full Code Here

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

        assertEquals("x := 1", get(exprSwitch.getSimpleStatement()).getText());
        assertEquals("x", get(exprSwitch.getExpression()).getText());
    }

    public void testClauses() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "func main() int {\n" +
                      "     switch x := 1; x {\n" +
                      "         case 1:\n" +
                      "             a := 1\n" +
                      "             return a\n" +
                      "         default:\n" +
                      "             return x\n" +
                      "     }\n" +
                      "     return nil\n" +
                      "}\n"));

        GoSwitchExpressionStatement exprSwitch =
            castAs(GoSwitchExpressionStatement.class, 0,
                   get(
                       get(
                           file.getMainFunction()
                       ).getBlock()
                   ).getStatements()
            );

        assertEquals("x := 1", get(exprSwitch.getSimpleStatement()).getText());
View Full Code Here

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

        assertEquals(0, clause.getExpressions().length);
        assertTrue(clause.isDefault());
    }

    public void testClauseWithExpressionList() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "func main() int {\n" +
                      "     switch {\n" +
                      "         case 1, 2, 4:\n" +
                      "             a := 1\n" +
                      "             return a\n" +
                      "     }\n" +
                      "     return nil\n" +
                      "}\n"));

        GoSwitchExpressionStatement exprSwitch =
            castAs(GoSwitchExpressionStatement.class, 0,
                   get(
                       get(
                           file.getMainFunction()
                       ).getBlock()
                   ).getStatements()
            );

        assertNull(exprSwitch.getSimpleStatement());
View Full Code Here

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

public class GoPsiIntegerTest extends GoPsiTestCase {


    public void testBasic() throws Exception {
        GoFile file = get(
                parse("" +
                        "package main\n" +
                        "var (\n" +
                        "     x = 10\n" +
                        "     y = 0\n" +
                        "     z = 0120\n" +
                        "     h1 = 0xEF\n" +
                        "     h2 = 0XAB\n" +
                        "}"));

        GoVarDeclaration[] declarations =
                childAt(0,
                        file.getGlobalVariables()
                ).getDeclarations();

        GoLiteralInteger integer;

        // x
View Full Code Here

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

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

public class GoPsiStringsTest extends GoPsiTestCase {

    public void testBasic() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "var (\n" +
                      "     x = \"a\"\n" +
                      "     y = `b`\n" +
                      "     z = '本'\n" +
                      "     w = '\\U00101234'\n" +
                      "}"));

        GoVarDeclaration[] declarations =
            childAt(0,
                    file.getGlobalVariables()
            ).getDeclarations();

        GoLiteralString string =
            getAs(GoLiteralString.class,
                  getAs(GoLiteralExpression.class,
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.