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

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


     *
     * @param source: this is the ast that contains the body with multiple statements.
     * @param ast: This is the ast for which we want the statement.
     */
    public static stmtType findStmtForNode(SimpleNode source, final SimpleNode ast) {
        VisitorBase v = new VisitorBase() {

            private stmtType lastStmtFound;

            @Override
            protected Object unhandled_node(SimpleNode node) throws Exception {
View Full Code Here


    /**
     * used if we want to visit all in a call but the func itself (that's the call name).
     */
    protected static void visitCallAttr(Call c, VisitorBase base) throws Exception {
        //now, visit all inside it but the func itself
        VisitorBase visitor = base;
        if (c.func instanceof Attribute) {
            base.visitAttribute((Attribute) c.func);
        }
        if (c.args != null) {
            for (int i = 0; i < c.args.length; i++) {
View Full Code Here

     * @param currentClassName
     */
    public stmtType createOverrideBody(FunctionDef functionDef, String parentClassName, String currentClassName) {
        //create a copy because we do not want to retain the original line/col and we may change the originals here.
        final boolean[] addReturn = new boolean[] { false };
        VisitorBase visitor = new VisitorBase() {

            public Object visitClassDef(ClassDef node) throws Exception {
                return null;
            }

            public Object visitFunctionDef(FunctionDef node) throws Exception {
                return null; //don't visit internal scopes.
            }

            @Override
            protected Object unhandled_node(SimpleNode node) throws Exception {
                if (node instanceof Return) {
                    addReturn[0] = true;
                    throw stopVisitingException;
                }
                return null;
            }

            @Override
            public void traverse(SimpleNode node) throws Exception {
                node.traverse(this);
            }
        };
        try {
            visitor.traverse(functionDef);
        } catch (Exception e) {
            if (e != stopVisitingException) {
                Log.log(e);
            }
        }
View Full Code Here

TOP

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

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.