diff options
author | Bulgakov Alexander <abulgakov@at-consulting.ru> | 2016-11-12 15:56:17 +0300 |
---|---|---|
committer | Bulgakov Alexander <abulgakov@at-consulting.ru> | 2016-11-12 15:56:17 +0300 |
commit | 67371e5841e1dd8ed5d663f1c907da0952976b8f (patch) | |
tree | 677b27b2050d84daa11b5a8846a5c7d069d81148 /src/core/lombok/eclipse/handlers | |
parent | 4fbbd8ed03f7963715bc6e7c7de6faae0b1ba917 (diff) | |
download | lombok-67371e5841e1dd8ed5d663f1c907da0952976b8f.tar.gz lombok-67371e5841e1dd8ed5d663f1c907da0952976b8f.tar.bz2 lombok-67371e5841e1dd8ed5d663f1c907da0952976b8f.zip |
imports expanded, idents aligned
Diffstat (limited to 'src/core/lombok/eclipse/handlers')
-rw-r--r-- | src/core/lombok/eclipse/handlers/HandleVal.java | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleVal.java b/src/core/lombok/eclipse/handlers/HandleVal.java index 0a136d0b..e8b1deb4 100644 --- a/src/core/lombok/eclipse/handlers/HandleVal.java +++ b/src/core/lombok/eclipse/handlers/HandleVal.java @@ -21,18 +21,14 @@ */ package lombok.eclipse.handlers; -import static lombok.core.handlers.HandlerUtil.*; -import static lombok.eclipse.handlers.EclipseHandlerUtil.typeMatches; - import lombok.ConfigurationKeys; -import lombok.val; import lombok.core.HandlerPriority; import lombok.eclipse.DeferUntilPostDiet; import lombok.eclipse.EclipseASTAdapter; import lombok.eclipse.EclipseASTVisitor; import lombok.eclipse.EclipseNode; - import lombok.experimental.var; +import lombok.val; import org.eclipse.jdt.internal.compiler.ast.ArrayInitializer; import org.eclipse.jdt.internal.compiler.ast.ForStatement; import org.eclipse.jdt.internal.compiler.ast.ForeachStatement; @@ -40,6 +36,9 @@ import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration; 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; + /* * This class just handles 3 basic error cases. The real meat of eclipse 'val' support is in {@code PatchVal} and {@code PatchValEclipse}. */ @@ -51,34 +50,34 @@ public class HandleVal extends EclipseASTAdapter { TypeReference type = local.type; boolean isVal = typeMatches(val.class, localNode, type); boolean isVar = typeMatches(var.class, localNode, type); - if (!(isVal ||isVar)) return; - + if (!(isVal || isVar)) return; + if (isVal) handleFlagUsage(localNode, ConfigurationKeys.VAL_FLAG_USAGE, "val"); if (isVar) handleFlagUsage(localNode, ConfigurationKeys.VAR_FLAG_USAGE, "var"); - + boolean variableOfForEach = false; - + if (localNode.directUp().get() instanceof ForeachStatement) { ForeachStatement fs = (ForeachStatement) localNode.directUp().get(); variableOfForEach = fs.elementVariable == local; } - + String annotation = isVal ? "val" : "var"; if (local.initialization == null && !variableOfForEach) { localNode.addError("'" + annotation + "' on a local variable requires an initializer expression"); return; } - + if (local.initialization instanceof ArrayInitializer) { localNode.addError("'" + annotation + "' is not compatible with array initializer expressions. Use the full form (new int[] { ... } instead of just { ... })"); return; } - + if (isVal && localNode.directUp().get() instanceof ForStatement) { localNode.addError("'val' is not allowed in old-style for loops"); return; } - + 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."); } |