Package ro.redeul.google.go.lang.psi

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


        assertEquals(GoLiteral.Type.Char, aChar.getType());
        assertEquals('ሴ', (char)aChar.getValue());
    }

    public void testRune() throws Exception {
        GoFile file = get(
                parse("" +
                        "package main\n" +
                        "var (\n" +
                        "     x0 = '1'\n" +
                        "     x1 = 'a'\n" +
                        "     x2 = 'ä'\n" +
                        "     x3 = '本'\n" +
                        "     x4 = '\\t'\n" +
                        "     x5 = '\\000'\n" +
                        "     x6 = '\\007'\n" +
                        "     x7 = '\\377'\n" +
                        "     x8 = '\\x07'\n" +
                        "     x9 = '\\xff'\n" +
                        "     x10 = '\\u12e4'\n" +
                        "     x11 = '\\U00101234'\n" +
                        "     x12 = '\\\\'\n" +
                        "     x13 = '\\\''\n" +
                        "}"));

        HashMap<Integer,Integer> testRuneValues = new HashMap<Integer, Integer>();

        testRuneValues.put(0, 49);
        testRuneValues.put(1, 97);
        testRuneValues.put(2, 228);
        testRuneValues.put(3, 26412);
        testRuneValues.put(4, 9);
        testRuneValues.put(5, 0);
        testRuneValues.put(6, 7);
        testRuneValues.put(7, 255);
        testRuneValues.put(8, 7);
        testRuneValues.put(9, 255);
        testRuneValues.put(10, 4836);
        testRuneValues.put(11, 1053236);
        testRuneValues.put(12, 92);
        testRuneValues.put(13, 39);

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

        GoLiteralChar aChar;

        for (Map.Entry<Integer, Integer> entry : testRuneValues.entrySet()) {
View Full Code Here


        String script = content.replace(GoTestUtils.MARKER_BEGIN, "").replaceAll("/\\*end\\.[^\\*/]*\\*/", "");
        return Arrays.asList(script, content);
    }

    protected String processFile(String fileText) throws Exception {
        GoFile file = (GoFile) myFixture.configureByText(GoFileType.INSTANCE, fileText);
        Document document = myFixture.getDocument(file);
        StringBuilder sb = new StringBuilder();
        int pos = 0;

        Set<TextAttributesKey> keys = getAllKeysFromGoSyntaxHighlighter();
View Full Code Here

    public void testOther2()        { doTest("test() && a < 3 || a > 10", "(!test() || a >= 3) && a <= 10"); }
    public void testOther3()        { doTest("a == 3 || a > 5 && a % 2 == 0", "a != 3 && (a <= 5 || a % 2 != 0)"); }

    private void doTest(String expressionToFlip, String expectedResult) {
        String text = String.format("package main\nvar a=%s", expressionToFlip);
        GoFile file = (GoFile) myFixture.configureByText(GoFileType.INSTANCE, text);
        GoExpr expr = file.getGlobalVariables()[0].getDeclarations()[0].getExpressions()[0];
        Assert.assertEquals(expectedResult, FlipBooleanExpression.flip(expr));
    }
View Full Code Here

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

public class GoPsiSelectStatementTest extends GoPsiTestCase {

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

        GoSelectStatement selectStatement =
            castAs(GoSelectStatement.class, 0,
                   get(
                       childAt(0,
                               file.getFunctions()
                       ).getBlock()
                   ).getStatements()
            );

        assertNotNull(selectStatement);
View Full Code Here

        assertNotNull(selectStatement);
    }

    public void testSelectWithDefault() throws Exception {
        GoFile file = get(parse("" +
                                    "package main; " +
                                    "func main() { " +
                                    "   select {" +
                                    "       default:{}" +
                                    "   } " +
                                    "}"));

        GoSelectStatement selectStatement =
            castAs(GoSelectStatement.class, 0,
                   get(
                       childAt(0,
                               file.getFunctions()
                       ).getBlock()
                   ).getStatements()
            );

        assertEquals(1, selectStatement.getCommClauses().length);
View Full Code Here

        assertEquals(commClauseDefault.getText(), "default:{}");
    }

    public void testSelectCommClauseRecv1() throws Exception {
        GoFile file = get(parse("" +
                                    "package main; " +
                                    "func main() {" +
                                    "   select {" +
                                    "       case i1 = <-c1: {}" +
                                    "   } " +
                                    "}"));

        GoSelectStatement selectStatement =
            castAs(GoSelectStatement.class, 0,
                   get(
                       childAt(0,
                               file.getFunctions()
                       ).getBlock()
                   ).getStatements()
            );

        assertEquals(1, selectStatement.getCommClauses().length);
View Full Code Here

        assertEquals("<-c1", get(clauseRecv.getReceiveExpression()).getText());
    }

    public void testSelectCommClauseRecv2() throws Exception {
        GoFile file = get(parse("" +
                                    "package main; " +
                                    "func main() {" +
                                    "   select {" +
                                    "       case i1 := <-c1: {}" +
                                    "   } " +
                                    "}"));

        GoSelectStatement selectStatement =
            castAs(GoSelectStatement.class, 0,
                   get(
                       childAt(0,
                               file.getFunctions()
                       ).getBlock()
                   ).getStatements()
            );

        assertEquals(1, selectStatement.getCommClauses().length);
View Full Code Here

        if (list.size() != 3) {
            Assert.fail("invalid test case file");
        }

        GoFile goFile = (GoFile)
            GoTestUtils.createPseudoPhysicalGoFile(getProject(), list.get(0));

        GoRecursiveCollectorVisitor visitor = visitorForElementType(list.get(1));
        visitor.visitElement(goFile);
View Full Code Here

public class GoPsiCompositeLiteralsTest extends GoPsiTestCase {


    public void testKey() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "var e = Line{key:1, 2:1)"));

        GoLiteralCompositeValue value =
            get(
                getAs(GoLiteralComposite.class,
                      castAs(GoLiteralExpression.class, 0,
                             childAt(0,
                                     childAt(0,
                                             file.getGlobalVariables()
                                     ).getDeclarations()
                             ).getExpressions()
                      ).getLiteral()
                ).getValue());
View Full Code Here

                           ).getLiteral()
                     ).getText());
    }

    public void testNestedLiteral() throws Exception {
        GoFile file = get(
            parse("" +
                      "package main\n" +
                      "var e = Line{origin, Point{y: -4, z: 12.3}}\n"));


        GoLiteralComposite composite =
            getAs(GoLiteralComposite.class,
                  castAs(GoLiteralExpression.class, 0,
                         childAt(0,
                                 childAt(0,
                                         file.getGlobalVariables()
                                 ).getDeclarations()
                         ).getExpressions()
                  ).getLiteral());

        assertEquals("Line",
View Full Code Here

TOP

Related Classes of ro.redeul.google.go.lang.psi.GoFile

Copyright © 2018 www.massapicom. 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.