Package org.python.pydev.parser.jython.ast

Examples of org.python.pydev.parser.jython.ast.Module


            public int getGrammarVersion() throws MisconfigurationException {
                return IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_3_0;
            }
        };
        setDefaultVersion(IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_3_0);
        Module node = (Module) parseLegalDocStr(s);
        FunctionDef funcDef = (FunctionDef) node.body[0];
        String result = PrettyPrinterV2.printArguments(p, funcDef.args);
        assertEquals("*, a", result);
    }
View Full Code Here


            public int getGrammarVersion() throws MisconfigurationException {
                return IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_3_0;
            }
        };
        setDefaultVersion(IGrammarVersionProvider.GRAMMAR_PYTHON_VERSION_3_0);
        Module node = (Module) parseLegalDocStr(s);
        FunctionDef funcDef = (FunctionDef) node.body[0];
        String result = PrettyPrinterV2.printArguments(p, funcDef.args);
        assertEquals("**a", result);
    }
View Full Code Here

                "    a = 1\n" +
                "finally:\n" +
                "    pass\n" +
                "";
        SimpleNode node = checkPrettyPrintEqual(str);
        Module m = (Module) node;
        SimpleNode f = (SimpleNode) m.body[0];
        assertEquals(1, f.beginLine);
    }
View Full Code Here

        final String s = "" +
                "def Method(a,b,c=10,d=20,*args,**kwargs):\n" +
                "    pass\n" +
                "";

        Module node = (Module) parseLegalDocStr(s);
        FunctionDef funcDef = (FunctionDef) node.body[0];
        assertEquals("a, b, c=10, d=20, *args, **kwargs", PrettyPrinterV2.printArguments(versionProvider, funcDef.args));

    }
View Full Code Here

        final String s = "" +
                "def Method((a, b), c):\n" +
                "    pass\n" +
                "";

        Module node = (Module) parseLegalDocStr(s);
        FunctionDef funcDef = (FunctionDef) node.body[0];
        //yes, just making sure it's not supported.
        assertEquals("(a, b), c", PrettyPrinterV2.printArguments(versionProvider, funcDef.args));

    }
View Full Code Here

                "@classdec2\n" +
                "class A:\n" +
                "    pass\n" +
                "";
        SimpleNode ast = parseLegalDocStr(s);
        Module m = (Module) ast;
        ClassDef d = (ClassDef) m.body[0];
        assertEquals(2, d.decs.length);
        assertEquals("classdec", NodeUtils.getRepresentationString(d.decs[0].func));
        assertEquals("classdec2", NodeUtils.getRepresentationString(d.decs[1].func));
    }
View Full Code Here

     * This test checks the new relative import
     */
    public void testNewRelativeImport() {
        setDefaultVersion(IPythonNature.GRAMMAR_PYTHON_VERSION_2_5);
        String str = "from . import foo\n";
        Module mod = (Module) parseLegalDocStr(str);
        ImportFrom f = (ImportFrom) mod.body[0];
        assertEquals(1, f.level);
        assertEquals("", ((NameTok) f.module).id);
    }
View Full Code Here

    }

    public void testNewRelativeImport2() {
        setDefaultVersion(IPythonNature.GRAMMAR_PYTHON_VERSION_2_5);
        String str = "from ..bar import foo\n";
        Module mod = (Module) parseLegalDocStr(str);
        ImportFrom f = (ImportFrom) mod.body[0];
        assertEquals(2, f.level);
        assertEquals("bar", ((NameTok) f.module).id);
    }
View Full Code Here

    }

    public void testNewRelativeImport3() {
        setDefaultVersion(IPythonNature.GRAMMAR_PYTHON_VERSION_2_5);
        String str = "from ... import foo\n";
        Module mod = (Module) parseLegalDocStr(str);
        ImportFrom f = (ImportFrom) mod.body[0];
        assertEquals(3, f.level);
        assertEquals("", ((NameTok) f.module).id);
    }
View Full Code Here

    }

    public void testNewRelativeImport4() {
        setDefaultVersion(IPythonNature.GRAMMAR_PYTHON_VERSION_2_5);
        String str = "from ...bar import foo\n";
        Module mod = (Module) parseLegalDocStr(str);
        ImportFrom f = (ImportFrom) mod.body[0];
        assertEquals(3, f.level);
        assertEquals("bar", ((NameTok) f.module).id);
    }
View Full Code Here

TOP

Related Classes of org.python.pydev.parser.jython.ast.Module

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.