|
Lombok - v0.9.3 | ||||||||
| 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 com.sun.tools.javac.tree.JCTree.JCExpression |
chainDots(com.sun.tools.javac.tree.TreeMaker maker,
JavacNode node,
java.lang.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 com.sun.tools.javac.util.List<java.lang.Integer> |
createListOfNonExistentFields(com.sun.tools.javac.util.List<java.lang.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 |
deleteImportFromCompilationUnit(JavacNode node,
java.lang.String name)
|
static JavacHandlerUtil.MemberExistsResult |
fieldExists(java.lang.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,
java.util.regex.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 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 |
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 |
isPrimitive(com.sun.tools.javac.tree.JCTree.JCExpression ref)
Checks if the given expression (that really ought to refer to a type expression) represents a primitive type. |
static void |
markAnnotationAsProcessed(JavacNode annotation,
java.lang.Class<? extends java.lang.annotation.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 JavacHandlerUtil.MemberExistsResult |
methodExists(java.lang.String methodName,
JavacNode node)
|
static JavacHandlerUtil.MemberExistsResult |
methodExists(java.lang.String methodName,
JavacNode node,
boolean caseSensitive)
Checks if there is a method with the provided name. |
static java.util.List<java.lang.String> |
toAllGetterNames(com.sun.tools.javac.tree.JCTree.JCVariableDecl field)
Translates the given field into all possible getter names. |
static java.lang.String |
toGetterName(com.sun.tools.javac.tree.JCTree.JCVariableDecl field)
|
static int |
toJavacModifier(AccessLevel accessLevel)
Turns an AccessLevel instance into the flag bit used by javac. |
static java.lang.String |
toSetterName(com.sun.tools.javac.tree.JCTree.JCVariableDecl field)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static boolean isPrimitive(com.sun.tools.javac.tree.JCTree.JCExpression ref)
public static void markAnnotationAsProcessed(JavacNode annotation,
java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
public static void deleteImportFromCompilationUnit(JavacNode node,
java.lang.String name)
public static java.util.List<java.lang.String> toAllGetterNames(com.sun.tools.javac.tree.JCTree.JCVariableDecl field)
TransformationsUtil.toAllGetterNames(CharSequence, boolean).
public static java.lang.String toGetterName(com.sun.tools.javac.tree.JCTree.JCVariableDecl field)
TransformationsUtil.toGetterName(CharSequence, boolean).public static java.lang.String toSetterName(com.sun.tools.javac.tree.JCTree.JCVariableDecl field)
TransformationsUtil.toSetterName(CharSequence).
public static JavacHandlerUtil.MemberExistsResult fieldExists(java.lang.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(java.lang.String methodName,
JavacNode node)
public static JavacHandlerUtil.MemberExistsResult methodExists(java.lang.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 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(com.sun.tools.javac.tree.TreeMaker maker,
JavacNode node,
java.lang.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,
java.util.regex.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<java.lang.Integer> createListOfNonExistentFields(com.sun.tools.javac.util.List<java.lang.String> list,
JavacNode type,
boolean excludeStandard,
boolean excludeTransient)
|
Lombok - v0.9.3 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||