aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2014-03-18 21:53:20 +0100
committerRoel Spilker <r.spilker@gmail.com>2014-03-18 21:53:20 +0100
commitdb71f39c271f1f8124fac96daa68d8b012fbf390 (patch)
tree6ac442401e3c3e957caf05decb5baa0602f9043d /src/core/lombok/eclipse
parent0de56b76e6e9ba738232a3eb6c66c16df7346c82 (diff)
parent17972d59fa7e2eec6b73ba5da8234f5fa7ac2536 (diff)
downloadlombok-db71f39c271f1f8124fac96daa68d8b012fbf390.tar.gz
lombok-db71f39c271f1f8124fac96daa68d8b012fbf390.tar.bz2
lombok-db71f39c271f1f8124fac96daa68d8b012fbf390.zip
Merge branch 'master' into configuration
Conflicts: build.xml src/core/lombok/eclipse/HandlerLibrary.java src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java src/core/lombok/javac/HandlerLibrary.java src/core/lombok/javac/handlers/JavacHandlerUtil.java
Diffstat (limited to 'src/core/lombok/eclipse')
-rw-r--r--src/core/lombok/eclipse/HandlerLibrary.java15
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java42
2 files changed, 13 insertions, 44 deletions
diff --git a/src/core/lombok/eclipse/HandlerLibrary.java b/src/core/lombok/eclipse/HandlerLibrary.java
index ad9c87b9..9726255c 100644
--- a/src/core/lombok/eclipse/HandlerLibrary.java
+++ b/src/core/lombok/eclipse/HandlerLibrary.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009-2013 The Project Lombok Authors.
+ * Copyright (C) 2009-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
@@ -33,12 +33,12 @@ import java.util.HashMap;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
-import java.util.WeakHashMap;
import lombok.Lombok;
import lombok.core.AnnotationValues;
import lombok.core.AnnotationValues.AnnotationValueDecodeFail;
import lombok.core.configuration.ConfigurationKeysLoader;
+import lombok.core.BooleanFieldAugment;
import lombok.core.HandlerPriority;
import lombok.core.SpiLoadUtil;
import lombok.core.TypeLibrary;
@@ -188,19 +188,14 @@ public class HandlerLibrary {
}
}
- private static final Map<ASTNode, Object> handledMap = new WeakHashMap<ASTNode, Object>();
- private static final Object MARKER = new Object();
+ private static final BooleanFieldAugment<ASTNode> handled = BooleanFieldAugment.augment(ASTNode.class, "lombok$handled");
private boolean checkAndSetHandled(ASTNode node) {
- synchronized (handledMap) {
- return handledMap.put(node, MARKER) != MARKER;
- }
+ return !handled.set(node);
}
private boolean needsHandling(ASTNode node) {
- synchronized (handledMap) {
- return handledMap.get(node) != MARKER;
- }
+ return !handled.get(node);
}
/**
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
index 94fdffad..a93f321b 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -25,7 +25,6 @@ import static lombok.eclipse.Eclipse.*;
import static lombok.core.handlers.HandlerUtil.*;
import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@@ -35,7 +34,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.WeakHashMap;
import lombok.AccessLevel;
import lombok.ConfigurationKeys;
@@ -45,6 +43,8 @@ import lombok.Lombok;
import lombok.core.AST.Kind;
import lombok.core.AnnotationValues;
import lombok.core.AnnotationValues.AnnotationValue;
+import lombok.core.BooleanFieldAugment;
+import lombok.core.ReferenceFieldAugment;
import lombok.core.TypeResolver;
import lombok.core.handlers.HandlerUtil;
import lombok.eclipse.EclipseAST;
@@ -208,27 +208,10 @@ public class EclipseHandlerUtil {
}
}
- private static Field generatedByField;
-
- static {
- try {
- generatedByField = ASTNode.class.getDeclaredField("$generatedBy");
- } catch (Throwable t) {
- //ignore - no $generatedBy exists when running in ecj.
- }
- }
-
- private static Map<ASTNode, ASTNode> generatedNodes = new WeakHashMap<ASTNode, ASTNode>();
+ private static ReferenceFieldAugment<ASTNode, ASTNode> generatedNodes = ReferenceFieldAugment.augment(ASTNode.class, ASTNode.class, "$generatedBy");
public static ASTNode getGeneratedBy(ASTNode node) {
- if (generatedByField != null) {
- try {
- return (ASTNode) generatedByField.get(node);
- } catch (Exception e) {}
- }
- synchronized (generatedNodes) {
- return generatedNodes.get(node);
- }
+ return generatedNodes.get(node);
}
public static boolean isGenerated(ASTNode node) {
@@ -236,15 +219,7 @@ public class EclipseHandlerUtil {
}
public static ASTNode setGeneratedBy(ASTNode node, ASTNode source) {
- if (generatedByField != null) {
- try {
- generatedByField.set(node, source);
- return node;
- } catch (Exception e) {}
- }
- synchronized (generatedNodes) {
- generatedNodes.put(node, source);
- }
+ generatedNodes.set(node, source);
return node;
}
@@ -866,12 +841,11 @@ public class EclipseHandlerUtil {
}
}
- private static final Map<FieldDeclaration, Object> generatedLazyGettersWithPrimitiveBoolean = new WeakHashMap<FieldDeclaration, Object>();
- private static final Object MARKER = new Object();
+ private static final BooleanFieldAugment<FieldDeclaration> generatedLazyGettersWithPrimitiveBoolean = BooleanFieldAugment.augment(FieldDeclaration.class, "lombok$booleanLazyGetter");
static void registerCreatedLazyGetter(FieldDeclaration field, char[] methodName, TypeReference returnType) {
if (isBoolean(returnType)) {
- generatedLazyGettersWithPrimitiveBoolean.put(field, MARKER);
+ generatedLazyGettersWithPrimitiveBoolean.set(field);
}
}
@@ -881,7 +855,7 @@ public class EclipseHandlerUtil {
private static GetterMethod findGetter(EclipseNode field) {
FieldDeclaration fieldDeclaration = (FieldDeclaration) field.get();
- boolean forceBool = generatedLazyGettersWithPrimitiveBoolean.containsKey(fieldDeclaration);
+ boolean forceBool = generatedLazyGettersWithPrimitiveBoolean.get(fieldDeclaration);
TypeReference fieldType = fieldDeclaration.type;
boolean isBoolean = forceBool || isBoolean(fieldType);