diff options
Diffstat (limited to 'src/core/lombok/eclipse')
-rw-r--r-- | src/core/lombok/eclipse/EclipseAugments.java | 39 | ||||
-rw-r--r-- | src/core/lombok/eclipse/HandlerLibrary.java | 8 | ||||
-rw-r--r-- | src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java | 18 |
3 files changed, 48 insertions, 17 deletions
diff --git a/src/core/lombok/eclipse/EclipseAugments.java b/src/core/lombok/eclipse/EclipseAugments.java new file mode 100644 index 00000000..f4583ac4 --- /dev/null +++ b/src/core/lombok/eclipse/EclipseAugments.java @@ -0,0 +1,39 @@ +/* + * 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.eclipse; + +import org.eclipse.jdt.internal.compiler.ast.ASTNode; +import org.eclipse.jdt.internal.compiler.ast.Annotation; +import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; + +import lombok.core.FieldAugment; + +public final class EclipseAugments { + private EclipseAugments() { + // Prevent instantiation + } + + public static final FieldAugment<FieldDeclaration, Boolean> FieldDeclaration_booleanLazyGetter = FieldAugment.augment(FieldDeclaration.class, boolean.class, "lombok$booleanLazyGetter"); + public static final FieldAugment<ASTNode, Boolean> ASTNode_handled = FieldAugment.augment(ASTNode.class, boolean.class, "lombok$handled"); + public static final FieldAugment<ASTNode, ASTNode> ASTNode_generatedBy = FieldAugment.augment(ASTNode.class, ASTNode.class, "$generatedBy"); + public static final FieldAugment<Annotation, Boolean> Annotation_applied = FieldAugment.augment(Annotation.class, boolean.class, "lombok$applied"); +} diff --git a/src/core/lombok/eclipse/HandlerLibrary.java b/src/core/lombok/eclipse/HandlerLibrary.java index 3e5a557f..07c6f97b 100644 --- a/src/core/lombok/eclipse/HandlerLibrary.java +++ b/src/core/lombok/eclipse/HandlerLibrary.java @@ -23,6 +23,7 @@ package lombok.eclipse; import static lombok.eclipse.Eclipse.*; import static lombok.eclipse.handlers.EclipseHandlerUtil.*; +import static lombok.eclipse.EclipseAugments.ASTNode_handled; import java.io.IOException; import java.lang.annotation.Annotation; @@ -38,7 +39,6 @@ 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,14 +188,12 @@ public class HandlerLibrary { } } - private static final BooleanFieldAugment<ASTNode> handled = BooleanFieldAugment.augment(ASTNode.class, "lombok$handled"); - private boolean checkAndSetHandled(ASTNode node) { - return !handled.set(node); + return !ASTNode_handled.getAndSet(node, true); } private boolean needsHandling(ASTNode node) { - return !handled.get(node); + return !ASTNode_handled.get(node); } /** diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index b37dbd81..6a903e4c 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -21,8 +21,9 @@ */ package lombok.eclipse.handlers; -import static lombok.eclipse.Eclipse.*; import static lombok.core.handlers.HandlerUtil.*; +import static lombok.eclipse.Eclipse.*; +import static lombok.eclipse.EclipseAugments.*; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; @@ -43,8 +44,6 @@ 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.configuration.NullCheckExceptionType; import lombok.core.handlers.HandlerUtil; @@ -109,7 +108,6 @@ import org.eclipse.jdt.internal.compiler.lookup.TypeIds; import org.eclipse.jdt.internal.compiler.lookup.WildcardBinding; import org.osgi.framework.Bundle; - /** * Container for static utility methods useful to handlers written for eclipse. */ @@ -211,10 +209,8 @@ public class EclipseHandlerUtil { } } - private static ReferenceFieldAugment<ASTNode, ASTNode> generatedNodes = ReferenceFieldAugment.augment(ASTNode.class, ASTNode.class, "$generatedBy"); - public static ASTNode getGeneratedBy(ASTNode node) { - return generatedNodes.get(node); + return ASTNode_generatedBy.get(node); } public static boolean isGenerated(ASTNode node) { @@ -222,7 +218,7 @@ public class EclipseHandlerUtil { } public static ASTNode setGeneratedBy(ASTNode node, ASTNode source) { - generatedNodes.set(node, source); + ASTNode_generatedBy.set(node, source); return node; } @@ -844,11 +840,9 @@ public class EclipseHandlerUtil { } } - 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.set(field); + FieldDeclaration_booleanLazyGetter.set(field, true); } } @@ -858,7 +852,7 @@ public class EclipseHandlerUtil { private static GetterMethod findGetter(EclipseNode field) { FieldDeclaration fieldDeclaration = (FieldDeclaration) field.get(); - boolean forceBool = generatedLazyGettersWithPrimitiveBoolean.get(fieldDeclaration); + boolean forceBool = FieldDeclaration_booleanLazyGetter.get(fieldDeclaration); TypeReference fieldType = fieldDeclaration.type; boolean isBoolean = forceBool || isBoolean(fieldType); |