diff options
author | Roel Spilker <r.spilker@gmail.com> | 2010-11-07 15:13:47 +0100 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2010-11-07 15:13:47 +0100 |
commit | 378b939108ef2216da00724a8efd9521b7a10b8f (patch) | |
tree | 1b4b8a3d9d8958a06a8a05b51e0146b9afd79a11 | |
parent | 1f0db1191a7fcc35aaeab1481a806201a450d797 (diff) | |
download | lombok-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.java | 28 |
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; } } |