public class InMemoryRegistryPlugin extends BasePlugin
BasePlugin.Pair
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.String,Aast> |
asts
In-memory storage of ASTs, by their name.
|
dirty, fids, fnames, HIGH_BITS, locklist, MAX_POSSIBLE, TREE_MASK
Constructor and Description |
---|
InMemoryRegistryPlugin() |
Modifier and Type | Method and Description |
---|---|
boolean |
isExistingAst(java.lang.String name)
Check if the AST specified by the given name exists already in the plugin's storage.
|
Aast |
loadTree(java.lang.String name)
Load a named AST from the in-memory storage, by returning a copy of the
asts
entry after using the specified name as the key. |
boolean |
removeTree(long id)
Removes this tree from the in-memory storage.
|
void |
save()
A no-op for this in-memory storage.
|
void |
saveTree(Aast ast,
java.lang.String name,
boolean terse)
Save the given AST to in-memory storage under the given name.
|
private void |
terseTree(Aast ast)
Set the line and column information to 0 for the entire tree.
|
boolean |
usesMemoryStorage()
Does this plug-in use memory as its primary storage medium? This implementation overrides
the superclass' implementation to return
true . |
addTree, getNextNodeId, getTreeId, getTreeId, getTreeName, isInvalid, lockTree, resetNextNodeId, setNextNodeId, unlockTree
private final java.util.Map<java.lang.String,Aast> asts
public boolean usesMemoryStorage()
true
.usesMemoryStorage
in interface AstManagerPlugin
usesMemoryStorage
in class BasePlugin
true
.public Aast loadTree(java.lang.String name) throws AstException, java.lang.IllegalArgumentException
asts
entry after using the specified name
as the key.name
- The name of the tree. Often this is a file name.AstException
- On any error during the loading process.java.lang.IllegalArgumentException
- If the name is invalid or the specified resource doesn't exist.public void saveTree(Aast ast, java.lang.String name, boolean terse) throws AstException, java.lang.IllegalArgumentException
asts
map, usin the specified name as the key.ast
- The tree to save.name
- The name of the tree. Often this is a file name.terse
- Do not store line and column data when the node data is saved.AstException
- On any error during the saving process.java.lang.IllegalArgumentException
- If the name is invalid or the specified resource cannot be
used as a target to store the AST.public void save() throws AstException
AstException
- On any failure.public boolean removeTree(long id) throws AstException
removeTree
in interface AstManagerPlugin
removeTree
in class BasePlugin
id
- The ID the tree to remove.true
if the tree existed in the registry (and
was removed), false
if the tree didn't exist.AstException
BasePlugin.removeTree(long)
public boolean isExistingAst(java.lang.String name)
name
- The name (including path) of the AST file to be checked.true
if the specified AST is in the plugin's storage.private void terseTree(Aast ast)
ast
- The AST which needs the column/line information to be removed.