public class EclipseHandlerUtil
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
EclipseHandlerUtil.FieldAccess |
static class |
EclipseHandlerUtil.MemberExistsResult
Serves as return value for the methods that check for the existence of fields and methods.
|
Modifier and Type | Method and Description |
---|---|
static org.eclipse.jdt.internal.compiler.ast.Annotation[] |
addGenerated(EclipseNode node,
org.eclipse.jdt.internal.compiler.ast.ASTNode source,
org.eclipse.jdt.internal.compiler.ast.Annotation[] originalAnnotationArray) |
static org.eclipse.jdt.internal.compiler.ast.Annotation[] |
addSuppressWarningsAll(EclipseNode node,
org.eclipse.jdt.internal.compiler.ast.ASTNode source,
org.eclipse.jdt.internal.compiler.ast.Annotation[] originalAnnotationArray) |
static boolean |
annotationTypeMatches(java.lang.Class<? extends java.lang.annotation.Annotation> type,
EclipseNode node)
Checks if the provided annotation type is likely to be the intended type for the given annotation node.
|
static org.eclipse.jdt.internal.compiler.ast.TypeReference |
cloneSelfType(EclipseNode context) |
static org.eclipse.jdt.internal.compiler.ast.TypeReference |
cloneSelfType(EclipseNode context,
org.eclipse.jdt.internal.compiler.ast.ASTNode source) |
static EclipseHandlerUtil.MemberExistsResult |
constructorExists(EclipseNode node)
Checks if there is a (non-default) constructor.
|
static org.eclipse.jdt.internal.compiler.ast.Annotation |
copyAnnotation(org.eclipse.jdt.internal.compiler.ast.Annotation annotation,
org.eclipse.jdt.internal.compiler.ast.ASTNode source) |
static org.eclipse.jdt.internal.compiler.ast.Annotation[] |
copyAnnotations(org.eclipse.jdt.internal.compiler.ast.ASTNode source,
org.eclipse.jdt.internal.compiler.ast.Annotation[]... allAnnotations) |
static org.eclipse.jdt.internal.compiler.ast.TypeReference |
copyType(org.eclipse.jdt.internal.compiler.ast.TypeReference ref) |
static org.eclipse.jdt.internal.compiler.ast.TypeReference |
copyType(org.eclipse.jdt.internal.compiler.ast.TypeReference ref,
org.eclipse.jdt.internal.compiler.ast.ASTNode source)
You can't share TypeReference objects or subtle errors start happening.
|
static org.eclipse.jdt.internal.compiler.ast.TypeParameter[] |
copyTypeParams(org.eclipse.jdt.internal.compiler.ast.TypeParameter[] params,
org.eclipse.jdt.internal.compiler.ast.ASTNode source)
You can't share TypeParameter objects or bad things happen; for example, one 'T' resolves differently
from another 'T', even for the same T in a single class file.
|
static org.eclipse.jdt.internal.compiler.ast.TypeReference[] |
copyTypes(org.eclipse.jdt.internal.compiler.ast.TypeReference[] refs) |
static org.eclipse.jdt.internal.compiler.ast.TypeReference[] |
copyTypes(org.eclipse.jdt.internal.compiler.ast.TypeReference[] refs,
org.eclipse.jdt.internal.compiler.ast.ASTNode source)
Convenience method that creates a new array and copies each TypeReference in the source array via
copyType(TypeReference, ASTNode) . |
static <A extends java.lang.annotation.Annotation> |
createAnnotation(java.lang.Class<A> type,
EclipseNode annotationNode)
Provides AnnotationValues with the data it needs to do its thing.
|
static java.util.List<java.lang.Integer> |
createListOfNonExistentFields(java.util.List<java.lang.String> list,
EclipseNode 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 org.eclipse.jdt.internal.compiler.ast.NameReference |
createNameReference(java.lang.String name,
org.eclipse.jdt.internal.compiler.ast.Annotation source) |
static void |
error(org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration cud,
java.lang.String message,
java.lang.Throwable ex)
Generates an error in the Eclipse error log.
|
static EclipseHandlerUtil.MemberExistsResult |
fieldExists(java.lang.String fieldName,
EclipseNode node)
Checks if there is a field with the provided name.
|
static boolean |
filterField(org.eclipse.jdt.internal.compiler.ast.FieldDeclaration declaration)
Checks if the field should be included in operations that work on 'all' fields:
If the field is static, or starts with a '$', or is actually an enum constant, 'false' is returned, indicating you should skip it.
|
static boolean |
filterField(org.eclipse.jdt.internal.compiler.ast.FieldDeclaration declaration,
boolean skipStatic) |
static org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation |
generateDeprecatedAnnotation(org.eclipse.jdt.internal.compiler.ast.ASTNode source) |
static org.eclipse.jdt.internal.compiler.ast.Statement |
generateNullCheck(org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration variable,
EclipseNode sourceNode)
Generates a new statement that checks if the given variable is null, and if so, throws a specified exception with the
variable name as message.
|
static AnnotationValues<Accessors> |
getAccessorsForField(EclipseNode field) |
static org.eclipse.jdt.internal.compiler.ast.ASTNode |
getGeneratedBy(org.eclipse.jdt.internal.compiler.ast.ASTNode node) |
static boolean |
hasAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> type,
EclipseNode node) |
static EclipseNode |
injectField(EclipseNode type,
org.eclipse.jdt.internal.compiler.ast.FieldDeclaration field)
Inserts a field into an existing type.
|
static EclipseNode |
injectFieldAndMarkGenerated(EclipseNode type,
org.eclipse.jdt.internal.compiler.ast.FieldDeclaration field)
Inserts a field into an existing type.
|
static EclipseNode |
injectMethod(EclipseNode type,
org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration method)
Inserts a method into an existing type.
|
static EclipseNode |
injectType(EclipseNode typeNode,
org.eclipse.jdt.internal.compiler.ast.TypeDeclaration type)
Adds an inner type (class, interface, enum) to the given type.
|
static boolean |
isBoolean(org.eclipse.jdt.internal.compiler.ast.TypeReference typeReference) |
static boolean |
isEnumConstant(org.eclipse.jdt.internal.compiler.ast.FieldDeclaration field) |
static boolean |
isFieldDeprecated(EclipseNode fieldNode) |
static boolean |
isGenerated(org.eclipse.jdt.internal.compiler.ast.ASTNode node) |
static org.eclipse.jdt.internal.compiler.ast.CastExpression |
makeCastExpression(org.eclipse.jdt.internal.compiler.ast.Expression ref,
org.eclipse.jdt.internal.compiler.ast.TypeReference castTo,
org.eclipse.jdt.internal.compiler.ast.ASTNode source)
In eclipse 3.7+, the CastExpression constructor was changed from a really weird version to
a less weird one.
|
static org.eclipse.jdt.internal.compiler.ast.IntLiteral |
makeIntLiteral(char[] token,
org.eclipse.jdt.internal.compiler.ast.ASTNode source)
In eclipse 3.7+, IntLiterals are created using a factory-method
Unfortunately that means we need to use reflection as we want to be compatible
with eclipse versions before 3.7.
|
static org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation |
makeMarkerAnnotation(char[][] name,
org.eclipse.jdt.internal.compiler.ast.ASTNode source)
Create an annotation of the given name, and is marked as being generated by the given source.
|
static org.eclipse.jdt.internal.compiler.ast.TypeReference |
makeType(org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding,
org.eclipse.jdt.internal.compiler.ast.ASTNode pos,
boolean allowCompound) |
static EclipseHandlerUtil.MemberExistsResult |
methodExists(java.lang.String methodName,
EclipseNode node,
boolean caseSensitive,
int params)
Checks if there is a method with the provided name.
|
static EclipseHandlerUtil.MemberExistsResult |
methodExists(java.lang.String methodName,
EclipseNode node,
int params)
|
static org.eclipse.jdt.internal.compiler.ast.TypeReference |
namePlusTypeParamsToTypeReference(char[] typeName,
org.eclipse.jdt.internal.compiler.ast.TypeParameter[] params,
long p) |
static char[] |
removePrefixFromField(EclipseNode field) |
static void |
sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(EclipseNode typeNode,
EclipseNode errorNode) |
static <T extends org.eclipse.jdt.internal.compiler.ast.ASTNode> |
setGeneratedBy(T node,
org.eclipse.jdt.internal.compiler.ast.ASTNode source) |
static boolean |
shouldReturnThis(EclipseNode field)
When generating a setter, the setter either returns void (beanspec) or Self (fluent).
|
static java.util.List<java.lang.String> |
toAllGetterNames(EclipseNode field,
boolean isBoolean)
Translates the given field into all possible getter names.
|
static java.util.List<java.lang.String> |
toAllSetterNames(EclipseNode field,
boolean isBoolean)
Translates the given field into all possible setter names.
|
static java.util.List<java.lang.String> |
toAllWitherNames(EclipseNode field,
boolean isBoolean)
Translates the given field into all possible wither names.
|
static int |
toEclipseModifier(AccessLevel value)
Turns an
AccessLevel instance into the flag bit used by eclipse. |
static java.lang.String |
toGetterName(EclipseNode field,
boolean isBoolean) |
static java.lang.String |
toSetterName(EclipseNode field,
boolean isBoolean) |
static java.lang.String |
toWitherName(EclipseNode field,
boolean isBoolean) |
static boolean |
typeMatches(java.lang.Class<?> type,
EclipseNode node,
org.eclipse.jdt.internal.compiler.ast.TypeReference typeRef)
Checks if the given TypeReference node is likely to be a reference to the provided class.
|
static java.util.List<org.eclipse.jdt.internal.compiler.ast.Annotation> |
unboxAndRemoveAnnotationParameter(org.eclipse.jdt.internal.compiler.ast.Annotation annotation,
java.lang.String annotationName,
java.lang.String errorName,
EclipseNode errorNode) |
static void |
warning(java.lang.String message,
java.lang.Throwable ex)
Generates a warning in the Eclipse error log.
|
public static void error(org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration cud, java.lang.String message, java.lang.Throwable ex)
cud
- The CompilationUnitDeclaration
where the error occurred.
An error will be generated on line 0 linking to the error log entry. Can be null
.message
- Human readable description of the problem.ex
- The associated exception. Can be null
.public static void warning(java.lang.String message, java.lang.Throwable ex)
message
- Human readable description of the problem.ex
- The associated exception. Can be null
.public static org.eclipse.jdt.internal.compiler.ast.ASTNode getGeneratedBy(org.eclipse.jdt.internal.compiler.ast.ASTNode node)
public static boolean isGenerated(org.eclipse.jdt.internal.compiler.ast.ASTNode node)
public static <T extends org.eclipse.jdt.internal.compiler.ast.ASTNode> T setGeneratedBy(T node, org.eclipse.jdt.internal.compiler.ast.ASTNode source)
public static org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation generateDeprecatedAnnotation(org.eclipse.jdt.internal.compiler.ast.ASTNode source)
public static boolean isFieldDeprecated(EclipseNode fieldNode)
public static boolean typeMatches(java.lang.Class<?> type, EclipseNode node, org.eclipse.jdt.internal.compiler.ast.TypeReference typeRef)
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).typeRef
- A type reference to check.public static void sanityCheckForMethodGeneratingAnnotationsOnBuilderClass(EclipseNode typeNode, EclipseNode errorNode)
public static org.eclipse.jdt.internal.compiler.ast.Annotation copyAnnotation(org.eclipse.jdt.internal.compiler.ast.Annotation annotation, org.eclipse.jdt.internal.compiler.ast.ASTNode source)
public static org.eclipse.jdt.internal.compiler.ast.TypeParameter[] copyTypeParams(org.eclipse.jdt.internal.compiler.ast.TypeParameter[] params, org.eclipse.jdt.internal.compiler.ast.ASTNode source)
public static org.eclipse.jdt.internal.compiler.ast.TypeReference namePlusTypeParamsToTypeReference(char[] typeName, org.eclipse.jdt.internal.compiler.ast.TypeParameter[] params, long p)
public static org.eclipse.jdt.internal.compiler.ast.TypeReference[] copyTypes(org.eclipse.jdt.internal.compiler.ast.TypeReference[] refs)
public static org.eclipse.jdt.internal.compiler.ast.TypeReference[] copyTypes(org.eclipse.jdt.internal.compiler.ast.TypeReference[] refs, org.eclipse.jdt.internal.compiler.ast.ASTNode source)
copyType(TypeReference, ASTNode)
.public static org.eclipse.jdt.internal.compiler.ast.TypeReference copyType(org.eclipse.jdt.internal.compiler.ast.TypeReference ref)
public static org.eclipse.jdt.internal.compiler.ast.TypeReference copyType(org.eclipse.jdt.internal.compiler.ast.TypeReference ref, org.eclipse.jdt.internal.compiler.ast.ASTNode source)
public static org.eclipse.jdt.internal.compiler.ast.Annotation[] copyAnnotations(org.eclipse.jdt.internal.compiler.ast.ASTNode source, org.eclipse.jdt.internal.compiler.ast.Annotation[]... allAnnotations)
public static boolean hasAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> type, EclipseNode node)
public static boolean annotationTypeMatches(java.lang.Class<? extends java.lang.annotation.Annotation> type, EclipseNode node)
public static org.eclipse.jdt.internal.compiler.ast.TypeReference cloneSelfType(EclipseNode context)
public static org.eclipse.jdt.internal.compiler.ast.TypeReference cloneSelfType(EclipseNode context, org.eclipse.jdt.internal.compiler.ast.ASTNode source)
public static org.eclipse.jdt.internal.compiler.ast.TypeReference makeType(org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding, org.eclipse.jdt.internal.compiler.ast.ASTNode pos, boolean allowCompound)
public static <A extends java.lang.annotation.Annotation> AnnotationValues<A> createAnnotation(java.lang.Class<A> type, EclipseNode annotationNode)
public static int toEclipseModifier(AccessLevel value)
AccessLevel
instance into the flag bit used by eclipse.public static boolean isBoolean(org.eclipse.jdt.internal.compiler.ast.TypeReference typeReference)
public static java.util.List<java.lang.String> toAllGetterNames(EclipseNode field, boolean isBoolean)
TransformationsUtil#toAllGetterNames(lombok.core.AnnotationValues, CharSequence, boolean)
.public static java.lang.String toGetterName(EclipseNode field, boolean isBoolean)
TransformationsUtil#toGetterName(lombok.core.AnnotationValues, CharSequence, boolean)
.public static java.util.List<java.lang.String> toAllSetterNames(EclipseNode field, boolean isBoolean)
TransformationsUtil#toAllSetterNames(lombok.core.AnnotationValues, CharSequence, boolean)
.public static java.lang.String toSetterName(EclipseNode field, boolean isBoolean)
TransformationsUtil#toSetterName(lombok.core.AnnotationValues, CharSequence, boolean)
.public static java.util.List<java.lang.String> toAllWitherNames(EclipseNode field, boolean isBoolean)
TransformationsUtil#toAllWitherNames(lombok.core.AnnotationValues, CharSequence, boolean)
.public static java.lang.String toWitherName(EclipseNode field, boolean isBoolean)
TransformationsUtil#toWitherName(lombok.core.AnnotationValues, CharSequence, boolean)
.public static boolean shouldReturnThis(EclipseNode field)
Accessors
annotation and associated config properties to figure that out.public static boolean filterField(org.eclipse.jdt.internal.compiler.ast.FieldDeclaration declaration)
public static boolean filterField(org.eclipse.jdt.internal.compiler.ast.FieldDeclaration declaration, boolean skipStatic)
public static char[] removePrefixFromField(EclipseNode field)
public static AnnotationValues<Accessors> getAccessorsForField(EclipseNode field)
public static EclipseHandlerUtil.MemberExistsResult fieldExists(java.lang.String fieldName, EclipseNode node)
fieldName
- the field name to check for.node
- Any node that represents the Type (TypeDeclaration) to look in, or any child node thereof.public static EclipseHandlerUtil.MemberExistsResult methodExists(java.lang.String methodName, EclipseNode node, int params)
public static EclipseHandlerUtil.MemberExistsResult methodExists(java.lang.String methodName, EclipseNode node, boolean caseSensitive, int params)
methodName
- the method name to check for.node
- Any node that represents the Type (TypeDeclaration) to look in, or any child node thereof.caseSensitive
- If the search should be case sensitive.params
- The number of parameters the method should have; varargs count as 0-*. Set to -1 to find any method with the appropriate name regardless of parameter count.public static EclipseHandlerUtil.MemberExistsResult constructorExists(EclipseNode node)
node
- Any node that represents the Type (TypeDeclaration) to look in, or any child node thereof.public static EclipseNode injectFieldAndMarkGenerated(EclipseNode type, org.eclipse.jdt.internal.compiler.ast.FieldDeclaration field)
TypeDeclaration
.
The field carries the @SuppressWarnings
("all") annotation.public static EclipseNode injectField(EclipseNode type, org.eclipse.jdt.internal.compiler.ast.FieldDeclaration field)
TypeDeclaration
.public static boolean isEnumConstant(org.eclipse.jdt.internal.compiler.ast.FieldDeclaration field)
public static EclipseNode injectMethod(EclipseNode type, org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration method)
TypeDeclaration
.public static EclipseNode injectType(EclipseNode typeNode, org.eclipse.jdt.internal.compiler.ast.TypeDeclaration type)
typeNode
- parent type to inject new type intotype
- New type (class, interface, etc) to inject.public static org.eclipse.jdt.internal.compiler.ast.Annotation[] addSuppressWarningsAll(EclipseNode node, org.eclipse.jdt.internal.compiler.ast.ASTNode source, org.eclipse.jdt.internal.compiler.ast.Annotation[] originalAnnotationArray)
public static org.eclipse.jdt.internal.compiler.ast.Annotation[] addGenerated(EclipseNode node, org.eclipse.jdt.internal.compiler.ast.ASTNode source, org.eclipse.jdt.internal.compiler.ast.Annotation[] originalAnnotationArray)
public static org.eclipse.jdt.internal.compiler.ast.Statement generateNullCheck(org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration variable, EclipseNode sourceNode)
exName
- The name of the exception to throw; normally java.lang.NullPointerException
.public static org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation makeMarkerAnnotation(char[][] name, org.eclipse.jdt.internal.compiler.ast.ASTNode source)
public static java.util.List<java.lang.Integer> createListOfNonExistentFields(java.util.List<java.lang.String> list, EclipseNode type, boolean excludeStandard, boolean excludeTransient)
public static org.eclipse.jdt.internal.compiler.ast.CastExpression makeCastExpression(org.eclipse.jdt.internal.compiler.ast.Expression ref, org.eclipse.jdt.internal.compiler.ast.TypeReference castTo, org.eclipse.jdt.internal.compiler.ast.ASTNode source)
ref
- The foo
in (String)foo
.castTo
- The String
in (String)foo
.public static org.eclipse.jdt.internal.compiler.ast.IntLiteral makeIntLiteral(char[] token, org.eclipse.jdt.internal.compiler.ast.ASTNode source)
public static java.util.List<org.eclipse.jdt.internal.compiler.ast.Annotation> unboxAndRemoveAnnotationParameter(org.eclipse.jdt.internal.compiler.ast.Annotation annotation, java.lang.String annotationName, java.lang.String errorName, EclipseNode errorNode)
public static org.eclipse.jdt.internal.compiler.ast.NameReference createNameReference(java.lang.String name, org.eclipse.jdt.internal.compiler.ast.Annotation source)
Copyright © 2009-2015 The Project Lombok Authors, licensed under the MIT licence.