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

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


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


                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

                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

                "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

                "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

        stmtType[] body = ((Module) ast).body;
        assertEquals(1, body.length);
        ClassDef classFound = (ClassDef) body[0];
        body = classFound.body;
        assertEquals(1, body.length);
        FunctionDef func = (FunctionDef) body[0];
        If ifFound = (If) func.body[0];
        assertEquals(6, ifFound.orelse.beginLine);

    }
View Full Code Here

                "def m1():\n" +
                "    yield from a" +
                "";

        Module ast = (Module) parseLegalDocStr(s);
        FunctionDef f = (FunctionDef) ast.body[0];
        Expr e = (Expr) f.body[0];
        Yield y = (Yield) e.value;
        assertTrue("Expected yield to be a yield from.", y.yield_from);

        parseLegalDocStrWithoutTree(s);
View Full Code Here

                "        Method1(10, param2=20)\n" +
                "        Method1(param1=10, param2=20)\n" +
                "";
        Module root = (Module) parseLegalDocStr(s);
        ClassDef classDef = (ClassDef) root.body[0];
        FunctionDef funcDef = (FunctionDef) classDef.body[0];
        Expr expr = (Expr) funcDef.body[1];
        Call call = (Call) expr.value;
        Name name = (Name) call.func;
        FindCallVisitor visitor = new FindCallVisitor(name);
        visitor.traverse(root);
View Full Code Here

    public PyAstFactory(AdapterPrefs adapterPrefs) {
        nodeHelper = new NodeHelper(adapterPrefs);
    }

    public FunctionDef createFunctionDef(String name) {
        FunctionDef functionDef = new FunctionDef(new NameTok(name, NameTok.FunctionName), null, null, null, null);
        return functionDef;
    }
View Full Code Here

    public FunctionDef createSetterFunctionDef(String accessorName, String attributeName) {
        NameTok functionName = new NameTok(accessorName, NameTok.FunctionName);
        argumentsType args = createArguments(true, "value");
        stmtType[] body = createSetterBody(attributeName);

        return new FunctionDef(functionName, args, body, null, null);
    }
View Full Code Here

TOP

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

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.