|
Groovy Documentation | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.codehaus.groovy.control.ClassNodeResolver
public class ClassNodeResolver extends java.lang.Object
This class is used as a plugable way to resolve class names. An instance of this class has to be added to CompilationUnit using CompilationUnit.setClassNodeResolver. The CompilationUnit will then set the resolver on the ResolveVisitor each time new. The ResolveVisitor will prepare name lookup and then finally ask the resolver if the class exists. This resolver then can return either a SourceUnit or a ClassNode. In case of a SourceUnit the compiler is notified that a new source is to be added to the compilation queue. In case of a ClassNode no further action than the resolving is done. The lookup result is stored in the helper class LookupResult. This class provides a class cache to cache lookups. If you don't want this, you have to override the methods ClassNodeResolver.cacheClass and ClassNodeResolver.getFromClassCache. Custom lookup logic is supposed to go into the method ClassNodeResolver.findClassNode while the entry method is ClassNodeResolver.resolveName
Nested Class Summary | |
---|---|
static class |
ClassNodeResolver.LookupResult
Helper class to return either a SourceUnit or ClassNode. |
Field Summary | |
---|---|
protected static ClassNode |
NO_CLASS
Internal helper used to indicate a cache hit for a class that does not exist. |
Method Summary | |
---|---|
void
|
cacheClass(java.lang.String name, ClassNode res)
caches a ClassNode |
ClassNodeResolver.LookupResult
|
findClassNode(java.lang.String name, CompilationUnit compilationUnit)
Extension point for custom lookup logic of finding ClassNodes. |
ClassNode
|
getFromClassCache(java.lang.String name)
returns whatever is stored in the class cache for the given name |
ClassNodeResolver.LookupResult
|
resolveName(java.lang.String name, CompilationUnit compilationUnit)
Resolves the name of a class to a SourceUnit or ClassNode. |
Methods inherited from class java.lang.Object | |
---|---|
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Field Detail |
---|
protected static final ClassNode NO_CLASS
Method Detail |
---|
public void cacheClass(java.lang.String name, ClassNode res)
name
- - the name of the classres
- - the ClassNode for that name
public ClassNodeResolver.LookupResult findClassNode(java.lang.String name, CompilationUnit compilationUnit)
name
- - the name of the classcompilationUnit
- - the current compilation unit
public ClassNode getFromClassCache(java.lang.String name)
name
- - the name of the class
public ClassNodeResolver.LookupResult resolveName(java.lang.String name, CompilationUnit compilationUnit)
name
- - the name of the classcompilationUnit
- - the current CompilationUnit
Groovy Documentation