Lombok - v0.9.3

lombok.eclipse.handlers
Class EclipseHandlerUtil

java.lang.Object
  extended by lombok.eclipse.handlers.EclipseHandlerUtil

public class EclipseHandlerUtil
extends java.lang.Object

Container for static utility methods useful to handlers written for eclipse.


Nested Class Summary
static class EclipseHandlerUtil.MemberExistsResult
          Serves as return value for the methods that check for the existence of fields and methods.
 
Method Summary
static EclipseHandlerUtil.MemberExistsResult constructorExists(EclipseNode node)
          Checks if there is a (non-default) constructor.
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 EclipseHandlerUtil.MemberExistsResult fieldExists(java.lang.String fieldName, EclipseNode node)
          Checks if there is a field with the provided name.
static org.eclipse.jdt.internal.compiler.ast.Annotation[] findAnnotations(org.eclipse.jdt.internal.compiler.ast.FieldDeclaration field, java.util.regex.Pattern namePattern)
          Searches the given field node for annotations and returns each one that matches the provided regular expression pattern.
static org.eclipse.jdt.internal.compiler.ast.Statement generateNullCheck(org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration variable, org.eclipse.jdt.internal.compiler.ast.ASTNode source)
          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 EclipseNode getExistingLombokConstructor(EclipseNode node)
          Returns the constructor that's already been generated by lombok.
static EclipseNode getExistingLombokMethod(java.lang.String methodName, EclipseNode node)
          Returns the method that's already been generated by lombok with the given name.
static void injectField(EclipseNode type, org.eclipse.jdt.internal.compiler.ast.FieldDeclaration field)
          Inserts a field into an existing type.
static void injectMethod(EclipseNode type, org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration method)
          Inserts a method into an existing type.
static boolean isPrimitive(org.eclipse.jdt.internal.compiler.ast.TypeReference ref)
          Checks if the given type reference represents a primitive type.
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 EclipseHandlerUtil.MemberExistsResult methodExists(java.lang.String methodName, EclipseNode node)
          Wrapper for methodExists(String, EclipseNode, boolean) with caseSensitive = true.
static EclipseHandlerUtil.MemberExistsResult methodExists(java.lang.String methodName, EclipseNode node, boolean caseSensitive)
          Checks if there is a method with the provided name.
static boolean nameEquals(char[][] typeName, java.lang.String string)
          Checks if an eclipse-style array-of-array-of-characters to represent a fully qualified name ('foo.bar.baz'), matches a plain string containing the same fully qualified name with dots in the string.
static int toEclipseModifier(AccessLevel value)
          Turns an AccessLevel instance into the flag bit used by eclipse.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isPrimitive

public static boolean isPrimitive(org.eclipse.jdt.internal.compiler.ast.TypeReference ref)
Checks if the given type reference represents a primitive type.


toEclipseModifier

public static int toEclipseModifier(AccessLevel value)
Turns an AccessLevel instance into the flag bit used by eclipse.


nameEquals

public static boolean nameEquals(char[][] typeName,
                                 java.lang.String string)
Checks if an eclipse-style array-of-array-of-characters to represent a fully qualified name ('foo.bar.baz'), matches a plain string containing the same fully qualified name with dots in the string.


fieldExists

public static EclipseHandlerUtil.MemberExistsResult fieldExists(java.lang.String fieldName,
                                                                EclipseNode node)
Checks if there is a field with the provided name.

Parameters:
fieldName - the field name to check for.
node - Any node that represents the Type (TypeDeclaration) to look in, or any child node thereof.

methodExists

public static EclipseHandlerUtil.MemberExistsResult methodExists(java.lang.String methodName,
                                                                 EclipseNode node)
Wrapper for methodExists(String, EclipseNode, boolean) with caseSensitive = true.


methodExists

public static EclipseHandlerUtil.MemberExistsResult methodExists(java.lang.String methodName,
                                                                 EclipseNode node,
                                                                 boolean caseSensitive)
Checks if there is a method with the provided name. In case of multiple methods (overloading), only the first method decides if EXISTS_BY_USER or EXISTS_BY_LOMBOK is returned.

Parameters:
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.

constructorExists

public static EclipseHandlerUtil.MemberExistsResult constructorExists(EclipseNode node)
Checks if there is a (non-default) constructor. In case of multiple constructors (overloading), only the first constructor decides if EXISTS_BY_USER or EXISTS_BY_LOMBOK is returned.

Parameters:
node - Any node that represents the Type (TypeDeclaration) to look in, or any child node thereof.

getExistingLombokConstructor

public static EclipseNode getExistingLombokConstructor(EclipseNode node)
Returns the constructor that's already been generated by lombok. Provide any node that represents the type (TypeDeclaration) to look in, or any child node thereof.


getExistingLombokMethod

public static EclipseNode getExistingLombokMethod(java.lang.String methodName,
                                                  EclipseNode node)
Returns the method that's already been generated by lombok with the given name. Provide any node that represents the type (TypeDeclaration) to look in, or any child node thereof.


injectField

public static void injectField(EclipseNode type,
                               org.eclipse.jdt.internal.compiler.ast.FieldDeclaration field)
Inserts a field into an existing type. The type must represent a TypeDeclaration.


injectMethod

public static void injectMethod(EclipseNode type,
                                org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration method)
Inserts a method into an existing type. The type must represent a TypeDeclaration.


findAnnotations

public static org.eclipse.jdt.internal.compiler.ast.Annotation[] findAnnotations(org.eclipse.jdt.internal.compiler.ast.FieldDeclaration field,
                                                                                 java.util.regex.Pattern namePattern)
Searches the given field node for annotations and returns each one that matches the provided regular expression pattern. Only the simple name is checked - the package and any containing class are ignored.


generateNullCheck

public static org.eclipse.jdt.internal.compiler.ast.Statement generateNullCheck(org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration variable,
                                                                                org.eclipse.jdt.internal.compiler.ast.ASTNode source)
Generates a new statement that checks if the given variable is null, and if so, throws a NullPointerException with the variable name as message.


makeMarkerAnnotation

public 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.


createListOfNonExistentFields

public 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.


Lombok - v0.9.3

Copyright © 2009 Reinier Zwitserloot and Roel Spilker, licensed under the MIT licence.