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

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


    public void runTest() throws Throwable {
        FileUtilsFileBuffer.IN_TESTS = true;
        MockupExtractMethodConfig config = initConfig();

        IDocument doc = new Document(data.source);
        Module astModule = VisitorFactory.getRootNode(doc, createVersionProvider());
        String name = data.file.getName();
        name = name.substring(0, name.length() - EXTENSION);
        ModuleAdapter module = new ModuleAdapter(null, data.file, doc, astModule, new PythonNatureStub());

        if (data.sourceSelection == null) {
View Full Code Here


        final String expected = "return [1,2,self.call(*a)]\n";

        checkWithAllGrammars(new ICallback<Boolean, Integer>() {

            public Boolean call(Integer version) {
                Module module = (Module) parseLegalDocStr(s);
                exprType value = ((Expr) module.body[0]).value;
                Return node = new Return((exprType) value.createCopy());
                try {
                    MakeAstValidForPrettyPrintingVisitor.makeValid(node);
                } catch (Exception e) {
View Full Code Here

    /**
     * Note that the line returned is 1-based.
     */
    @Override
    public int getNodeFirstLine() {
        Module astNode = getASTNode();
        for (int i = 0; i < astNode.body.length; i++) {
            SimpleNode node = astNode.body[i];
            if (!nodeHelper.isImport(node) && !nodeHelper.isStr(node)) {
                return node.beginLine;
            }
View Full Code Here

        IntegrityInfo info = AdditionalInfoIntegrityChecker.checkIntegrity(nature, monitor, false);
        assertTrue(info.desc.toString(), info.allOk);

        File f = FileUtils.getTempFileAt(baseDir, "integrity_no_file", ".py");
        FileUtils.writeStrToFile("", f);
        addFooModule(new Module(new stmtType[0]), f);
        info = AdditionalInfoIntegrityChecker.checkIntegrity(nature, monitor, false);
        assertFalse(info.allOk);
        assertEquals(1, info.modulesNotInDisk.size());
        assertEquals(info.modulesNotInDisk.get(0), new ModulesKey("foo", null));
View Full Code Here

                "def test(arg,attribute,*args,**kwargs):\n"
                +
                "    return Parent.test(arg,attribute,*args,**kwargs)\n" +
                "";

        Module module = (Module) parseLegalDocStr(expected);
        FunctionDef functionDef = (FunctionDef) module.body[0];
        FunctionDef createdFunctionDef = astFactory.createFunctionDef("test");
        createdFunctionDef.args = functionDef.args.createCopy();
        astFactory.setBody(createdFunctionDef, astFactory.createOverrideBody(functionDef, "Parent", "Current"));
        checkExpected(createdFunctionDef, expected);
View Full Code Here

                "def test(arg,attribute,a=10,b=20,*args,**kwargs):\n"
                +
                "    Parent.test(arg,attribute,a=a,b=b,*args,**kwargs)\n" +
                "";

        Module module = (Module) parseLegalDocStr(base);
        FunctionDef functionDef = (FunctionDef) module.body[0];
        FunctionDef createdFunctionDef = astFactory.createFunctionDef("test");
        createdFunctionDef.args = functionDef.args.createCopy();
        astFactory.setBody(createdFunctionDef, astFactory.createOverrideBody(functionDef, "Parent", "Current"));
        checkExpected(createdFunctionDef, expected);
View Full Code Here

                "";
        //        Module m = (Module) parseLegalDocStr(expected);
        //        FunctionDef func = (FunctionDef) m.body[0];
        //        System.out.println(func.body[0]);

        Module module = (Module) parseLegalDocStr(base);
        FunctionDef functionDef = (FunctionDef) module.body[0];
        FunctionDef createdFunctionDef = functionDef.createCopy();
        astFactory.setBody(createdFunctionDef, astFactory.createOverrideBody(functionDef, "Parent", "Current"));
        checkExpected(createdFunctionDef, expected);
    }
View Full Code Here

                "@classmethod\n" +
                "def test(cls):\n" +
                "    super(Current,cls).test()\n" +
                "";

        Module module = (Module) parseLegalDocStr(base);
        FunctionDef functionDef = (FunctionDef) module.body[0];
        FunctionDef createdFunctionDef = functionDef.createCopy(false);
        astFactory.setBody(createdFunctionDef, astFactory.createOverrideBody(functionDef, "Parent", "Current"));
        checkExpected(createdFunctionDef, expected);
    }
View Full Code Here

            SourceModule moduleTest = (SourceModule) AbstractModule.createModuleFromDoc("test", null, new Document(
                    testDoc), grammarVersionProvider, true);
            SourceModule moduleBar = (SourceModule) AbstractModule.createModuleFromDoc("bar", null,
                    new Document(barDoc), grammarVersionProvider, true);

            Module astTest = (Module) moduleTest.getAst();
            Module astBar = (Module) moduleBar.getAst();

            HierarchyNodeModel testModel = new HierarchyNodeModel("test", (ClassDef) astTest.body[2]);
            HierarchyNodeModel barModel = new HierarchyNodeModel("bar", (ClassDef) astBar.body[0]);
            testModel.parents.add(barModel);
View Full Code Here

                "    args" +
                "";

        Document doc = new Document(d);
        SourceModule module = (SourceModule) AbstractModule.createModuleFromDoc("", null, doc, nature, true);
        Module ast = (Module) module.getAst();
        assertEquals(1, ast.body.length);
        ICompletionState emptyCompletionState = CompletionStateFactory.getEmptyCompletionState("args", nature,
                new CompletionCache());
        Definition[] defs = (Definition[]) module.findDefinition(emptyCompletionState, 2, 7, nature);
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.