aboutsummaryrefslogtreecommitdiff
path: root/src/eclipseAgent
diff options
context:
space:
mode:
Diffstat (limited to 'src/eclipseAgent')
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java14
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java17
2 files changed, 14 insertions, 17 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java b/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java
index 6fdcfa63..6a0c25e7 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2011 The Project Lombok Authors.
+ * Copyright (C) 2010-2014 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -30,11 +30,10 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
-import java.util.WeakHashMap;
import lombok.core.AST.Kind;
+import lombok.core.BooleanFieldAugment;
import lombok.eclipse.EclipseAST;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.TransformEclipseAST;
@@ -182,11 +181,10 @@ public class PatchDelegate {
return null;
}
- private static Map<ASTNode, Object> alreadyApplied = new WeakHashMap<ASTNode, Object>();
- private static final Object MARKER = new Object();
+ private static BooleanFieldAugment<Annotation> applied = BooleanFieldAugment.augment(Annotation.class, "lombok$applied");
public static void markHandled(Annotation annotation) {
- alreadyApplied.put(annotation, MARKER);
+ applied.set(annotation);
}
private static void fillMethodBindingsForFields(CompilationUnitDeclaration cud, ClassScope scope, List<BindingTuple> methodsToDelegate) {
@@ -197,7 +195,7 @@ public class PatchDelegate {
if (field.annotations == null) continue;
for (Annotation ann : field.annotations) {
if (!isDelegate(ann, decl)) continue;
- if (alreadyApplied.put(ann, MARKER) == MARKER) continue;
+ if (applied.set(ann)) continue;
if ((field.modifiers & ClassFileConstants.AccStatic) != 0) {
EclipseAST eclipseAst = TransformEclipseAST.getAST(cud, true);
@@ -250,7 +248,7 @@ public class PatchDelegate {
if (methodDecl.annotations == null) continue;
for (Annotation ann : methodDecl.annotations) {
if (!isDelegate(ann, decl)) continue;
- if (alreadyApplied.put(ann, MARKER) == MARKER) continue;
+ if (applied.set(ann)) continue;
if (!(methodDecl instanceof MethodDeclaration)) {
EclipseAST eclipseAst = TransformEclipseAST.getAST(cud, true);
eclipseAst.get(ann).addError(LEGALITY_OF_DELEGATE);
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java b/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java
index a3d77055..9b3ec5df 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchExtensionMethod.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 The Project Lombok Authors.
+ * Copyright (C) 2012-2014 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -27,12 +27,11 @@ import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import java.util.Map;
-import java.util.WeakHashMap;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
import lombok.core.AnnotationValues.AnnotationValueDecodeFail;
+import lombok.core.ReferenceFieldAugment;
import lombok.eclipse.EclipseAST;
import lombok.eclipse.EclipseNode;
import lombok.eclipse.TransformEclipseAST;
@@ -179,14 +178,14 @@ public class PatchExtensionMethod {
return extensionMethods;
}
- private static final Map<MessageSend, PostponedError> ERRORS = new WeakHashMap<MessageSend, PostponedError>();
+ private static final ReferenceFieldAugment<MessageSend, PostponedError> postponedErrors = ReferenceFieldAugment.augment(MessageSend.class, PostponedError.class, "lombok$postponedErrors");
public static void errorNoMethodFor(ProblemReporter problemReporter, MessageSend messageSend, TypeBinding recType, TypeBinding[] params) {
- ERRORS.put(messageSend, new PostponedNoMethodError(problemReporter, messageSend, recType, params));
+ postponedErrors.set(messageSend, new PostponedNoMethodError(problemReporter, messageSend, recType, params));
}
public static void invalidMethod(ProblemReporter problemReporter, MessageSend messageSend, MethodBinding method) {
- ERRORS.put(messageSend, new PostponedInvalidMethodError(problemReporter, messageSend, method));
+ postponedErrors.set(messageSend, new PostponedInvalidMethodError(problemReporter, messageSend, method));
}
public static TypeBinding resolveType(TypeBinding resolvedType, MessageSend methodCall, BlockScope scope) {
@@ -216,7 +215,7 @@ public class PatchExtensionMethod {
if (!extension.suppressBaseMethods && !(methodCall.binding instanceof ProblemMethodBinding)) continue;
for (MethodBinding extensionMethod : extension.extensionMethods) {
if (!Arrays.equals(methodCall.selector, extensionMethod.selector)) continue;
- ERRORS.remove(methodCall);
+ postponedErrors.clear(methodCall);
if (methodCall.receiver instanceof ThisReference) {
methodCall.receiver.bits &= ~ASTNode.IsImplicitThis;
}
@@ -258,10 +257,10 @@ public class PatchExtensionMethod {
}
}
- PostponedError error = ERRORS.get(methodCall);
+ PostponedError error = postponedErrors.get(methodCall);
if (error != null) error.fire();
- ERRORS.remove(methodCall);
+ postponedErrors.clear(methodCall);
return resolvedType;
}