Examples of GoFile


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

        assertNull(sliceExpression.getFirstIndex());
        assertEquals("j", get(sliceExpression.getSecondIndex()).getText());
        assertNull(sliceExpression.getCapacity());
    }
    public void testSliceCapacity() throws Exception {
        GoFile file = get(parse("package main; func a() { a[:j:k] }"));


        GoSliceExpression sliceExpression =
            getAs(GoSliceExpression.class,
                  castAs(GoExpressionStatement.class, 0,
                         get(
                             childAt(0,
                                     file.getFunctions()
                             ).getBlock()
                         ).getStatements()
                  ).getExpression()
            );
View Full Code Here

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

        assertEquals("j", get(sliceExpression.getSecondIndex()).getText());
        assertEquals("k", get(sliceExpression.getCapacity()).getText());
    }

    public void testSliceWithCommentsAndWhitespaces() throws Exception {
        GoFile file = get(parse("" +
                                    "package main; func a() { " +
                                    "   ad[\n" +
                                    "/**/ 1/**/:/**/2/**/] }\n" +
                                    ""));

        GoSliceExpression sliceExpression =
            getAs(GoSliceExpression.class,
                  castAs(GoExpressionStatement.class, 0,
                         get(
                             childAt(0,
                                     file.getFunctions()
                             ).getBlock()
                         ).getStatements()
                  ).getExpression()
            );

View Full Code Here

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

        assertEquals("1", get(sliceExpression.getFirstIndex()).getText());
        assertEquals("2", get(sliceExpression.getSecondIndex()).getText());
    }

    public void testNewSliceWithCommentsAndWhitespaces() throws Exception {
        GoFile file = get(parse("" +
                "package main; func a() { " +
                "   ad[\n" +
                "/**/ 1/**/:/**/2/**/:/**/3/**/] }\n" +
                ""));

        GoSliceExpression sliceExpression =
                getAs(GoSliceExpression.class,
                        castAs(GoExpressionStatement.class, 0,
                                get(
                                        childAt(0,
                                                file.getFunctions()
                                        ).getBlock()
                                ).getStatements()
                        ).getExpression()
                );

View Full Code Here

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

public class GoPsiBlockTest extends GoPsiTestCase {

    public void testListStatements() throws Exception {

        GoFile file = get(parse("" +
                                    "package main;\n" +
                                    "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.GoFile

        castAs(GoExpressionStatement.class, 1, block.getStatements());
    }

    public void testReturnWithExpressions() throws Exception {

        GoFile file = get(parse("" +
                                    "package main\n" +
                                    "func Ok4() (int, int) {\n" +
                                    "    return int(1), 1\n" +
                                    "}"));

        GoReturnStatement statement =
            castAs(GoReturnStatement.class, 0,
                   get(
                       childAt(0,
                               file.getFunctions()
                       ).getBlock()
                   ).getStatements()
            );

        castAs(GoCallOrConvExpression.class, 0, statement.getExpressions());
View Full Code Here

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

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

public class GoPsiFunctionLiteralTestCase extends GoPsiTestCase {
    public void testReturn() throws Exception {

        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "func main() {\n" +
                      "   f := func() int {\n" +
                      "            return 3\n" +
                      "        };\n" +
                      "}"));

        GoLiteralFunction lit =
            getAs(GoLiteralFunction.class,
                  castAs(GoLiteralExpression.class, 0,
                         castAs(GoShortVarDeclaration.class, 0,
                                get(
                                    childAt(0,
                                            file.getFunctions()
                                    ).getBlock()
                                ).getStatements()
                         ).getExpressions()
                  ).getLiteral());
View Full Code Here

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

public class GoPsiTypeAssertionsTest extends GoPsiTestCase {


    public void testBasic() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "var e = i.(int)"));

        GoTypeAssertionExpression typeAssertion =
            castAs(GoTypeAssertionExpression.class, 0,
                   childAt(0,
                           childAt(0,
                                   file.getGlobalVariables()
                           ).getDeclarations()
                   ).getExpressions()
            );

        assertEquals("i", get(typeAssertion.getBaseExpression()).getText());
View Full Code Here

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

        assertEquals("i", get(typeAssertion.getBaseExpression()).getText());
        assertEquals("int", get(typeAssertion.getAssertedType()).getText());
    }

    public void testArray() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "var e = i.([]int)"));

        GoTypeAssertionExpression typeAssertion =
            castAs(GoTypeAssertionExpression.class, 0,
                   childAt(0,
                           childAt(0,
                                   file.getGlobalVariables()
                           ).getDeclarations()
                   ).getExpressions()
            );

        assertEquals("i", get(typeAssertion.getBaseExpression()).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 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.GoFile

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

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