aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2010-11-07 15:13:47 +0100
committerRoel Spilker <r.spilker@gmail.com>2010-11-07 15:13:47 +0100
commit378b939108ef2216da00724a8efd9521b7a10b8f (patch)
tree1b4b8a3d9d8958a06a8a05b51e0146b9afd79a11
parent1f0db1191a7fcc35aaeab1481a806201a450d797 (diff)
downloadlombok-378b939108ef2216da00724a8efd9521b7a10b8f.tar.gz
lombok-378b939108ef2216da00724a8efd9521b7a10b8f.tar.bz2
lombok-378b939108ef2216da00724a8efd9521b7a10b8f.zip
Now generated nodes can also be detected in ecj
-rw-r--r--src/core/lombok/eclipse/Eclipse.java28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/core/lombok/eclipse/Eclipse.java b/src/core/lombok/eclipse/Eclipse.java
index 915706f9..659651d6 100644
--- a/src/core/lombok/eclipse/Eclipse.java
+++ b/src/core/lombok/eclipse/Eclipse.java
@@ -29,6 +29,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.WeakHashMap;
import lombok.core.AnnotationValues;
import lombok.core.TypeLibrary;
@@ -476,12 +477,16 @@ public class Eclipse {
}
}
+ private static Map<ASTNode, ASTNode> generatedNodes = new WeakHashMap<ASTNode, ASTNode>();
+
public static ASTNode getGeneratedBy(ASTNode node) {
- try {
- return (ASTNode) generatedByField.get(node);
- } catch (Exception t) {
- //ignore - no $generatedBy exists when running in ecj.
- return null;
+ if (generatedByField != null) {
+ try {
+ return (ASTNode) generatedByField.get(node);
+ } catch (Exception e) {}
+ }
+ synchronized (generatedNodes) {
+ return generatedNodes.get(node);
}
}
@@ -490,12 +495,15 @@ public class Eclipse {
}
public static ASTNode setGeneratedBy(ASTNode node, ASTNode source) {
- try {
- generatedByField.set(node, source);
- } catch (Exception t) {
- //ignore - no $generatedBy exists when running in ecj.
+ if (generatedByField != null) {
+ try {
+ generatedByField.set(node, source);
+ return node;
+ } catch (Exception e) {}
+ }
+ synchronized (generatedNodes) {
+ generatedNodes.put(node, source);
}
-
return node;
}
}