Examples of FunctionDef


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

                    case FIELD:

                        parametersAfterCall = checkFirst(parametersAfterCall, "self");
                        FunctionDefAdapter firstInit = targetClass.getFirstInit();
                        if (firstInit != null) {
                            FunctionDef astNode = firstInit.getASTNode();
                            replacePassStatement = getLastPassFromNode(astNode);

                            //Create the field as the last line in the __init__
                            int nodeLastLine = firstInit.getNodeLastLine() - 1;
                            indent = firstInit.getNodeBodyIndent();
View Full Code Here

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

                            ImageCache.DECORATION_LOCATION_BOTTOM_RIGHT);
                default:
                    return imageCache.get(UIConstants.CLASS_ICON);
            }
        } else if (token instanceof FunctionDef) {
            FunctionDef functionDefToken = (FunctionDef) token;

            String methodName = NodeUtils.getNameFromNameTok((NameTok) ((FunctionDef) token).name);
            String qualifierIcon = null;
            switch (qualifierFromName(methodName)) {
                case QUALIFIER_PRIVATE:
View Full Code Here

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

        if (nodeHelper.isClassDef(node)) {

            ClassDef classNode = (ClassDef) node;
            for (stmtType statement : classNode.body) {
                if (nodeHelper.isInit(statement)) {
                    FunctionDef func = (FunctionDef) statement;
                    stmtType lastStmt = func.body[func.body.length - 1];
                    LastLineVisitor visitor = VisitorFactory.createVisitor(LastLineVisitor.class, lastStmt);
                    return visitor.getLastLine();
                }
            }
View Full Code Here

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

        fail("The token requested (" + req + ") was not found.");
        return null;
    }

    private FunctionDef createFuncDef(String metName) {
        return new FunctionDef(new NameTok(metName, NameTok.FunctionName), null, null, null, null);
    }
View Full Code Here

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

            } else if (node instanceof Attribute) {
                Attribute attribute = (Attribute) node;
                node = attribute.attr;

            } else if (node instanceof FunctionDef) {
                FunctionDef def = (FunctionDef) node;
                node = def.name;

            } else if (node instanceof Import) {
                ArrayList<SimpleNode> ret = new ArrayList<SimpleNode>();
                Import importToken = (Import) node;
View Full Code Here

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

            }
        }));
    }

    public void testPyAstFactory() throws Exception {
        FunctionDef functionDef = astFactory.createFunctionDef("MyMethod");

        String expected = "" +
                "def MyMethod():\n" +
                "    pass\n" +
                "";
View Full Code Here

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

                "    A.__init__(self,arg)\n"
                +
                "    self.attribute = attribute\n" +
                "";

        FunctionDef functionDef = astFactory.createFunctionDef("__init__");
        functionDef.args = astFactory.createArguments(true, "arg", "attribute");
        astFactory.setBody(functionDef, astFactory.createCall("A.__init__", "self", "arg"), astFactory.createAssign(
                astFactory.createAttribute("self.attribute"), new Name("attribute", Name.Load, false)));
        checkExpected(functionDef, expected);
    }
View Full Code Here

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

        String expected = "" +
                "def test(self,arg,attribute):\n" +
                "    Parent.test(self,arg,attribute)\n" +
                "";

        FunctionDef functionDef = astFactory.createFunctionDef("test");
        functionDef.args = astFactory.createArguments(true, "arg", "attribute");
        astFactory.setBody(functionDef, astFactory.createOverrideBody(functionDef, "Parent", "Current"));
        checkExpected(functionDef, expected);
    }
View Full Code Here

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

                +
                "    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

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

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