|
Griffon 1.2.0 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.codehaus.griffon.ast.AbstractASTTransformation
org.codehaus.griffon.ast.ResourcesAwareASTTransformation
@GroovyASTTransformation(phase = CompilePhase.CANONICALIZATION) public class ResourcesAwareASTTransformation extends AbstractASTTransformation
Handles generation of code for the @ResourcesAware annotation.
Generally, it adds (if needed) a ResourceLocator field and the required methods from ResourceHandler.Field Summary | |
---|---|
private static ClassNode |
INPUT_STREAM_TYPE
|
private static Logger |
LOG
|
private static String |
METHOD_GET_RESOURCES
|
private static String |
METHOD_GET_RESOURCE_AS_STREAM
|
private static String |
METHOD_GET_RESOURCE_AS_URL
|
private static String |
NAME
|
private static ClassNode |
RESOURCES_AWARE_TYPE
|
private static ClassNode |
RESOURCE_HANDLER_TYPE
|
private static ClassNode |
RESOURCE_LOCATOR_TYPE
|
private static ClassNode |
URL_TYPE
|
Fields inherited from class AbstractASTTransformation | |
---|---|
APPLICATION_HOLDER_TYPE, COLLECTIONS_CLASS |
Constructor Summary | |
ResourcesAwareASTTransformation()
|
Method Summary | |
---|---|
static void
|
addResourceLocatorIfNeeded(SourceUnit source, ClassNode classNode)
|
static void
|
apply(ClassNode declaringClass)
Adds the necessary field and methods to support resource locating. |
static boolean
|
hasResourcesAwareAnnotation(AnnotatedNode node)
Convenience method to see if an annotated node is @ResourcesAware. |
protected static boolean
|
needsResourceLocator(ClassNode declaringClass, SourceUnit sourceUnit)
Snoops through the declaring class and all parents looking for methods
|
void
|
visit(ASTNode[] nodes, SourceUnit source)
Handles the bulk of the processing, mostly delegating to other methods. |
Methods inherited from class AbstractASTTransformation | |
---|---|
addError, applicationInstance, checkNodesForAnnotationAndType, emptyMap, makeClassSafe, makeClassSafe, makeClassSafe, newClass |
Field Detail |
---|
private static final ClassNode INPUT_STREAM_TYPE
private static final Logger LOG
private static final String METHOD_GET_RESOURCES
private static final String METHOD_GET_RESOURCE_AS_STREAM
private static final String METHOD_GET_RESOURCE_AS_URL
private static final String NAME
private static final ClassNode RESOURCES_AWARE_TYPE
private static final ClassNode RESOURCE_HANDLER_TYPE
private static final ClassNode RESOURCE_LOCATOR_TYPE
private static final ClassNode URL_TYPE
Constructor Detail |
---|
ResourcesAwareASTTransformation()
Method Detail |
---|
public static void addResourceLocatorIfNeeded(SourceUnit source, ClassNode classNode)
public static void apply(ClassNode declaringClass)
protected final org.codehaus.griffon.runtime.core.ResourceLocator this$resourceLocator = new org.codehaus.griffon.runtime.core.ResourceLocator()
Also adds support methods:
public URL getResourceAsURL(String)
public InputStream getResourceAsStream(String)
public List>URL< getResources(String)
declaringClass
- the class to which we add the support field and methods
public static boolean hasResourcesAwareAnnotation(AnnotatedNode node)
node
- the node to check
protected static boolean needsResourceLocator(ClassNode declaringClass, SourceUnit sourceUnit)
declaringClass
- the class to searchsourceUnit
- the source unit, for error reporting. @NotNull.
public void visit(ASTNode[] nodes, SourceUnit source)
nodes
- the ast nodessource
- the source unit for the nodes
Groovy Documentation