Lombok - v0.10.8

lombok.eclipse
Class EclipseAnnotationHandler<T extends Annotation>

java.lang.Object
  extended by lombok.eclipse.EclipseAnnotationHandler<T>
Direct Known Subclasses:
HandleCleanup, HandleConstructor.HandleAllArgsConstructor, HandleConstructor.HandleNoArgsConstructor, HandleConstructor.HandleRequiredArgsConstructor, HandleData, HandleEqualsAndHashCode, HandleGetter, HandleLog.HandleCommonsLog, HandleLog.HandleJulLog, HandleLog.HandleLog4jLog, HandleLog.HandleSlf4jLog, HandlePrintAST, HandleSetter, HandleSneakyThrows, HandleSynchronized, HandleToString

public abstract class EclipseAnnotationHandler<T extends Annotation>
extends Object

Implement this interface if you want to be triggered for a specific annotation. You MUST replace 'T' with a specific annotation type, such as: public class HandleGetter implements EclipseAnnotationHandler<Getter> Because this generics parameter is inspected to figure out which class you're interested in. You also need to register yourself via SPI discovery as being an implementation of EclipseAnnotationHandler.


Constructor Summary
EclipseAnnotationHandler()
           
 
Method Summary
 boolean deferUntilPostDiet()
          Return true if this handler should not be run in the diet parse phase.
abstract  void handle(AnnotationValues<T> annotation, org.eclipse.jdt.internal.compiler.ast.Annotation ast, EclipseNode annotationNode)
          Called when an annotation is found that is likely to match the annotation you're interested in.
 void preHandle(AnnotationValues<T> annotation, org.eclipse.jdt.internal.compiler.ast.Annotation ast, EclipseNode annotationNode)
          Called when you want to defer until post diet, and we're still in pre-diet.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EclipseAnnotationHandler

public EclipseAnnotationHandler()
Method Detail

handle

public abstract void handle(AnnotationValues<T> annotation,
                            org.eclipse.jdt.internal.compiler.ast.Annotation ast,
                            EclipseNode annotationNode)
Called when an annotation is found that is likely to match the annotation you're interested in. Be aware that you'll be called for ANY annotation node in the source that looks like a match. There is, for example, no guarantee that the annotation node belongs to a method, even if you set your TargetType in the annotation to methods only.

Parameters:
annotation - The actual annotation - use this object to retrieve the annotation parameters.
ast - The Eclipse AST node representing the annotation.
annotationNode - The Lombok AST wrapper around the 'ast' parameter. You can use this object to travel back up the chain (something javac AST can't do) to the parent of the annotation, as well as access useful methods such as generating warnings or errors focused on the annotation.

preHandle

public void preHandle(AnnotationValues<T> annotation,
                      org.eclipse.jdt.internal.compiler.ast.Annotation ast,
                      EclipseNode annotationNode)
Called when you want to defer until post diet, and we're still in pre-diet. May be called not at all or multiple times, so make sure this method is idempotent if run more than once, and whatever you do here should also be done in the main 'handle' method. NB: This method exists because in certain cases, within eclipse, you have to create i.e. a field before referencing it in generated code. You still have to create the field, if its not already there, in 'handle', because for example preHandle would never even be called in ecj mode.


deferUntilPostDiet

public boolean deferUntilPostDiet()
Return true if this handler should not be run in the diet parse phase. 'diet parse' is where method bodies aren't filled in yet. If you have a method-level annotation that modifies the contents of that method, return true here. Otherwise, return false here.


Lombok - v0.10.8

Copyright © 2009-2011 The Project Lombok Authors, licensed under the MIT licence.