diff options
author | Roel Spilker <r.spilker@gmail.com> | 2014-06-06 02:56:05 +0200 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2014-06-06 02:56:05 +0200 |
commit | 33ead46639087a4e772d6535d0354f39fadc5724 (patch) | |
tree | 1a7806ed96d22727e7eda70fcd4231df55668f5e /src/core/lombok/javac | |
parent | 288a2236c0d5c4c129d837330ca16bfef8e5b2e2 (diff) | |
parent | 68c5b016f9a2663abc9cd4aeb0cc0034949469ca (diff) | |
download | lombok-33ead46639087a4e772d6535d0354f39fadc5724.tar.gz lombok-33ead46639087a4e772d6535d0354f39fadc5724.tar.bz2 lombok-33ead46639087a4e772d6535d0354f39fadc5724.zip |
Merge branch 'master' into configResolutionInEclipse
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r-- | src/core/lombok/javac/HandlerLibrary.java | 7 | ||||
-rw-r--r-- | src/core/lombok/javac/JavacAugments.java | 35 | ||||
-rw-r--r-- | src/core/lombok/javac/apt/Processor.java | 6 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/JavacHandlerUtil.java | 10 |
4 files changed, 47 insertions, 11 deletions
diff --git a/src/core/lombok/javac/HandlerLibrary.java b/src/core/lombok/javac/HandlerLibrary.java index 7d40204b..30aeff73 100644 --- a/src/core/lombok/javac/HandlerLibrary.java +++ b/src/core/lombok/javac/HandlerLibrary.java @@ -21,6 +21,8 @@ */ package lombok.javac; +import static lombok.javac.JavacAugments.JCTree_handled; + import java.io.IOException; import java.lang.annotation.Annotation; import java.util.ArrayList; @@ -35,7 +37,6 @@ 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; @@ -206,10 +207,8 @@ public class HandlerLibrary { if (t != null) t.printStackTrace(); } - private static final BooleanFieldAugment<JCTree> handled = BooleanFieldAugment.augment(JCTree.class, "lombok$handled"); - private boolean checkAndSetHandled(JCTree node) { - return !handled.set(node); + return !JCTree_handled.getAndSet(node, true); } /** diff --git a/src/core/lombok/javac/JavacAugments.java b/src/core/lombok/javac/JavacAugments.java new file mode 100644 index 00000000..bc23131b --- /dev/null +++ b/src/core/lombok/javac/JavacAugments.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ +package lombok.javac; + +import lombok.core.FieldAugment; + +import com.sun.tools.javac.tree.JCTree; + +public final class JavacAugments { + private JavacAugments() { + // Prevent instantiation + } + + public static final FieldAugment<JCTree, Boolean> JCTree_handled = FieldAugment.augment(JCTree.class, boolean.class, "lombok$handled"); + public static final FieldAugment<JCTree, JCTree> JCTree_generatedNode = FieldAugment.circularSafeAugment(JCTree.class, JCTree.class, "lombok$generatedNode"); +} diff --git a/src/core/lombok/javac/apt/Processor.java b/src/core/lombok/javac/apt/Processor.java index 3d234541..ce4d75ff 100644 --- a/src/core/lombok/javac/apt/Processor.java +++ b/src/core/lombok/javac/apt/Processor.java @@ -256,12 +256,16 @@ public class Processor extends AbstractProcessor { for (int i = priorityLevels.length - 1; i >= 0; i--) { Long curLevel = priorityLevels[i]; Long nextLevel = (i == priorityLevels.length - 1) ? null : priorityLevels[i + 1]; + List<JCCompilationUnit> cusToAdvance = new ArrayList<JCCompilationUnit>(); for (Map.Entry<JCCompilationUnit, Long> entry : roots.entrySet()) { if (curLevel.equals(entry.getValue())) { - entry.setValue(nextLevel); + cusToAdvance.add(entry.getKey()); newLevels.add(nextLevel); } } + for (JCCompilationUnit unit : cusToAdvance) { + roots.put(unit, nextLevel); + } } newLevels.remove(null); diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index 25b95590..6413e8ef 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -23,6 +23,7 @@ package lombok.javac.handlers; import static lombok.core.handlers.HandlerUtil.*; import static lombok.javac.Javac.*; +import static lombok.javac.JavacAugments.JCTree_generatedNode; import java.lang.annotation.Annotation; import java.lang.reflect.Method; @@ -41,7 +42,6 @@ import lombok.Getter; import lombok.core.AST.Kind; import lombok.core.AnnotationValues; import lombok.core.AnnotationValues.AnnotationValue; -import lombok.core.ReferenceFieldAugment; import lombok.core.TypeResolver; import lombok.core.configuration.NullCheckExceptionType; import lombok.core.handlers.HandlerUtil; @@ -112,8 +112,6 @@ public class JavacHandlerUtil { } } - 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 * is running javac on the open source file to find inline errors and such. As class files are compiled separately this does not affect @@ -129,7 +127,7 @@ public class JavacHandlerUtil { } public static JCTree getGeneratedBy(JCTree node) { - return generatedNodes.get(node); + return JCTree_generatedNode.get(node); } public static boolean isGenerated(JCTree node) { @@ -145,8 +143,8 @@ public class JavacHandlerUtil { public static <T extends JCTree> T setGeneratedBy(T node, JCTree source, Context context) { if (node == null) return null; - if (source == null) generatedNodes.clear(node); - else generatedNodes.set(node, source); + if (source == null) JCTree_generatedNode.clear(node); + else JCTree_generatedNode.set(node, source); if (source != null && (!inNetbeansEditor(context) || (node instanceof JCVariableDecl && (((JCVariableDecl) node).mods.flags & Flags.PARAMETER) != 0))) node.pos = source.pos; return node; } |