aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBulgakov Alexander <abulgakov@at-consulting.ru>2016-11-12 15:56:17 +0300
committerBulgakov Alexander <abulgakov@at-consulting.ru>2016-11-12 15:56:17 +0300
commit67371e5841e1dd8ed5d663f1c907da0952976b8f (patch)
tree677b27b2050d84daa11b5a8846a5c7d069d81148 /src
parent4fbbd8ed03f7963715bc6e7c7de6faae0b1ba917 (diff)
downloadlombok-67371e5841e1dd8ed5d663f1c907da0952976b8f.tar.gz
lombok-67371e5841e1dd8ed5d663f1c907da0952976b8f.tar.bz2
lombok-67371e5841e1dd8ed5d663f1c907da0952976b8f.zip
imports expanded, idents aligned
Diffstat (limited to 'src')
-rw-r--r--src/core/lombok/core/handlers/HandlerUtil.java82
-rw-r--r--src/core/lombok/eclipse/handlers/HandleVal.java25
-rw-r--r--src/core/lombok/javac/handlers/HandleVal.java41
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchVal.java71
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchValEclipse.java8
5 files changed, 132 insertions, 95 deletions
diff --git a/src/core/lombok/core/handlers/HandlerUtil.java b/src/core/lombok/core/handlers/HandlerUtil.java
index cdca991a..a321e67f 100644
--- a/src/core/lombok/core/handlers/HandlerUtil.java
+++ b/src/core/lombok/core/handlers/HandlerUtil.java
@@ -21,7 +21,24 @@
*/
package lombok.core.handlers;
-import lombok.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+import lombok.AllArgsConstructor;
+import lombok.ConfigurationKeys;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.RequiredArgsConstructor;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.Value;
import lombok.core.AST;
import lombok.core.AnnotationValues;
import lombok.core.JavaIdentifiers;
@@ -33,13 +50,6 @@ import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import lombok.experimental.Wither;
-import java.util.*;
-import java.util.regex.Pattern;
-
-import static lombok.core.configuration.FlagUsageType.ALLOW;
-import static lombok.core.configuration.FlagUsageType.ERROR;
-import static lombok.core.configuration.FlagUsageType.WARNING;
-
/**
* Container for static utility methods useful for some of the standard lombok handlers, regardless of
* target platform (e.g. useful for both javac and Eclipse lombok implementations).
@@ -64,7 +74,7 @@ public class HandlerUtil {
}
/** Checks if the given name is a valid identifier.
- *
+ *
* If it is, this returns {@code true} and does nothing else.
* If it isn't, this returns {@code false} and adds an error message to the supplied node.
*/
@@ -90,15 +100,15 @@ public class HandlerUtil {
FlagUsageType fut = node.getAst().readConfiguration(key);
- boolean allowed = !allowable || ALLOW == fut;
+ boolean allowed = !allowable || FlagUsageType.ALLOW == fut;
if (!allowed) {
- node.addError("Use of " + featureName + " is disabled by default. Please use flag " + ALLOW + " to enable.");
+ node.addError("Use of " + featureName + " is disabled by default. Please use flag " + FlagUsageType.ALLOW + " to enable.");
}
if (fut != null) {
String msg = "Use of " + featureName + " is flagged according to lombok configuration.";
- if (fut == WARNING) node.addWarning(msg);
- else if (fut == ERROR) node.addError(msg);
+ if (fut == FlagUsageType.WARNING) node.addWarning(msg);
+ else if (fut == FlagUsageType.ERROR) node.addError(msg);
}
}
@@ -112,13 +122,13 @@ public class HandlerUtil {
FlagUsageType fut = null;
String featureName = null;
- if (fut1 == ERROR) {
+ if (fut1 == FlagUsageType.ERROR) {
fut = fut1;
featureName = featureName1;
- } else if (fut2 == ERROR) {
+ } else if (fut2 == FlagUsageType.ERROR) {
fut = fut2;
featureName = featureName2;
- } else if (fut1 == WARNING) {
+ } else if (fut1 == FlagUsageType.WARNING) {
fut = fut1;
featureName = featureName1;
} else {
@@ -128,7 +138,7 @@ public class HandlerUtil {
if (fut != null) {
String msg = "Use of " + featureName + " is flagged according to lombok configuration.";
- if (fut == WARNING) node.addWarning(msg);
+ if (fut == FlagUsageType.WARNING) node.addWarning(msg);
else node.addError(msg);
}
}
@@ -159,8 +169,8 @@ public class HandlerUtil {
@SuppressWarnings({"all", "unchecked", "deprecation"})
public static final List<Class<? extends java.lang.annotation.Annotation>> INVALID_ON_BUILDERS = Collections.unmodifiableList(
Arrays.<Class<? extends java.lang.annotation.Annotation>>asList(
- Getter.class, Setter.class, Wither.class, ToString.class, EqualsAndHashCode.class,
- RequiredArgsConstructor.class, AllArgsConstructor.class, NoArgsConstructor.class,
+ Getter.class, Setter.class, Wither.class, ToString.class, EqualsAndHashCode.class,
+ RequiredArgsConstructor.class, AllArgsConstructor.class, NoArgsConstructor.class,
Data.class, Value.class, lombok.experimental.Value.class, FieldDefaults.class));
/**
@@ -168,9 +178,9 @@ public class HandlerUtil {
* For prefixes that end in a letter character, the next character must be a non-lowercase character (i.e. {@code hashCode} is not {@code ashCode} even if
* {@code h} is in the prefix list, but {@code hAshcode} would become {@code ashCode}). The first prefix that matches is used. If the prefix list is empty,
* or the empty string is in the prefix list and no prefix before it matches, the fieldName will be returned verbatim.
- *
+ *
* If no prefix matches and the empty string is not in the prefix list and the prefix list is not empty, {@code null} is returned.
- *
+ *
* @param fieldName The full name of a field.
* @param prefixes A list of prefixes, usually provided by the {@code Accessors} settings annotation, listing field prefixes.
* @return The base name of the field.
@@ -213,19 +223,19 @@ public class HandlerUtil {
/**
* Generates a getter name from a given field name.
- *
+ *
* Strategy:
* <ul>
* <li>Reduce the field's name to its base name by stripping off any prefix (from {@code Accessors}). If the field name does not fit
* the prefix list, this method immediately returns {@code null}.</li>
* <li>If {@code Accessors} has {@code fluent=true}, then return the basename.</li>
* <li>Pick a prefix. 'get' normally, but 'is' if {@code isBoolean} is true.</li>
- * <li>Only if {@code isBoolean} is true: Check if the field starts with {@code is} followed by a non-lowercase character. If so, return the field name verbatim.</li>
+ * <li>Only if {@code isBoolean} is true: Check if the field starts with {@code is} followed by a non-lowercase character. If so, return the field name verbatim.</li>
* <li>Check if the first character of the field is lowercase. If so, check if the second character
* exists and is title or upper case. If so, uppercase the first character. If not, titlecase the first character.</li>
* <li>Return the prefix plus the possibly title/uppercased first character, and the rest of the field name.</li>
* </ul>
- *
+ *
* @param accessors Accessors configuration.
* @param fieldName the name of the field.
* @param isBoolean if the field is of type 'boolean'. For fields of type {@code java.lang.Boolean}, you should provide {@code false}.
@@ -237,19 +247,19 @@ public class HandlerUtil {
/**
* Generates a setter name from a given field name.
- *
+ *
* Strategy:
* <ul>
* <li>Reduce the field's name to its base name by stripping off any prefix (from {@code Accessors}). If the field name does not fit
* the prefix list, this method immediately returns {@code null}.</li>
* <li>If {@code Accessors} has {@code fluent=true}, then return the basename.</li>
* <li>Only if {@code isBoolean} is true: Check if the field starts with {@code is} followed by a non-lowercase character.
- * If so, replace {@code is} with {@code set} and return that.</li>
+ * If so, replace {@code is} with {@code set} and return that.</li>
* <li>Check if the first character of the field is lowercase. If so, check if the second character
* exists and is title or upper case. If so, uppercase the first character. If not, titlecase the first character.</li>
* <li>Return {@code "set"} plus the possibly title/uppercased first character, and the rest of the field name.</li>
* </ul>
- *
+ *
* @param accessors Accessors configuration.
* @param fieldName the name of the field.
* @param isBoolean if the field is of type 'boolean'. For fields of type {@code java.lang.Boolean}, you should provide {@code false}.
@@ -261,18 +271,18 @@ public class HandlerUtil {
/**
* Generates a wither name from a given field name.
- *
+ *
* Strategy:
* <ul>
* <li>Reduce the field's name to its base name by stripping off any prefix (from {@code Accessors}). If the field name does not fit
* the prefix list, this method immediately returns {@code null}.</li>
* <li>Only if {@code isBoolean} is true: Check if the field starts with {@code is} followed by a non-lowercase character.
- * If so, replace {@code is} with {@code with} and return that.</li>
+ * If so, replace {@code is} with {@code with} and return that.</li>
* <li>Check if the first character of the field is lowercase. If so, check if the second character
* exists and is title or upper case. If so, uppercase the first character. If not, titlecase the first character.</li>
* <li>Return {@code "with"} plus the possibly title/uppercased first character, and the rest of the field name.</li>
* </ul>
- *
+ *
* @param accessors Accessors configuration.
* @param fieldName the name of the field.
* @param isBoolean if the field is of type 'boolean'. For fields of type {@code java.lang.Boolean}, you should provide {@code false}.
@@ -313,10 +323,10 @@ public class HandlerUtil {
/**
* Returns all names of methods that would represent the getter for a field with the provided name.
- *
+ *
* For example if {@code isBoolean} is true, then a field named {@code isRunning} would produce:<br />
* {@code [isRunning, getRunning, isIsRunning, getIsRunning]}
- *
+ *
* @param accessors Accessors configuration.
* @param fieldName the name of the field.
* @param isBoolean if the field is of type 'boolean'. For fields of type 'java.lang.Boolean', you should provide {@code false}.
@@ -327,10 +337,10 @@ public class HandlerUtil {
/**
* Returns all names of methods that would represent the setter for a field with the provided name.
- *
+ *
* For example if {@code isBoolean} is true, then a field named {@code isRunning} would produce:<br />
* {@code [setRunning, setIsRunning]}
- *
+ *
* @param accessors Accessors configuration.
* @param fieldName the name of the field.
* @param isBoolean if the field is of type 'boolean'. For fields of type 'java.lang.Boolean', you should provide {@code false}.
@@ -341,10 +351,10 @@ public class HandlerUtil {
/**
* Returns all names of methods that would represent the wither for a field with the provided name.
- *
+ *
* For example if {@code isBoolean} is true, then a field named {@code isRunning} would produce:<br />
* {@code [withRunning, withIsRunning]}
- *
+ *
* @param accessors Accessors configuration.
* @param fieldName the name of the field.
* @param isBoolean if the field is of type 'boolean'. For fields of type 'java.lang.Boolean', you should provide {@code false}.
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.");
}
diff --git a/src/core/lombok/javac/handlers/HandleVal.java b/src/core/lombok/javac/handlers/HandleVal.java
index 5b90ff62..47965573 100644
--- a/src/core/lombok/javac/handlers/HandleVal.java
+++ b/src/core/lombok/javac/handlers/HandleVal.java
@@ -21,22 +21,31 @@
*/
package lombok.javac.handlers;
+import static lombok.core.handlers.HandlerUtil.*;
+import static lombok.javac.handlers.JavacHandlerUtil.*;
+import lombok.ConfigurationKeys;
+import lombok.experimental.var;
+import lombok.val;
+import lombok.core.HandlerPriority;
+import lombok.javac.JavacASTAdapter;
+import lombok.javac.JavacASTVisitor;
+import lombok.javac.JavacNode;
+import lombok.javac.JavacResolution;
+import lombok.javac.ResolutionResetNeeded;
+
+import org.mangosdk.spi.ProviderFor;
+
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.Symtab;
import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.tree.JCTree.*;
+import com.sun.tools.javac.tree.JCTree.JCAnnotation;
+import com.sun.tools.javac.tree.JCTree.JCEnhancedForLoop;
+import com.sun.tools.javac.tree.JCTree.JCExpression;
+import com.sun.tools.javac.tree.JCTree.JCForLoop;
+import com.sun.tools.javac.tree.JCTree.JCNewArray;
+import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.util.List;
-import lombok.ConfigurationKeys;
-import lombok.core.HandlerPriority;
-import lombok.javac.*;
-import lombok.val;
-import lombok.experimental.var;
-import org.mangosdk.spi.ProviderFor;
-
-import static lombok.core.handlers.HandlerUtil.handleFlagUsage;
-import static lombok.javac.handlers.JavacHandlerUtil.recursiveSetGeneratedBy;
-import static lombok.javac.handlers.JavacHandlerUtil.typeMatches;
@ProviderFor(JavacASTVisitor.class)
@HandlerPriority(65536) // 2^16; resolution needs to work, so if the RHS expression is i.e. a call to a generated getter, we have to run after that getter has been generated.
@@ -98,13 +107,13 @@ public class HandleVal extends JavacASTAdapter {
JCAnnotation valAnnotation = recursiveSetGeneratedBy(localNode.getTreeMaker().Annotation(local.vartype, List.<JCExpression>nil()), typeTree, localNode.getContext());
local.mods.annotations = local.mods.annotations == null ? List.of(valAnnotation) : local.mods.annotations.append(valAnnotation);
}
-
+
if (JavacResolution.platformHasTargetTyping()) {
local.vartype = localNode.getAst().getTreeMaker().Ident(localNode.getAst().toName("___Lombok_VAL_Attrib__"));
} else {
local.vartype = JavacResolution.createJavaLangObject(localNode.getAst());
}
-
+
Type type;
try {
if (rhsOfEnhancedForLoop == null) {
@@ -137,10 +146,10 @@ public class HandleVal extends JavacASTAdapter {
type = rhsOfEnhancedForLoop.type;
}
}
-
+
try {
JCExpression replacement;
-
+
if (rhsOfEnhancedForLoop != null) {
Type componentType = JavacResolution.ifTypeIsIterableToComponent(type, localNode.getAst());
if (componentType == null) replacement = JavacResolution.createJavaLangObject(localNode.getAst());
@@ -148,7 +157,7 @@ public class HandleVal extends JavacASTAdapter {
} else {
replacement = JavacResolution.typeToJCTree(type, localNode.getAst(), false);
}
-
+
if (replacement != null) {
local.vartype = replacement;
} else {
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
index 43e93bbe..e4dd7b26 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
@@ -21,9 +21,22 @@
*/
package lombok.eclipse.agent;
-import org.eclipse.jdt.internal.compiler.ast.*;
+import org.eclipse.jdt.internal.compiler.ast.Annotation;
+import org.eclipse.jdt.internal.compiler.ast.Expression;
+import org.eclipse.jdt.internal.compiler.ast.ForeachStatement;
+import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.QualifiedTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.lookup.ArrayBinding;
+import org.eclipse.jdt.internal.compiler.lookup.Binding;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
+import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
+import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
import java.lang.reflect.Field;
@@ -31,13 +44,13 @@ import static lombok.eclipse.Eclipse.poss;
import static lombok.eclipse.handlers.EclipseHandlerUtil.makeType;
public class PatchVal {
-
+
// This is half of the work for 'val' support - the other half is in PatchValEclipse. This half is enough for ecj.
// Creates a copy of the 'initialization' field on a LocalDeclaration if the type of the LocalDeclaration is 'val', because the completion parser will null this out,
// which in turn stops us from inferring the intended type for 'val x = 5;'. We look at the copy.
// Also patches local declaration to not call .resolveType() on the initializer expression if we've already done so (calling it twice causes weird errors),
// and patches .resolve() on LocalDeclaration itself to just-in-time replace the 'val' vartype with the right one.
-
+
public static TypeBinding skipResolveInitializerIfAlreadyCalled(Expression expr, BlockScope scope) {
if (expr.resolvedType != null) return expr.resolvedType;
try {
@@ -49,7 +62,7 @@ public class PatchVal {
return null;
}
}
-
+
public static TypeBinding skipResolveInitializerIfAlreadyCalled2(Expression expr, BlockScope scope, LocalDeclaration decl) {
if (decl != null && LocalDeclaration.class.equals(decl.getClass()) && expr.resolvedType != null) return expr.resolvedType;
try {
@@ -61,23 +74,23 @@ public class PatchVal {
return null;
}
}
-
+
public static boolean matches(String key, char[] array) {
if (array == null || key.length() != array.length) return false;
for (int i = 0; i < array.length; i++) {
if (key.charAt(i) != array[i]) return false;
}
-
+
return true;
}
-
+
public static boolean couldBe(String key, TypeReference ref) {
String[] keyParts = key.split("\\.");
if (ref instanceof SingleTypeReference) {
char[] token = ((SingleTypeReference)ref).token;
return matches(keyParts[keyParts.length - 1], token);
}
-
+
if (ref instanceof QualifiedTypeReference) {
char[][] tokens = ((QualifiedTypeReference)ref).tokens;
if (keyParts.length != tokens.length) return false;
@@ -88,7 +101,7 @@ public class PatchVal {
}
return true;
}
-
+
return false;
}
@@ -110,20 +123,20 @@ public class PatchVal {
System.arraycopy(nm, 0, fullName, pkgFullLength, nm.length);
return matches(key, fullName);
}
-
+
public static final class Reflection {
private static final Field initCopyField, iterableCopyField;
-
+
static {
Field a = null, b = null;
-
+
try {
a = LocalDeclaration.class.getDeclaredField("$initCopy");
b = LocalDeclaration.class.getDeclaredField("$iterableCopy");
} catch (Throwable t) {
//ignore - no $initCopy exists when running in ecj.
}
-
+
initCopyField = a;
iterableCopyField = b;
}
@@ -131,11 +144,11 @@ public class PatchVal {
public static boolean handleValForLocalDeclaration(LocalDeclaration local, BlockScope scope) {
if (local == null || !LocalDeclaration.class.equals(local.getClass())) return false;
boolean decomponent = false;
-
+
boolean val = isVal(local, scope);
boolean var = isVar(local, scope);
if (!(val || var)) return false;
-
+
StackTraceElement[] st = new Throwable().getStackTrace();
for (int i = 0; i < st.length - 2 && i < 10; i++) {
if (st[i].getClassName().equals("lombok.launch.PatchFixesHider$Val")) {
@@ -146,7 +159,7 @@ public class PatchVal {
break;
}
}
-
+
Expression init = local.initialization;
if (init == null && Reflection.initCopyField != null) {
try {
@@ -155,7 +168,7 @@ public class PatchVal {
// init remains null.
}
}
-
+
if (init == null && Reflection.iterableCopyField != null) {
try {
init = (Expression) Reflection.iterableCopyField.get(local);
@@ -190,7 +203,7 @@ public class PatchVal {
}
}
}
-
+
if(val) local.modifiers |= ClassFileConstants.AccFinal;
local.annotations = addValAnnotation(local.annotations, local.type, scope);
local.type = replacement != null ? replacement : new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, poss(local.type, 3));
@@ -212,16 +225,16 @@ public class PatchVal {
boolean val = isVal(forEach.elementVariable, scope);
boolean var = isVar(forEach.elementVariable, scope);
if (!(val || var)) return false;
-
+
TypeBinding component = getForEachComponentType(forEach.collection, scope);
if (component == null) return false;
TypeReference replacement = makeType(component, forEach.elementVariable.type, false);
-
+
if (val) forEach.elementVariable.modifiers |= ClassFileConstants.AccFinal;
forEach.elementVariable.annotations = addValAnnotation(forEach.elementVariable.annotations, forEach.elementVariable.type, scope);
forEach.elementVariable.type = replacement != null ? replacement :
new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, poss(forEach.elementVariable.type, 3));
-
+
return false;
}
@@ -233,12 +246,12 @@ public class PatchVal {
} else {
newAnn = new Annotation[1];
}
-
+
newAnn[newAnn.length - 1] = new org.eclipse.jdt.internal.compiler.ast.MarkerAnnotation(originalRef, originalRef.sourceStart);
-
+
return newAnn;
}
-
+
private static TypeBinding getForEachComponentType(Expression collection, BlockScope scope) {
if (collection != null) {
TypeBinding resolved = collection.resolvedType;
@@ -249,7 +262,7 @@ public class PatchVal {
return resolved;
} else if (resolved instanceof ReferenceBinding) {
ReferenceBinding iterableType = ((ReferenceBinding)resolved).findSuperTypeOriginatingFrom(TypeIds.T_JavaLangIterable, false);
-
+
TypeBinding[] arguments = null;
if (iterableType != null) switch (iterableType.kind()) {
case Binding.GENERIC_TYPE : // for (T t : Iterable<T>) - in case used inside Iterable itself
@@ -261,16 +274,16 @@ public class PatchVal {
case Binding.RAW_TYPE : // for(Object e : Iterable)
return null;
}
-
+
if (arguments != null && arguments.length == 1) {
return arguments[0];
}
}
}
-
+
return null;
}
-
+
private static TypeBinding resolveForExpression(Expression collection, BlockScope scope) {
try {
return collection.resolveType(scope);
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchValEclipse.java b/src/eclipseAgent/lombok/eclipse/agent/PatchValEclipse.java
index d0c29ac8..505eb767 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchValEclipse.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchValEclipse.java
@@ -41,7 +41,13 @@ import org.eclipse.jdt.core.dom.QualifiedName;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclarationStatement;
-import org.eclipse.jdt.internal.compiler.ast.*;
+import org.eclipse.jdt.internal.compiler.ast.ASTNode;
+import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.Annotation;
+import org.eclipse.jdt.internal.compiler.ast.ForeachStatement;
+import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
+import org.eclipse.jdt.internal.compiler.ast.TypeReference;
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
import org.eclipse.jdt.internal.compiler.parser.Parser;