public class MemoryUnitCache extends Object implements UnitCache
CompilationUnit
instances in a Map.
Only one unit is cached per resource path. If the contentId of the unit
changes, the old unit is discarded and replaced with the new unit.Modifier and Type | Class and Description |
---|---|
protected static class |
MemoryUnitCache.UnitCacheEntry
Storage for a compilation unit in the map.
|
protected static class |
MemoryUnitCache.UnitOrigin
Track how the unit was loaded.
|
Modifier and Type | Field and Description |
---|---|
protected Map<String,MemoryUnitCache.UnitCacheEntry> |
unitMap
References to all
CompilationUnit objects loaded from the
persistent store, and any new ones added to the store as well. |
protected Map<com.google.gwt.dev.javac.ContentId,MemoryUnitCache.UnitCacheEntry> |
unitMapByContentId
References
CompilationUnit objects by ContentId , which is
composed of the type name and a hash on the source code contents. |
Constructor and Description |
---|
MemoryUnitCache() |
Modifier and Type | Method and Description |
---|---|
void |
add(CompilationUnit newUnit)
Adds a new entry into the cache.
|
void |
cleanup(TreeLogger logger)
This method is a no-op for an in-memory cache.
|
void |
clear()
Wipe the contents of the cache.
|
CompilationUnit |
find(com.google.gwt.dev.javac.ContentId contentId)
Lookup a
CompilationUnit by ContentId . |
CompilationUnit |
find(String resourcePath)
Lookup a
CompilationUnit by resource path. |
void |
remove(CompilationUnit unit)
Remove a
CompilationUnit from the cache. |
protected final Map<String,MemoryUnitCache.UnitCacheEntry> unitMap
CompilationUnit
objects loaded from the
persistent store, and any new ones added to the store as well.
The key is resource path.protected final Map<com.google.gwt.dev.javac.ContentId,MemoryUnitCache.UnitCacheEntry> unitMapByContentId
CompilationUnit
objects by ContentId
, which is
composed of the type name and a hash on the source code contents.public void add(CompilationUnit newUnit)
public void cleanup(TreeLogger logger)
public void clear() throws UnableToCompleteException
UnitCache
clear
in interface UnitCache
UnableToCompleteException
public CompilationUnit find(com.google.gwt.dev.javac.ContentId contentId)
UnitCache
CompilationUnit
by ContentId
.public CompilationUnit find(String resourcePath)
UnitCache
CompilationUnit
by resource path. This should include any path prefix that may
have been stripped to reroot the resource.find
in interface UnitCache
CompilationUnit.getResourcePath()
public void remove(CompilationUnit unit)
UnitCache
CompilationUnit
from the cache.Copyright © 2018. All rights reserved.