diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2011-06-20 21:03:13 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2011-06-20 21:05:06 +0200 |
commit | 0fb0c59d5aa9f18c34eac36e65dcf3c2fdf6808c (patch) | |
tree | 4c4ba80d0652b99345c88b2a6f2fecca653f9dc1 /src/core/lombok/eclipse | |
parent | bdcbd1bac40ddbfeda22a99285976e2a92fd59df (diff) | |
download | lombok-0fb0c59d5aa9f18c34eac36e65dcf3c2fdf6808c.tar.gz lombok-0fb0c59d5aa9f18c34eac36e65dcf3c2fdf6808c.tar.bz2 lombok-0fb0c59d5aa9f18c34eac36e65dcf3c2fdf6808c.zip |
Javac/EclipseAnnotationHandler are now abstract classes instead of interfaces; there were too many 'option' methods (methods where you return either true or false), so we really needed the ability to pick a default.
Diffstat (limited to 'src/core/lombok/eclipse')
12 files changed, 21 insertions, 71 deletions
diff --git a/src/core/lombok/eclipse/EclipseAnnotationHandler.java b/src/core/lombok/eclipse/EclipseAnnotationHandler.java index 2841eb9f..10c0b6fb 100644 --- a/src/core/lombok/eclipse/EclipseAnnotationHandler.java +++ b/src/core/lombok/eclipse/EclipseAnnotationHandler.java @@ -34,7 +34,7 @@ import lombok.core.AnnotationValues; * * You also need to register yourself via SPI discovery as being an implementation of {@code EclipseAnnotationHandler}. */ -public interface EclipseAnnotationHandler<T extends java.lang.annotation.Annotation> { +public abstract class EclipseAnnotationHandler<T extends java.lang.annotation.Annotation> { /** * Called when an annotation is found that is likely to match the annotation you're interested in. * @@ -48,12 +48,14 @@ public interface EclipseAnnotationHandler<T extends java.lang.annotation.Annotat * to travel back up the chain (something javac AST can't do) to the parent of the annotation, as well * as access useful methods such as generating warnings or errors focused on the annotation. */ - void handle(AnnotationValues<T> annotation, org.eclipse.jdt.internal.compiler.ast.Annotation ast, EclipseNode annotationNode); + public abstract void handle(AnnotationValues<T> annotation, org.eclipse.jdt.internal.compiler.ast.Annotation ast, EclipseNode annotationNode); /** * Return true if this handler should not be run in the diet parse phase. * 'diet parse' is where method bodies aren't filled in yet. If you have a method-level annotation that modifies the contents of that method, * return {@code true} here. Otherwise, return {@code false} here. */ - boolean deferUntilPostDiet(); + public boolean deferUntilPostDiet() { + return false; + } } diff --git a/src/core/lombok/eclipse/handlers/HandleCleanup.java b/src/core/lombok/eclipse/handlers/HandleCleanup.java index 6620e9d7..bbe209d5 100644 --- a/src/core/lombok/eclipse/handlers/HandleCleanup.java +++ b/src/core/lombok/eclipse/handlers/HandleCleanup.java @@ -58,11 +58,7 @@ import org.mangosdk.spi.ProviderFor; * Handles the {@code lombok.Cleanup} annotation for eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) -public class HandleCleanup implements EclipseAnnotationHandler<Cleanup> { - @Override public boolean deferUntilPostDiet() { - return false; - } - +public class HandleCleanup extends EclipseAnnotationHandler<Cleanup> { public void handle(AnnotationValues<Cleanup> annotation, Annotation ast, EclipseNode annotationNode) { String cleanupName = annotation.getInstance().value(); if (cleanupName.length() == 0) { diff --git a/src/core/lombok/eclipse/handlers/HandleConstructor.java b/src/core/lombok/eclipse/handlers/HandleConstructor.java index a0589ad7..781e8dae 100644 --- a/src/core/lombok/eclipse/handlers/HandleConstructor.java +++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java @@ -72,11 +72,7 @@ import org.mangosdk.spi.ProviderFor; public class HandleConstructor { @ProviderFor(EclipseAnnotationHandler.class) - public static class HandleNoArgsConstructor implements EclipseAnnotationHandler<NoArgsConstructor> { - @Override public boolean deferUntilPostDiet() { - return false; - } - + public static class HandleNoArgsConstructor extends EclipseAnnotationHandler<NoArgsConstructor> { @Override public void handle(AnnotationValues<NoArgsConstructor> annotation, Annotation ast, EclipseNode annotationNode) { EclipseNode typeNode = annotationNode.up(); if (!checkLegality(typeNode, annotationNode, NoArgsConstructor.class.getSimpleName())) return; @@ -91,11 +87,7 @@ public class HandleConstructor { } @ProviderFor(EclipseAnnotationHandler.class) - public static class HandleRequiredArgsConstructor implements EclipseAnnotationHandler<RequiredArgsConstructor> { - @Override public boolean deferUntilPostDiet() { - return false; - } - + public static class HandleRequiredArgsConstructor extends EclipseAnnotationHandler<RequiredArgsConstructor> { @Override public void handle(AnnotationValues<RequiredArgsConstructor> annotation, Annotation ast, EclipseNode annotationNode) { EclipseNode typeNode = annotationNode.up(); if (!checkLegality(typeNode, annotationNode, RequiredArgsConstructor.class.getSimpleName())) return; @@ -124,11 +116,7 @@ public class HandleConstructor { } @ProviderFor(EclipseAnnotationHandler.class) - public static class HandleAllArgsConstructor implements EclipseAnnotationHandler<AllArgsConstructor> { - @Override public boolean deferUntilPostDiet() { - return false; - } - + public static class HandleAllArgsConstructor extends EclipseAnnotationHandler<AllArgsConstructor> { @Override public void handle(AnnotationValues<AllArgsConstructor> annotation, Annotation ast, EclipseNode annotationNode) { EclipseNode typeNode = annotationNode.up(); if (!checkLegality(typeNode, annotationNode, AllArgsConstructor.class.getSimpleName())) return; diff --git a/src/core/lombok/eclipse/handlers/HandleData.java b/src/core/lombok/eclipse/handlers/HandleData.java index 5d05af6b..71027c07 100644 --- a/src/core/lombok/eclipse/handlers/HandleData.java +++ b/src/core/lombok/eclipse/handlers/HandleData.java @@ -36,11 +36,7 @@ import org.mangosdk.spi.ProviderFor; * Handles the {@code lombok.Data} annotation for eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) -public class HandleData implements EclipseAnnotationHandler<Data> { - @Override public boolean deferUntilPostDiet() { - return false; - } - +public class HandleData extends EclipseAnnotationHandler<Data> { public void handle(AnnotationValues<Data> annotation, Annotation ast, EclipseNode annotationNode) { Data ann = annotation.getInstance(); EclipseNode typeNode = annotationNode.up(); diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java index 9fdbea1e..05fbd0e2 100644 --- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java @@ -86,7 +86,7 @@ import lombok.eclipse.EclipseNode; * Handles the {@code EqualsAndHashCode} annotation for eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) -public class HandleEqualsAndHashCode implements EclipseAnnotationHandler<EqualsAndHashCode> { +public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndHashCode> { private static final Set<String> BUILT_IN_TYPES = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList( "byte", "short", "int", "long", "char", "boolean", "double", "float"))); @@ -116,10 +116,6 @@ public class HandleEqualsAndHashCode implements EclipseAnnotationHandler<EqualsA generateMethods(typeNode, errorNode, null, null, null, false, FieldAccess.GETTER); } - @Override public boolean deferUntilPostDiet() { - return false; - } - @Override public void handle(AnnotationValues<EqualsAndHashCode> annotation, Annotation ast, EclipseNode annotationNode) { EqualsAndHashCode ann = annotation.getInstance(); diff --git a/src/core/lombok/eclipse/handlers/HandleGetter.java b/src/core/lombok/eclipse/handlers/HandleGetter.java index 17f2880c..88b24f8c 100644 --- a/src/core/lombok/eclipse/handlers/HandleGetter.java +++ b/src/core/lombok/eclipse/handlers/HandleGetter.java @@ -70,7 +70,7 @@ import org.mangosdk.spi.ProviderFor; * Handles the {@code lombok.Getter} annotation for eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) -public class HandleGetter implements EclipseAnnotationHandler<Getter> { +public class HandleGetter extends EclipseAnnotationHandler<Getter> { public boolean generateGetterForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean checkForTypeLevelGetter) { if (checkForTypeLevelGetter) { if (typeNode != null) for (EclipseNode child : typeNode.down()) { @@ -131,10 +131,6 @@ public class HandleGetter implements EclipseAnnotationHandler<Getter> { createGetterForField(level, fieldNode, fieldNode, pos, false, onMethod, lazy); } - @Override public boolean deferUntilPostDiet() { - return false; - } - public void handle(AnnotationValues<Getter> annotation, Annotation ast, EclipseNode annotationNode) { EclipseNode node = annotationNode.up(); Getter annotationInstance = annotation.getInstance(); diff --git a/src/core/lombok/eclipse/handlers/HandleLog.java b/src/core/lombok/eclipse/handlers/HandleLog.java index 9a10e5bc..f6d0745b 100644 --- a/src/core/lombok/eclipse/handlers/HandleLog.java +++ b/src/core/lombok/eclipse/handlers/HandleLog.java @@ -152,11 +152,7 @@ public class HandleLog { * Handles the {@link lombok.extern.apachecommons.CommonsLog} annotation for Eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) - public static class HandleCommonsLog implements EclipseAnnotationHandler<lombok.extern.apachecommons.CommonsLog> { - @Override public boolean deferUntilPostDiet() { - return false; - } - + public static class HandleCommonsLog extends EclipseAnnotationHandler<lombok.extern.apachecommons.CommonsLog> { @Override public void handle(AnnotationValues<lombok.extern.apachecommons.CommonsLog> annotation, Annotation source, EclipseNode annotationNode) { processAnnotation(LoggingFramework.COMMONS, annotation, source, annotationNode); } @@ -166,11 +162,7 @@ public class HandleLog { * Handles the {@link lombok.extern.java.Log} annotation for Eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) - public static class HandleJulLog implements EclipseAnnotationHandler<lombok.extern.java.Log> { - @Override public boolean deferUntilPostDiet() { - return false; - } - + public static class HandleJulLog extends EclipseAnnotationHandler<lombok.extern.java.Log> { @Override public void handle(AnnotationValues<lombok.extern.java.Log> annotation, Annotation source, EclipseNode annotationNode) { processAnnotation(LoggingFramework.JUL, annotation, source, annotationNode); } @@ -180,11 +172,7 @@ public class HandleLog { * Handles the {@link lombok.extern.log4j.Log4j} annotation for Eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) - public static class HandleLog4jLog implements EclipseAnnotationHandler<lombok.extern.log4j.Log4j> { - @Override public boolean deferUntilPostDiet() { - return false; - } - + public static class HandleLog4jLog extends EclipseAnnotationHandler<lombok.extern.log4j.Log4j> { @Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j> annotation, Annotation source, EclipseNode annotationNode) { processAnnotation(LoggingFramework.LOG4J, annotation, source, annotationNode); } @@ -194,11 +182,7 @@ public class HandleLog { * Handles the {@link lombok.extern.slf4j.Slf4j} annotation for Eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) - public static class HandleSlf4jLog implements EclipseAnnotationHandler<lombok.extern.slf4j.Slf4j> { - @Override public boolean deferUntilPostDiet() { - return false; - } - + public static class HandleSlf4jLog extends EclipseAnnotationHandler<lombok.extern.slf4j.Slf4j> { @Override public void handle(AnnotationValues<lombok.extern.slf4j.Slf4j> annotation, Annotation source, EclipseNode annotationNode) { processAnnotation(LoggingFramework.SLF4J, annotation, source, annotationNode); } diff --git a/src/core/lombok/eclipse/handlers/HandlePrintAST.java b/src/core/lombok/eclipse/handlers/HandlePrintAST.java index 6fa7b938..95db4e18 100644 --- a/src/core/lombok/eclipse/handlers/HandlePrintAST.java +++ b/src/core/lombok/eclipse/handlers/HandlePrintAST.java @@ -39,7 +39,7 @@ import lombok.eclipse.EclipseNode; * Handles the {@code lombok.core.PrintAST} annotation for eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) -public class HandlePrintAST implements EclipseAnnotationHandler<PrintAST> { +public class HandlePrintAST extends EclipseAnnotationHandler<PrintAST> { @Override public boolean deferUntilPostDiet() { return true; } diff --git a/src/core/lombok/eclipse/handlers/HandleSetter.java b/src/core/lombok/eclipse/handlers/HandleSetter.java index c9f98d15..1f1ab628 100644 --- a/src/core/lombok/eclipse/handlers/HandleSetter.java +++ b/src/core/lombok/eclipse/handlers/HandleSetter.java @@ -57,7 +57,7 @@ import org.mangosdk.spi.ProviderFor; * Handles the {@code lombok.Setter} annotation for eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) -public class HandleSetter implements EclipseAnnotationHandler<Setter> { +public class HandleSetter extends EclipseAnnotationHandler<Setter> { private static final Annotation[] EMPTY_ANNOTATIONS_ARRAY = new Annotation[0]; public boolean generateSetterForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean checkForTypeLevelSetter) { if (checkForTypeLevelSetter) { @@ -120,10 +120,6 @@ public class HandleSetter implements EclipseAnnotationHandler<Setter> { createSetterForField(level, fieldNode, fieldNode, pos, false, onMethod, onParam); } - @Override public boolean deferUntilPostDiet() { - return false; - } - public void handle(AnnotationValues<Setter> annotation, Annotation ast, EclipseNode annotationNode) { EclipseNode node = annotationNode.up(); AccessLevel level = annotation.getInstance().value(); diff --git a/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java b/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java index f426b9ce..4e9070f3 100644 --- a/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java +++ b/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java @@ -54,7 +54,7 @@ import org.mangosdk.spi.ProviderFor; * Handles the {@code lombok.HandleSneakyThrows} annotation for eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) -public class HandleSneakyThrows implements EclipseAnnotationHandler<SneakyThrows> { +public class HandleSneakyThrows extends EclipseAnnotationHandler<SneakyThrows> { private static class DeclaredException { final String exceptionName; final ASTNode node; diff --git a/src/core/lombok/eclipse/handlers/HandleSynchronized.java b/src/core/lombok/eclipse/handlers/HandleSynchronized.java index 905316bc..6a971bc9 100644 --- a/src/core/lombok/eclipse/handlers/HandleSynchronized.java +++ b/src/core/lombok/eclipse/handlers/HandleSynchronized.java @@ -53,7 +53,7 @@ import org.mangosdk.spi.ProviderFor; * Handles the {@code lombok.Synchronized} annotation for eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) -public class HandleSynchronized implements EclipseAnnotationHandler<Synchronized> { +public class HandleSynchronized extends EclipseAnnotationHandler<Synchronized> { private static final char[] INSTANCE_LOCK_NAME = "$lock".toCharArray(); private static final char[] STATIC_LOCK_NAME = "$LOCK".toCharArray(); diff --git a/src/core/lombok/eclipse/handlers/HandleToString.java b/src/core/lombok/eclipse/handlers/HandleToString.java index fff8750f..f1679161 100644 --- a/src/core/lombok/eclipse/handlers/HandleToString.java +++ b/src/core/lombok/eclipse/handlers/HandleToString.java @@ -67,7 +67,7 @@ import org.mangosdk.spi.ProviderFor; * Handles the {@code ToString} annotation for eclipse. */ @ProviderFor(EclipseAnnotationHandler.class) -public class HandleToString implements EclipseAnnotationHandler<ToString> { +public class HandleToString extends EclipseAnnotationHandler<ToString> { private void checkForBogusFieldNames(EclipseNode type, AnnotationValues<ToString> annotation) { if (annotation.isExplicit("exclude")) { for (int i : createListOfNonExistentFields(Arrays.asList(annotation.getInstance().exclude()), type, true, false)) { @@ -98,10 +98,6 @@ public class HandleToString implements EclipseAnnotationHandler<ToString> { generateToString(typeNode, errorNode, null, null, includeFieldNames, null, false, FieldAccess.GETTER); } - @Override public boolean deferUntilPostDiet() { - return false; - } - public void handle(AnnotationValues<ToString> annotation, Annotation ast, EclipseNode annotationNode) { ToString ann = annotation.getInstance(); List<String> excludes = Arrays.asList(ann.exclude()); |