diff options
author | Roel Spilker <r.spilker@gmail.com> | 2014-03-18 21:53:20 +0100 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2014-03-18 21:53:20 +0100 |
commit | db71f39c271f1f8124fac96daa68d8b012fbf390 (patch) | |
tree | 6ac442401e3c3e957caf05decb5baa0602f9043d /src/core/lombok/javac | |
parent | 0de56b76e6e9ba738232a3eb6c66c16df7346c82 (diff) | |
parent | 17972d59fa7e2eec6b73ba5da8234f5fa7ac2536 (diff) | |
download | lombok-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/javac')
-rw-r--r-- | src/core/lombok/javac/HandlerLibrary.java | 13 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/JavacHandlerUtil.java | 18 |
2 files changed, 11 insertions, 20 deletions
diff --git a/src/core/lombok/javac/HandlerLibrary.java b/src/core/lombok/javac/HandlerLibrary.java index 0905170b..7d40204b 100644 --- a/src/core/lombok/javac/HandlerLibrary.java +++ b/src/core/lombok/javac/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 @@ -30,16 +30,16 @@ import java.util.HashMap; import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; -import java.util.WeakHashMap; import javax.annotation.processing.Messager; import javax.tools.Diagnostic; +import lombok.core.AnnotationValues.AnnotationValueDecodeFail; +import lombok.core.BooleanFieldAugment; import lombok.core.HandlerPriority; import lombok.core.SpiLoadUtil; import lombok.core.TypeLibrary; import lombok.core.TypeResolver; -import lombok.core.AnnotationValues.AnnotationValueDecodeFail; import lombok.core.configuration.ConfigurationKeysLoader; import lombok.javac.handlers.JavacHandlerUtil; @@ -206,13 +206,10 @@ public class HandlerLibrary { if (t != null) t.printStackTrace(); } - private static final Map<JCTree, Object> handledMap = new WeakHashMap<JCTree, Object>(); - private static final Object MARKER = new Object(); + private static final BooleanFieldAugment<JCTree> handled = BooleanFieldAugment.augment(JCTree.class, "lombok$handled"); private boolean checkAndSetHandled(JCTree node) { - synchronized (handledMap) { - return handledMap.put(node, MARKER) != MARKER; - } + return !handled.set(node); } /** diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index 37164a6c..aa395e08 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -25,14 +25,12 @@ import static lombok.core.handlers.HandlerUtil.*; import static lombok.javac.Javac.*; import java.lang.annotation.Annotation; -import java.lang.ref.WeakReference; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import java.util.WeakHashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -43,8 +41,9 @@ import lombok.Getter; import lombok.core.AST.Kind; import lombok.core.AnnotationValues; import lombok.core.AnnotationValues.AnnotationValue; -import lombok.core.handlers.HandlerUtil; +import lombok.core.ReferenceFieldAugment; import lombok.core.TypeResolver; +import lombok.core.handlers.HandlerUtil; import lombok.delombok.LombokOptionsFactory; import lombok.experimental.Accessors; import lombok.javac.Javac; @@ -111,7 +110,7 @@ public class JavacHandlerUtil { } } - private static Map<JCTree, WeakReference<JCTree>> generatedNodes = new WeakHashMap<JCTree, WeakReference<JCTree>>(); + private static ReferenceFieldAugment<JCTree, JCTree> generatedNodes = ReferenceFieldAugment.augmentWeakField(JCTree.class, JCTree.class, "lombok$generatedNodes"); /** * Contributed by Jan Lahoda; many lombok transformations should not be run (or a lite version should be run) when the netbeans editor @@ -128,10 +127,7 @@ public class JavacHandlerUtil { } public static JCTree getGeneratedBy(JCTree node) { - synchronized (generatedNodes) { - WeakReference<JCTree> ref = generatedNodes.get(node); - return ref == null ? null : ref.get(); - } + return generatedNodes.get(node); } public static boolean isGenerated(JCTree node) { @@ -147,10 +143,8 @@ public class JavacHandlerUtil { public static <T extends JCTree> T setGeneratedBy(T node, JCTree source, Context context) { if (node == null) return null; - synchronized (generatedNodes) { - if (source == null) generatedNodes.remove(node); - else generatedNodes.put(node, new WeakReference<JCTree>(source)); - } + if (source == null) generatedNodes.clear(node); + else generatedNodes.set(node, source); if (source != null && (!inNetbeansEditor(context) || (node instanceof JCVariableDecl && (((JCVariableDecl) node).mods.flags & Flags.PARAMETER) != 0))) node.pos = source.pos; return node; } |