Documentation of 'org.python.indexer.AstCache' Java class
AstCache
org.python.indexer

Class AstCache



  • public class AstCache
    extends java.lang.Object
    Provides a factory for python source ASTs. Maintains configurable on-disk and in-memory caches to avoid re-parsing files during analysis.
    • Field Summary

      Fields 
      Modifier and Type Field and Description
      static java.lang.String CACHE_DIR 
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      void clear()
      Clears the memory cache.
      boolean clearDiskCache()
      Removes all serialized ASTs from the on-disk cache.
      static AstCache get() 
      NModule getAST(java.lang.String path)
      Returns the syntax tree for path.
      NModule getAST(java.lang.String path, java.lang.String contents)
      Returns the syntax tree for path with contents.
      java.lang.String getCachePath(java.io.File sourcePath)
      Each source file's AST is saved in an object file named for the MD5 checksum of the source file.
      java.lang.String getCachePath(java.lang.String md5, java.lang.String name) 
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • CACHE_DIR

        public static final java.lang.String CACHE_DIR
    • Method Detail

      • get

        public static AstCache get()
                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • clear

        public void clear()
        Clears the memory cache.
      • clearDiskCache

        public boolean clearDiskCache()
        Removes all serialized ASTs from the on-disk cache.
        Returns:
        true if all cached AST files were removed
      • getAST

        public NModule getAST(java.lang.String path)
                       throws java.lang.Exception
        Returns the syntax tree for path. May find and/or create a cached copy in the mem cache or the disk cache.
        Parameters:
        path - absolute path to a source file
        Returns:
        the AST, or null if the parse failed for any reason
        Throws:
        java.lang.Exception - if anything unexpected occurs
      • getAST

        public NModule getAST(java.lang.String path,
                              java.lang.String contents)
                       throws java.lang.Exception
        Returns the syntax tree for path with contents. Uses the memory cache but not the disk cache. This method exists primarily for unit testing.
        Parameters:
        path - a name for the file. Can be relative.
        contents - the source to parse
        Throws:
        java.lang.Exception
      • getCachePath

        public java.lang.String getCachePath(java.io.File sourcePath)
                                      throws java.lang.Exception
        Each source file's AST is saved in an object file named for the MD5 checksum of the source file. All that is needed is the MD5, but the file's base name is included for ease of debugging.
        Throws:
        java.lang.Exception
      • getCachePath

        public java.lang.String getCachePath(java.lang.String md5,
                                             java.lang.String name)

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.