|
Lombok - v0.10.8 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectlombok.javac.handlers.JavacHandlerUtil
public class JavacHandlerUtil
Container for static utility methods useful to handlers written for javac.
| Nested Class Summary | |
|---|---|
static class |
JavacHandlerUtil.MemberExistsResult
Serves as return value for the methods that check for the existence of fields and methods. |
| Method Summary | ||
|---|---|---|
static boolean |
annotationTypeMatches(Class<? extends Annotation> type,
JavacNode node)
Checks if the Annotation AST Node provided is likely to be an instance of the provided annotation type. |
|
static com.sun.tools.javac.tree.JCTree.JCExpression |
chainDots(JavacNode node,
String... elems)
In javac, dotted access of any kind, from java.lang.String to var.methodName
is represented by a fold-left of Select nodes with the leftmost string represented by
a Ident node. |
|
static com.sun.tools.javac.tree.JCTree.JCExpression |
chainDotsString(JavacNode node,
String elems)
In javac, dotted access of any kind, from java.lang.String to var.methodName
is represented by a fold-left of Select nodes with the leftmost string represented by
a Ident node. |
|
static JavacHandlerUtil.MemberExistsResult |
constructorExists(JavacNode node)
Checks if there is a (non-default) constructor. |
|
static
|
createAnnotation(Class<A> type,
JavacNode node)
Creates an instance of AnnotationValues for the provided AST Node. |
|
static com.sun.tools.javac.util.List<Integer> |
createListOfNonExistentFields(com.sun.tools.javac.util.List<String> list,
JavacNode type,
boolean excludeStandard,
boolean excludeTransient)
Given a list of field names and a node referring to a type, finds each name in the list that does not match a field within the type. |
|
static void |
deleteAnnotationIfNeccessary(JavacNode annotation,
Class<? extends Annotation> annotationType)
Removes the annotation from javac's AST (it remains in lombok's AST), then removes any import statement that imports this exact annotation (not star imports). |
|
static void |
deleteImportFromCompilationUnit(JavacNode node,
String name)
|
|
static JavacHandlerUtil.MemberExistsResult |
fieldExists(String fieldName,
JavacNode node)
Checks if there is a field with the provided name. |
|
static com.sun.tools.javac.util.List<com.sun.tools.javac.tree.JCTree.JCAnnotation> |
findAnnotations(JavacNode fieldNode,
Pattern namePattern)
Searches the given field node for annotations and returns each one that matches the provided regular expression pattern. |
|
static com.sun.tools.javac.tree.JCTree.JCStatement |
generateNullCheck(com.sun.tools.javac.tree.TreeMaker treeMaker,
JavacNode variable)
Generates a new statement that checks if the given variable is null, and if so, throws a NullPointerException with the
variable name as message. |
|
static com.sun.tools.javac.tree.JCTree |
getGeneratedBy(com.sun.tools.javac.tree.JCTree node)
|
|
static void |
injectField(JavacNode typeNode,
com.sun.tools.javac.tree.JCTree.JCVariableDecl field)
Adds the given new field declaration to the provided type AST Node. |
|
static void |
injectFieldSuppressWarnings(JavacNode typeNode,
com.sun.tools.javac.tree.JCTree.JCVariableDecl field)
Adds the given new field declaration to the provided type AST Node. |
|
static void |
injectMethod(JavacNode typeNode,
com.sun.tools.javac.tree.JCTree.JCMethodDecl method)
Adds the given new method declaration to the provided type AST Node. |
|
static boolean |
isGenerated(com.sun.tools.javac.tree.JCTree node)
|
|
static JavacHandlerUtil.MemberExistsResult |
methodExists(String methodName,
JavacNode node)
|
|
static JavacHandlerUtil.MemberExistsResult |
methodExists(String methodName,
JavacNode node,
boolean caseSensitive)
Checks if there is a method with the provided name. |
|
static
|
recursiveSetGeneratedBy(T node,
com.sun.tools.javac.tree.JCTree source)
|
|
static
|
setGeneratedBy(T node,
com.sun.tools.javac.tree.JCTree source)
|
|
static int |
toJavacModifier(AccessLevel accessLevel)
Turns an AccessLevel instance into the flag bit used by javac. |
|
static boolean |
typeMatches(Class<?> type,
JavacNode node,
com.sun.tools.javac.tree.JCTree typeNode)
Checks if the given TypeReference node is likely to be a reference to the provided class. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static com.sun.tools.javac.tree.JCTree getGeneratedBy(com.sun.tools.javac.tree.JCTree node)
public static boolean isGenerated(com.sun.tools.javac.tree.JCTree node)
public static <T extends com.sun.tools.javac.tree.JCTree> T recursiveSetGeneratedBy(T node,
com.sun.tools.javac.tree.JCTree source)
public static <T extends com.sun.tools.javac.tree.JCTree> T setGeneratedBy(T node,
com.sun.tools.javac.tree.JCTree source)
public static boolean annotationTypeMatches(Class<? extends Annotation> type,
JavacNode node)
type - An actual annotation type, such as lombok.Getter.class.node - A Lombok AST node representing an annotation in source code.
public static boolean typeMatches(Class<?> type,
JavacNode node,
com.sun.tools.javac.tree.JCTree typeNode)
type - An actual type. This method checks if typeNode is likely to be a reference to this type.node - A Lombok AST node. Any node in the appropriate compilation unit will do (used to get access to import statements).typeNode - A type reference to check.
public static <A extends Annotation> AnnotationValues<A> createAnnotation(Class<A> type,
JavacNode node)
AnnotationValues for the provided AST Node.
type - An annotation class type, such as lombok.Getter.class.node - A Lombok AST node representing an annotation in source code.
public static void deleteAnnotationIfNeccessary(JavacNode annotation,
Class<? extends Annotation> annotationType)
public static void deleteImportFromCompilationUnit(JavacNode node,
String name)
public static JavacHandlerUtil.MemberExistsResult fieldExists(String fieldName,
JavacNode node)
fieldName - the field name to check for.node - Any node that represents the Type (JCClassDecl) to look in, or any child node thereof.
public static JavacHandlerUtil.MemberExistsResult methodExists(String methodName,
JavacNode node)
public static JavacHandlerUtil.MemberExistsResult methodExists(String methodName,
JavacNode node,
boolean caseSensitive)
methodName - the method name to check for.node - Any node that represents the Type (JCClassDecl) to look in, or any child node thereof.caseSensitive - If the search should be case sensitive.public static JavacHandlerUtil.MemberExistsResult constructorExists(JavacNode node)
node - Any node that represents the Type (JCClassDecl) to look in, or any child node thereof.public static int toJavacModifier(AccessLevel accessLevel)
AccessLevel instance into the flag bit used by javac.
public static void injectFieldSuppressWarnings(JavacNode typeNode,
com.sun.tools.javac.tree.JCTree.JCVariableDecl field)
SuppressWarnings("all") annotation.
Also takes care of updating the JavacAST.
public static void injectField(JavacNode typeNode,
com.sun.tools.javac.tree.JCTree.JCVariableDecl field)
public static void injectMethod(JavacNode typeNode,
com.sun.tools.javac.tree.JCTree.JCMethodDecl method)
public static com.sun.tools.javac.tree.JCTree.JCExpression chainDots(JavacNode node,
String... elems)
java.lang.String to var.methodName
is represented by a fold-left of Select nodes with the leftmost string represented by
a Ident node. This method generates such an expression.
For example, maker.Select(maker.Select(maker.Ident(NAME[java]), NAME[lang]), NAME[String]).
JCTree.JCIdent,
JCTree.JCFieldAccess
public static com.sun.tools.javac.tree.JCTree.JCExpression chainDotsString(JavacNode node,
String elems)
java.lang.String to var.methodName
is represented by a fold-left of Select nodes with the leftmost string represented by
a Ident node. This method generates such an expression.
For example, maker.Select(maker.Select(maker.Ident(NAME[java]), NAME[lang]), NAME[String]).
JCTree.JCIdent,
JCTree.JCFieldAccess
public static com.sun.tools.javac.util.List<com.sun.tools.javac.tree.JCTree.JCAnnotation> findAnnotations(JavacNode fieldNode,
Pattern namePattern)
public static com.sun.tools.javac.tree.JCTree.JCStatement generateNullCheck(com.sun.tools.javac.tree.TreeMaker treeMaker,
JavacNode variable)
NullPointerException with the
variable name as message.
public static com.sun.tools.javac.util.List<Integer> createListOfNonExistentFields(com.sun.tools.javac.util.List<String> list,
JavacNode type,
boolean excludeStandard,
boolean excludeTransient)
|
Lombok - v0.10.8 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||