diff options
author | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2019-07-16 01:24:18 +0200 |
---|---|---|
committer | Reinier Zwitserloot <r.zwitserloot@projectlombok.org> | 2019-07-16 01:24:18 +0200 |
commit | b439e4ce771813a12300c3006f9fcc12f25678d7 (patch) | |
tree | 6f38105b83a7e611b074034aa6d2f61ea68ba809 /src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java | |
parent | b3824c9dc1861c0ce6acdf48049e6552d808e448 (diff) | |
download | lombok-b439e4ce771813a12300c3006f9fcc12f25678d7.tar.gz lombok-b439e4ce771813a12300c3006f9fcc12f25678d7.tar.bz2 lombok-b439e4ce771813a12300c3006f9fcc12f25678d7.zip |
[Fixes #2115] builder fields tracking a property that has a default set is now called `$value` in order to convey that you shouldnt manually mess with it.
Diffstat (limited to 'src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java')
-rw-r--r-- | src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index 1a0633bf..37976ae3 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -1816,12 +1816,12 @@ public class EclipseHandlerUtil { } /** - * Generates a new statement that checks if the given variable is null, and if so, throws a specified exception with the + * Generates a new statement that checks if the given local variable is null, and if so, throws a specified exception with the * variable name as message. * * @param exName The name of the exception to throw; normally {@code java.lang.NullPointerException}. */ - public static Statement generateNullCheck(AbstractVariableDeclaration variable, EclipseNode sourceNode) { + public static Statement generateNullCheck(TypeReference type, char[] variable, EclipseNode sourceNode) { NullCheckExceptionType exceptionType = sourceNode.getAst().readConfiguration(ConfigurationKeys.NON_NULL_EXCEPTION_TYPE); if (exceptionType == null) exceptionType = NullCheckExceptionType.NULL_POINTER_EXCEPTION; @@ -1830,11 +1830,11 @@ public class EclipseHandlerUtil { int pS = source.sourceStart, pE = source.sourceEnd; long p = (long)pS << 32 | pE; - if (isPrimitive(variable.type)) return null; + if (isPrimitive(type)) return null; AllocationExpression exception = new AllocationExpression(); setGeneratedBy(exception, source); - SingleNameReference varName = new SingleNameReference(variable.name, p); + SingleNameReference varName = new SingleNameReference(variable, p); setGeneratedBy(varName, source); NullLiteral nullLiteral = new NullLiteral(pS, pE); setGeneratedBy(nullLiteral, source); @@ -1844,7 +1844,7 @@ public class EclipseHandlerUtil { equalExpression.sourceStart = pS; equalExpression.statementEnd = equalExpression.sourceEnd = pE; setGeneratedBy(equalExpression, source); - StringLiteral message = new StringLiteral(exceptionType.toExceptionMessage(new String(variable.name)).toCharArray(), pS, pE, 0); + StringLiteral message = new StringLiteral(exceptionType.toExceptionMessage(new String(variable)).toCharArray(), pS, pE, 0); setGeneratedBy(message, source); if (exceptionType == NullCheckExceptionType.ASSERTION) { @@ -1876,6 +1876,16 @@ public class EclipseHandlerUtil { } /** + * 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. + * + * @param exName The name of the exception to throw; normally {@code java.lang.NullPointerException}. + */ + public static Statement generateNullCheck(AbstractVariableDeclaration variable, EclipseNode sourceNode) { + return generateNullCheck(variable.type, variable.name, sourceNode); + } + + /** * Create an annotation of the given name, and is marked as being generated by the given source. */ public static MarkerAnnotation makeMarkerAnnotation(char[][] name, ASTNode source) { |