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

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


        // create a stream with document's data
        String startDoc = info.document.get();
        if (startDoc.trim().length() == 0) {
            //If empty, don't bother to parse!
            return new Tuple<SimpleNode, Throwable>(new Module(new stmtType[0]), null);
        }
        char[] charArray = createCharArrayToParse(startDoc);
        startDoc = null; //it can be garbage-collected now.

        Tuple<SimpleNode, Throwable> returnVar = new Tuple<SimpleNode, Throwable>(null, null);
View Full Code Here


        return returnVar;
    }

    public static Tuple<SimpleNode, Throwable> createCythonAst(IDocument doc) {
        List<stmtType> classesAndFunctions = FastParser.parseCython(doc);
        return new Tuple<SimpleNode, Throwable>(new Module(classesAndFunctions.toArray(new stmtType[classesAndFunctions
                .size()])), null);
    }
View Full Code Here

                }
            }
            PySelection selection = new PySelection(info.getDocument(), userSelection);
            int startLineIndexIndocCoords = selection.getStartLineIndex();
            int startLineIndexInASTCoords = startLineIndexIndocCoords + 1; //from doc to ast
            Module module = info.getModuleAdapter().getASTNode();
            SimpleNode currentScope = module;

            try {
                FindScopeVisitor scopeVisitor = new FindScopeVisitor(startLineIndexInASTCoords,
                        selection.getCursorColumn() + 1);
                module.accept(scopeVisitor);
                ILocalScope scope = scopeVisitor.scope;
                FastStack scopeStack = scope.getScopeStack();
                currentScope = (SimpleNode) scopeStack.peek(); //at least the module should be there if we don't have anything.
            } catch (Exception e1) {
                Log.log(e1);
View Full Code Here

    private exprType extractExpression(ModuleAdapter node) {
        if (node == null) {
            return null;
        }
        Module astNode = node.getASTNode();
        if (astNode == null) {
            return null;
        }
        stmtType[] body = astNode.body;
View Full Code Here

        SimpleNode ret;

        switch (id) {

            case JJTFILE_INPUT:
                ret = new Module(null);
                break;

            case JJTFALSE:
                ret = new Name("False", Name.Load, true);
                break;
View Full Code Here

        switch (n.getId()) {
            case -1:
                throw new ParseException("Illegal node found: " + n, n);

            case JJTFILE_INPUT:
                Module m = (Module) n;
                m.body = makeStmts(arity);
                return m;

            case JJTFALSE:
            case JJTTRUE:
View Full Code Here

                    IToken tok = ret[i];
                    if ("__bootstrap__".equals(tok.getRepresentation())) {
                        //if we get here, we already know that it defined a __bootstrap__, so, let's see if it was also called
                        SimpleNode ast = this.getAst();
                        if (ast instanceof Module) {
                            Module module = (Module) ast;
                            if (module.body != null && module.body.length > 0) {
                                ast = module.body[module.body.length - 1];
                                if (ast instanceof Expr) {
                                    Expr expr = (Expr) ast;
                                    ast = expr.value;
View Full Code Here

    /**
     * @return the body of the passed node (if it doesn't have a body, an empty array is returned).
     */
    public static stmtType[] getBody(SimpleNode node) {
        if (node instanceof Module) {
            Module module = (Module) node;
            return module.body;
        }

        if (node instanceof ClassDef) {
            ClassDef module = (ClassDef) node;
View Full Code Here

            Log.log("Error parsing: " + moduleName + "\nContents:\n" + new String(cs, 0, len > 1000 ? 1000 : len),
                    runtimeException); //report at most 1000 chars...
            throw runtimeException;
        }
        List<stmtType> body = parser.body;
        Module ret = new Module(body.toArray(new stmtType[body.size()]));
        if (parseCallbacks.size() > 0) {
            Tuple<String, SimpleNode> arg = new Tuple<String, SimpleNode>(moduleName, ret);
            for (ICallback<Object, Tuple<String, SimpleNode>> c : parseCallbacks) {
                c.call(arg);
            }
View Full Code Here

                "a.get().a.get()\n" + //20 - 36
                "a.get(  ).foo\n" + //36 - 50
                "a.get( #comma.get()ent\n ).foo\n" + //50 - 80
                "a.\\\nget().foo\n" + //80
                "";
        Module mod = (Module) parseLegalDocStr(s);
        stmtType b0 = mod.body[0];

        Document doc = new Document(s);
        FindDuplicatesVisitor visitor = new FindDuplicatesVisitor(new TextSelection(doc, 0, 7), ((Expr) b0).value, doc);
        mod.accept(visitor);
        List<Tuple<ITextSelection, SimpleNode>> duplicates = visitor.getDuplicates();

        Comparator<? super Tuple<Integer, Integer>> comparator = new Comparator<Tuple<Integer, Integer>>() {

            public int compare(Tuple<Integer, Integer> o1, Tuple<Integer, Integer> o2) {
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.