aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse/handlers/HandleVal.java
diff options
context:
space:
mode:
authorBulgakov Alexander <abulgakov@at-consulting.ru>2016-11-12 23:04:48 +0300
committerBulgakov Alexander <abulgakov@at-consulting.ru>2016-11-12 23:04:48 +0300
commit69eeb9edc767bb3ceb0320bb5a0ea60dfabe827c (patch)
treee579423fe8ae7b5a961b0e643703a45dd167e36b /src/core/lombok/eclipse/handlers/HandleVal.java
parent67371e5841e1dd8ed5d663f1c907da0952976b8f (diff)
downloadlombok-69eeb9edc767bb3ceb0320bb5a0ea60dfabe827c.tar.gz
lombok-69eeb9edc767bb3ceb0320bb5a0ea60dfabe827c.tar.bz2
lombok-69eeb9edc767bb3ceb0320bb5a0ea60dfabe827c.zip
a initialization of variable like "var o = null;" will throw the compile time error "variable initializer is 'null'"
Diffstat (limited to 'src/core/lombok/eclipse/handlers/HandleVal.java')
-rw-r--r--src/core/lombok/eclipse/handlers/HandleVal.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleVal.java b/src/core/lombok/eclipse/handlers/HandleVal.java
index e8b1deb4..49820f60 100644
--- a/src/core/lombok/eclipse/handlers/HandleVal.java
+++ b/src/core/lombok/eclipse/handlers/HandleVal.java
@@ -23,6 +23,7 @@ package lombok.eclipse.handlers;
import lombok.ConfigurationKeys;
import lombok.core.HandlerPriority;
+import lombok.core.LombokNode;
import lombok.eclipse.DeferUntilPostDiet;
import lombok.eclipse.EclipseASTAdapter;
import lombok.eclipse.EclipseASTVisitor;
@@ -33,11 +34,13 @@ import org.eclipse.jdt.internal.compiler.ast.ArrayInitializer;
import org.eclipse.jdt.internal.compiler.ast.ForStatement;
import org.eclipse.jdt.internal.compiler.ast.ForeachStatement;
import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.NullLiteral;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.mangosdk.spi.ProviderFor;
import static lombok.core.handlers.HandlerUtil.handleFlagUsage;
import static lombok.eclipse.handlers.EclipseHandlerUtil.typeMatches;
+import static lombok.javac.handlers.HandleVal.VARIABLE_INITIALIZER_IS_NULL;
/*
* This class just handles 3 basic error cases. The real meat of eclipse 'val' support is in {@code PatchVal} and {@code PatchValEclipse}.
@@ -81,5 +84,11 @@ public class HandleVal extends EclipseASTAdapter {
if (local.initialization != null && local.initialization.getClass().getName().equals("org.eclipse.jdt.internal.compiler.ast.LambdaExpression")) {
localNode.addError("'" + annotation + "' is not allowed with lambda expressions.");
}
+
+ if(isVar && local.initialization instanceof NullLiteral) addVarNullInitMessage(localNode);
+ }
+
+ public static void addVarNullInitMessage(LombokNode localNode) {
+ localNode.addError(VARIABLE_INITIALIZER_IS_NULL);
}
}