Package org.python.pydev.parser.visitors.scope

Examples of org.python.pydev.parser.visitors.scope.EasyASTIteratorVisitor


        SimpleNode ast = edit.getAST();
        if (ast == null) {
            return true; //we need it to be correctly parsed with an ast to be able to do it...
        }

        EasyASTIteratorVisitor visitor = new EasyASTIteratorVisitor();
        try {
            ast.accept(visitor);
        } catch (Exception e1) {
            Log.log(e1);
            return true; //just go on
        }
        List<ASTEntry> availableImports = visitor.getAsList(new Class[] { ImportFrom.class, Import.class });

        PySourceViewer s = edit.getPySourceViewer();

        ArrayList<Tuple<MarkerAnnotationAndPosition, ASTEntry>> unusedImportsMarkers = new ArrayList<Tuple<MarkerAnnotationAndPosition, ASTEntry>>();
        ArrayList<Tuple<MarkerAnnotationAndPosition, ASTEntry>> unusedWildImportsMarkers = new ArrayList<Tuple<MarkerAnnotationAndPosition, ASTEntry>>();
View Full Code Here


     * @param ast the ast that corresponds to our context
     * @return the full name for the context where we are (in the format Class.method.xxx.xxx)
     */
    public static String getContextName(int lineNumber, SimpleNode ast) {
        if (ast != null) {
            EasyASTIteratorVisitor visitor = EasyASTIteratorVisitor.create(ast);
            Iterator<ASTEntry> classesAndMethodsIterator = visitor.getClassesAndMethodsIterator();
            ASTEntry last = null;
            while (classesAndMethodsIterator.hasNext()) {
                ASTEntry entry = classesAndMethodsIterator.next();
                if (entry.node.beginLine > lineNumber + 1) {
                    //ok, now, let's find out which context actually contains it...
View Full Code Here

        }
        return false;
    }

    public static ASTEntry findInitInClass(ClassDef d) {
        EasyASTIteratorVisitor visitor = EasyASTIteratorVisitor.create(d);

        for (Iterator<ASTEntry> it = visitor.getMethodsIterator(); it.hasNext();) {
            ASTEntry next = it.next();
            if (next.node != null) {
                String rep = NodeUtils.getRepresentationString(next.node);
                if ("__init__".equals(rep)) {
                    return next;
View Full Code Here

    private Iterator<ASTEntry> createModuleAndGetImports(String strDoc, Class classToGet) throws Exception {
        Document document = new Document(strDoc);
        SourceModule module = (SourceModule) AbstractModule.createModuleFromDoc(MODULE_NAME, null, document,
                CodeCompletionTestsBase.createStaticNature(), true);

        EasyASTIteratorVisitor visitor = new EasyASTIteratorVisitor();
        module.getAst().accept(visitor);
        Iterator<ASTEntry> iterator = visitor.getIterator(classToGet);
        return iterator;
    }
View Full Code Here

        // Source And Target are in Global Context
        assertTrue(NodeUtils.isValidContextForSetNext(ast, 25, 26));
    }

    private void checkEndLine(SimpleNode ast1, int endLine) {
        EasyASTIteratorVisitor visitor = EasyASTIteratorVisitor.create(ast1);

        List<ASTEntry> classes = visitor.getClassesAndMethodsList();
        assertEquals(1, classes.size());
        assertEquals(endLine, classes.get(0).endLine);
    }
View Full Code Here

TOP

Related Classes of org.python.pydev.parser.visitors.scope.EasyASTIteratorVisitor

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.