public class AstCache
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CACHE_DIR |
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) |
public static AstCache get() throws java.lang.Exception
java.lang.Exception
public void clear()
public boolean clearDiskCache()
true
if all cached AST files were removedpublic NModule getAST(java.lang.String path) throws java.lang.Exception
path
. May find and/or create a
cached copy in the mem cache or the disk cache.path
- absolute path to a source filenull
if the parse failed for any reasonjava.lang.Exception
- if anything unexpected occurspublic NModule getAST(java.lang.String path, java.lang.String contents) throws java.lang.Exception
path
with contents
.
Uses the memory cache but not the disk cache.
This method exists primarily for unit testing.path
- a name for the file. Can be relative.contents
- the source to parsejava.lang.Exception
public java.lang.String getCachePath(java.io.File sourcePath) throws java.lang.Exception
java.lang.Exception
public java.lang.String getCachePath(java.lang.String md5, java.lang.String name)