aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/eclipse/HandlerLibrary.java
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-09-23 07:43:43 +0200
committerReinier Zwitserloot <reinier@tipit.to>2009-09-23 07:43:43 +0200
commit21ea5eeca8448c8880a3f2d975dee3107e3175b3 (patch)
treeda324c234213102b5148fc43b0da82169cf9179c /src/lombok/eclipse/HandlerLibrary.java
parentec38e1a51be7d0d807faa15b7c1504063c1061d6 (diff)
downloadlombok-21ea5eeca8448c8880a3f2d975dee3107e3175b3.tar.gz
lombok-21ea5eeca8448c8880a3f2d975dee3107e3175b3.tar.bz2
lombok-21ea5eeca8448c8880a3f2d975dee3107e3175b3.zip
Slight tweak to SpiLoadUtil: It now returns iterables instead of iterators.
Diffstat (limited to 'src/lombok/eclipse/HandlerLibrary.java')
-rw-r--r--src/lombok/eclipse/HandlerLibrary.java44
1 files changed, 17 insertions, 27 deletions
diff --git a/src/lombok/eclipse/HandlerLibrary.java b/src/lombok/eclipse/HandlerLibrary.java
index 1b9ed545..ed8196f7 100644
--- a/src/lombok/eclipse/HandlerLibrary.java
+++ b/src/lombok/eclipse/HandlerLibrary.java
@@ -23,11 +23,11 @@ package lombok.eclipse;
import static lombok.eclipse.Eclipse.toQualifiedName;
+import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import lombok.Lombok;
@@ -96,44 +96,34 @@ public class HandlerLibrary {
/** Uses SPI Discovery to find implementations of {@link EclipseAnnotationHandler}. */
@SuppressWarnings("unchecked") private static void loadAnnotationHandlers(HandlerLibrary lib) {
- Iterator<EclipseAnnotationHandler> it;
try {
- it = SpiLoadUtil.findServices(EclipseAnnotationHandler.class);
- } catch ( Throwable t ) {
- throw Lombok.sneakyThrow(t);
- }
-
- while ( it.hasNext() ) {
- try {
- EclipseAnnotationHandler<?> handler = it.next();
- Class<? extends Annotation> annotationClass =
- SpiLoadUtil.findAnnotationClass(handler.getClass(), EclipseAnnotationHandler.class);
- AnnotationHandlerContainer<?> container = new AnnotationHandlerContainer(handler, annotationClass);
- if ( lib.annotationHandlers.put(container.annotationClass.getName(), container) != null ) {
- Eclipse.error(null, "Duplicate handlers for annotation type: " + container.annotationClass.getName());
+ for (EclipseAnnotationHandler<?> handler : SpiLoadUtil.findServices(EclipseAnnotationHandler.class)) {
+ try {
+ Class<? extends Annotation> annotationClass =
+ SpiLoadUtil.findAnnotationClass(handler.getClass(), EclipseAnnotationHandler.class);
+ AnnotationHandlerContainer<?> container = new AnnotationHandlerContainer(handler, annotationClass);
+ if (lib.annotationHandlers.put(container.annotationClass.getName(), container) != null) {
+ Eclipse.error(null, "Duplicate handlers for annotation type: " + container.annotationClass.getName());
+ }
+ lib.typeLibrary.addType(container.annotationClass.getName());
+ } catch (Throwable t) {
+ Eclipse.error(null, "Can't load Lombok annotation handler for Eclipse: ", t);
}
- lib.typeLibrary.addType(container.annotationClass.getName());
- } catch ( Throwable t ) {
- Eclipse.error(null, "Can't load Lombok annotation handler for Eclipse: ", t);
}
+ } catch ( IOException e ) {
+ Lombok.sneakyThrow(e);
}
}
/** Uses SPI Discovery to find implementations of {@link EclipseASTVisitor}. */
private static void loadVisitorHandlers(HandlerLibrary lib) {
- Iterator<EclipseASTVisitor> it;
try {
- it = SpiLoadUtil.findServices(EclipseASTVisitor.class);
+ for (EclipseASTVisitor visitor : SpiLoadUtil.findServices(EclipseASTVisitor.class)) {
+ lib.visitorHandlers.add(visitor);
+ }
} catch ( Throwable t ) {
throw Lombok.sneakyThrow(t);
}
- while ( it.hasNext() ) {
- try {
- lib.visitorHandlers.add(it.next());
- } catch ( Throwable t ) {
- Eclipse.error(null, "Can't load Lombok visitor handler for Eclipse: ", t);
- }
- }
}
/**