Examples of NModule


Examples of org.python.indexer.ast.NModule

        assertAttributeBinding("sys.flags");
        assertBindingType("sys.flags", NDictType.class);
    }

    public void testFetchAst() throws Exception {
        NModule ast = idx.getAstForFile(abspath("hello.py"));
        assertNotNull("failed to load file", ast);
        assertEquals("module has wrong name", "hello", ast.name);
        assertNotNull("AST has no body", ast.body);
        assertNotNull("AST body has no children", ast.body.seq);
        assertEquals("wrong number of children", 1, ast.body.seq.size());
View Full Code Here

Examples of org.python.indexer.ast.NModule

    public void testAstCache() throws Exception {
        AstCache cache = AstCache.get();
        String sourcePath = abspath("hello.py");

        // ensure not cached on disk
        NModule ast = cache.getSerializedModule(sourcePath);
        assertNull(ast);

        cache.getAST(sourcePath);

        // ensure cached on disk
        ast = cache.getSerializedModule(sourcePath);
        assertNotNull(ast);

        assertEquals(sourcePath, ast.getFile());
    }
View Full Code Here

Examples of org.python.indexer.ast.NModule

        assertEquals(sourcePath, ast.getFile());
    }

    public void testAstCacheEmptyFile() throws Exception {
        AstCache cache = AstCache.get();
        NModule mod = cache.getAST(abspath("empty_file.py"));
        assertNotNull(mod);
        NBlock seq = mod.body;
        assertNotNull(seq);
        assertTrue(seq.seq.isEmpty());
    }
View Full Code Here

Examples of org.python.indexer.ast.NModule

        assertNoneType(new NIndex(null));
        assertNoneType(new NKeyword(null, null));
        assertNoneType(new NLambda(null, null, null, null, null));
        assertNoneType(new NList(null));
        assertNoneType(new NListComp(null, null));
        assertNoneType(new NModule(null, 0, 1));
        assertNoneType(new NName(""));
        assertNoneType(new NNum(-1));
        assertNoneType(new NPass());
        assertNoneType(new NPlaceHolder());
        assertNoneType(new NPrint(null, null));
View Full Code Here

Examples of org.python.indexer.ast.NModule

            "deco.py",
            deco1,
            deco2,
            "def foo(): pass");
        assertFunctionBinding("deco.foo");
        NModule m = idx.getAstForFile("deco.py");
        assertNotNull(m);

        NNode obj = m.body.seq.get(0);
        assertTrue(obj instanceof NFunctionDef);
        NFunctionDef f = (NFunctionDef)obj;
View Full Code Here

Examples of org.python.indexer.ast.NModule

        // Cache stores null value if the parse failed.
        if (cache.containsKey(path)) {
            return cache.get(path);
        }

        NModule mod = null;
        try {
            mod = parse(path, contents);
            if (mod != null) {
                mod.setFileAndMD5(path, Util.getMD5(contents.getBytes("UTF-8")));
            }
        } finally {
            cache.put(path, mod)// may be null
        }
        return mod;
View Full Code Here

Examples of org.python.indexer.ast.NModule

        if (cache.containsKey(path)) {
            return cache.get(path);
        }

        // Might be cached on disk but not in memory.
        NModule mod = getSerializedModule(path);
        if (mod != null) {
            fine("reusing " + path);
            cache.put(path, mod);
            return mod;
        }
View Full Code Here

Examples of org.python.indexer.ast.NModule

        if (!(obj instanceof NModule)) {
            warn("\n[warning] converted AST is not a module: " + obj);
            return null;
        }

        NModule module = (NModule)obj;
        if (new File(path).canRead()) {
            module.setFile(path);
        }
        return module;
    }
View Full Code Here

Examples of org.python.indexer.ast.NModule

     * @param src file contents
     */
    public List<StyleRun> addStyles(String path, String src) throws Exception {
        this.path = path;
        source = src;
        NModule m = indexer.getAstForFile(path);
        if (m != null) {
            m.visit(this);
            highlightLexicalTokens();
        }
        return styles;
    }
View Full Code Here

Examples of org.python.indexer.ast.NModule

        FileInputStream fis = null;
        ObjectInputStream ois = null;
        try {
            fis = new FileInputStream(cachePath);
            ois = new ObjectInputStream(fis);
            NModule mod = (NModule)ois.readObject();
            // Files in different dirs may have the same base name and contents.
            mod.setFile(sourcePath);
            return mod;
        } finally {
            if (ois != null) {
                ois.close();
            } else if (fis != null) {
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.