aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/lombok/eclipse')
-rw-r--r--src/core/lombok/eclipse/EclipseAnnotationHandler.java6
-rw-r--r--src/core/lombok/eclipse/HandlerLibrary.java29
-rw-r--r--src/core/lombok/eclipse/TransformEclipseAST.java22
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java69
-rw-r--r--src/core/lombok/eclipse/handlers/HandleCleanup.java18
-rw-r--r--src/core/lombok/eclipse/handlers/HandleConstructor.java23
-rw-r--r--src/core/lombok/eclipse/handlers/HandleData.java8
-rw-r--r--src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java14
-rw-r--r--src/core/lombok/eclipse/handlers/HandleGetter.java38
-rw-r--r--src/core/lombok/eclipse/handlers/HandleLog.java26
-rw-r--r--src/core/lombok/eclipse/handlers/HandlePrintAST.java7
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSetter.java35
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSneakyThrows.java16
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSynchronized.java14
-rw-r--r--src/core/lombok/eclipse/handlers/HandleToString.java14
15 files changed, 128 insertions, 211 deletions
diff --git a/src/core/lombok/eclipse/EclipseAnnotationHandler.java b/src/core/lombok/eclipse/EclipseAnnotationHandler.java
index aaa57603..c105f252 100644
--- a/src/core/lombok/eclipse/EclipseAnnotationHandler.java
+++ b/src/core/lombok/eclipse/EclipseAnnotationHandler.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2009 Reinier Zwitserloot and Roel Spilker.
+ * Copyright © 2009-2011 Reinier Zwitserloot and Roel Spilker.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -47,8 +47,6 @@ public interface EclipseAnnotationHandler<T extends java.lang.annotation.Annotat
* @param annotationNode The Lombok AST wrapper around the 'ast' parameter. You can use this object
* 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.
- * @return {@code true} if you don't want to be called again about this annotation during this
- * compile session (you've handled it), or {@code false} to indicate you aren't done yet.
*/
- boolean handle(AnnotationValues<T> annotation, org.eclipse.jdt.internal.compiler.ast.Annotation ast, EclipseNode annotationNode);
+ void handle(AnnotationValues<T> annotation, org.eclipse.jdt.internal.compiler.ast.Annotation ast, EclipseNode annotationNode);
}
diff --git a/src/core/lombok/eclipse/HandlerLibrary.java b/src/core/lombok/eclipse/HandlerLibrary.java
index ba7f891a..109f6fe1 100644
--- a/src/core/lombok/eclipse/HandlerLibrary.java
+++ b/src/core/lombok/eclipse/HandlerLibrary.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2009 Reinier Zwitserloot and Roel Spilker.
+ * Copyright © 2009-2011 Reinier Zwitserloot and Roel Spilker.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+import java.util.WeakHashMap;
import lombok.Lombok;
import lombok.core.AnnotationValues;
@@ -38,6 +39,7 @@ import lombok.core.TypeLibrary;
import lombok.core.TypeResolver;
import lombok.core.AnnotationValues.AnnotationValueDecodeFail;
+import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
@@ -65,10 +67,10 @@ public class HandlerLibrary {
this.annotationClass = annotationClass;
}
- public boolean handle(org.eclipse.jdt.internal.compiler.ast.Annotation annotation,
+ public void handle(org.eclipse.jdt.internal.compiler.ast.Annotation annotation,
final EclipseNode annotationNode) {
AnnotationValues<T> annValues = Eclipse.createAnnotation(annotationClass, annotationNode);
- return handler.handle(annValues, annotation, annotationNode);
+ handler.handle(annValues, annotation, annotationNode);
}
}
@@ -126,6 +128,15 @@ public class HandlerLibrary {
}
}
+ private static final Map<ASTNode, Object> handledMap = new WeakHashMap<ASTNode, Object>();
+ private static final Object MARKER = new Object();
+
+ private boolean checkAndSetHandled(ASTNode node) {
+ synchronized (handledMap) {
+ return handledMap.put(node, MARKER) != MARKER;
+ }
+ }
+
/**
* Handles the provided annotation node by first finding a qualifying instance of
* {@link EclipseAnnotationHandler} and if one exists, calling it with a freshly cooked up
@@ -143,15 +154,15 @@ public class HandlerLibrary {
* @param annotationNode The Lombok AST Node representing the Annotation AST Node.
* @param annotation 'node.get()' - convenience parameter.
*/
- public boolean handle(CompilationUnitDeclaration ast, EclipseNode annotationNode,
- org.eclipse.jdt.internal.compiler.ast.Annotation annotation) {
+ public void handleAnnotation(CompilationUnitDeclaration ast, EclipseNode annotationNode, org.eclipse.jdt.internal.compiler.ast.Annotation annotation) {
+ if (!checkAndSetHandled(annotation)) return;
+
String pkgName = annotationNode.getPackageDeclaration();
Collection<String> imports = annotationNode.getImportStatements();
TypeResolver resolver = new TypeResolver(typeLibrary, pkgName, imports);
TypeReference rawType = annotation.type;
- if (rawType == null) return false;
- boolean handled = false;
+ if (rawType == null) return;
for (String fqn : resolver.findTypeMatches(annotationNode, toQualifiedName(annotation.type.getTypeName()))) {
boolean isPrintAST = fqn.equals(PrintAST.class.getName());
if (isPrintAST == skipPrintAST) continue;
@@ -160,15 +171,13 @@ public class HandlerLibrary {
if (container == null) continue;
try {
- handled |= container.handle(annotation, annotationNode);
+ container.handle(annotation, annotationNode);
} catch (AnnotationValueDecodeFail fail) {
fail.owner.setError(fail.getMessage(), fail.idx);
} catch (Throwable t) {
Eclipse.error(ast, String.format("Lombok annotation handler %s failed", container.handler.getClass()), t);
}
}
-
- return handled;
}
/**
diff --git a/src/core/lombok/eclipse/TransformEclipseAST.java b/src/core/lombok/eclipse/TransformEclipseAST.java
index aada3ca4..314c8a7d 100644
--- a/src/core/lombok/eclipse/TransformEclipseAST.java
+++ b/src/core/lombok/eclipse/TransformEclipseAST.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2009 Reinier Zwitserloot and Roel Spilker.
+ * Copyright © 2009-2011 Reinier Zwitserloot and Roel Spilker.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -168,38 +168,28 @@ public class TransformEclipseAST {
private static class AnnotationVisitor extends EclipseASTAdapter {
@Override public void visitAnnotationOnField(FieldDeclaration field, EclipseNode annotationNode, Annotation annotation) {
- if (annotationNode.isHandled()) return;
CompilationUnitDeclaration top = (CompilationUnitDeclaration) annotationNode.top().get();
- boolean handled = handlers.handle(top, annotationNode, annotation);
- if (handled) annotationNode.setHandled();
+ handlers.handleAnnotation(top, annotationNode, annotation);
}
@Override public void visitAnnotationOnMethodArgument(Argument arg, AbstractMethodDeclaration method, EclipseNode annotationNode, Annotation annotation) {
- if (annotationNode.isHandled()) return;
CompilationUnitDeclaration top = (CompilationUnitDeclaration) annotationNode.top().get();
- boolean handled = handlers.handle(top, annotationNode, annotation);
- if (handled) annotationNode.setHandled();
+ handlers.handleAnnotation(top, annotationNode, annotation);
}
@Override public void visitAnnotationOnLocal(LocalDeclaration local, EclipseNode annotationNode, Annotation annotation) {
- if (annotationNode.isHandled()) return;
CompilationUnitDeclaration top = (CompilationUnitDeclaration) annotationNode.top().get();
- boolean handled = handlers.handle(top, annotationNode, annotation);
- if (handled) annotationNode.setHandled();
+ handlers.handleAnnotation(top, annotationNode, annotation);
}
@Override public void visitAnnotationOnMethod(AbstractMethodDeclaration method, EclipseNode annotationNode, Annotation annotation) {
- if (annotationNode.isHandled()) return;
CompilationUnitDeclaration top = (CompilationUnitDeclaration) annotationNode.top().get();
- boolean handled = handlers.handle(top, annotationNode, annotation);
- if (handled) annotationNode.setHandled();
+ handlers.handleAnnotation(top, annotationNode, annotation);
}
@Override public void visitAnnotationOnType(TypeDeclaration type, EclipseNode annotationNode, Annotation annotation) {
- if (annotationNode.isHandled()) return;
CompilationUnitDeclaration top = (CompilationUnitDeclaration) annotationNode.top().get();
- boolean handled = handlers.handle(top, annotationNode, annotation);
- if (handled) annotationNode.setHandled();
+ handlers.handleAnnotation(top, annotationNode, annotation);
}
}
}
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
index d16e3ead..0eae12f2 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2009-2010 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans.
+ * Copyright © 2009-2011 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -332,9 +332,7 @@ public class EclipseHandlerUtil {
char[] fName = def.name;
if (fName == null) continue;
if (fieldName.equals(new String(fName))) {
- EclipseNode existing = node.getNodeFor(def);
- if (existing == null || !existing.isHandled()) return MemberExistsResult.EXISTS_BY_USER;
- return MemberExistsResult.EXISTS_BY_LOMBOK;
+ return Eclipse.getGeneratedBy(def) == null ? MemberExistsResult.EXISTS_BY_USER : MemberExistsResult.EXISTS_BY_LOMBOK;
}
}
}
@@ -369,11 +367,7 @@ public class EclipseHandlerUtil {
char[] mName = def.selector;
if (mName == null) continue;
boolean nameEquals = caseSensitive ? methodName.equals(new String(mName)) : methodName.equalsIgnoreCase(new String(mName));
- if (nameEquals) {
- EclipseNode existing = node.getNodeFor(def);
- if (existing == null || !existing.isHandled()) return MemberExistsResult.EXISTS_BY_USER;
- return MemberExistsResult.EXISTS_BY_LOMBOK;
- }
+ if (nameEquals) return Eclipse.getGeneratedBy(def) == null ? MemberExistsResult.EXISTS_BY_USER : MemberExistsResult.EXISTS_BY_LOMBOK;
}
}
}
@@ -397,9 +391,7 @@ public class EclipseHandlerUtil {
if (typeDecl.methods != null) for (AbstractMethodDeclaration def : typeDecl.methods) {
if (def instanceof ConstructorDeclaration) {
if ((def.bits & ASTNode.IsDefaultConstructor) != 0) continue;
- EclipseNode existing = node.getNodeFor(def);
- if (existing == null || !existing.isHandled()) return MemberExistsResult.EXISTS_BY_USER;
- return MemberExistsResult.EXISTS_BY_LOMBOK;
+ return Eclipse.getGeneratedBy(def) == null ? MemberExistsResult.EXISTS_BY_USER : MemberExistsResult.EXISTS_BY_LOMBOK;
}
}
}
@@ -408,55 +400,6 @@ public class EclipseHandlerUtil {
}
/**
- * Returns the constructor that's already been generated by lombok.
- * Provide any node that represents the type (TypeDeclaration) to look in, or any child node thereof.
- */
- public static EclipseNode getExistingLombokConstructor(EclipseNode node) {
- while (node != null && !(node.get() instanceof TypeDeclaration)) {
- node = node.up();
- }
-
- if (node == null) return null;
-
- if (node.get() instanceof TypeDeclaration) {
- for (AbstractMethodDeclaration def : ((TypeDeclaration)node.get()).methods) {
- if (def instanceof ConstructorDeclaration) {
- if ((def.bits & ASTNode.IsDefaultConstructor) != 0) continue;
- EclipseNode existing = node.getNodeFor(def);
- if (existing.isHandled()) return existing;
- }
- }
- }
-
- return null;
- }
-
- /**
- * Returns the method that's already been generated by lombok with the given name.
- * Provide any node that represents the type (TypeDeclaration) to look in, or any child node thereof.
- */
- public static EclipseNode getExistingLombokMethod(String methodName, EclipseNode node) {
- while (node != null && !(node.get() instanceof TypeDeclaration)) {
- node = node.up();
- }
-
- if (node == null) return null;
-
- if (node.get() instanceof TypeDeclaration) {
- for (AbstractMethodDeclaration def : ((TypeDeclaration)node.get()).methods) {
- char[] mName = def.selector;
- if (mName == null) continue;
- if (methodName.equals(new String(mName))) {
- EclipseNode existing = node.getNodeFor(def);
- if (existing.isHandled()) return existing;
- }
- }
- }
-
- return null;
- }
-
- /**
* Inserts a field into an existing type. The type must represent a {@code TypeDeclaration}.
* The field carries the &#64;{@link SuppressWarnings}("all") annotation.
*/
@@ -487,7 +430,7 @@ public class EclipseHandlerUtil {
}
}
- type.add(field, Kind.FIELD).recursiveSetHandled();
+ type.add(field, Kind.FIELD);
}
private static boolean hasClinit(TypeDeclaration parent) {
@@ -573,7 +516,7 @@ public class EclipseHandlerUtil {
parent.methods = newArray;
}
- type.add(method, Kind.METHOD).recursiveSetHandled();
+ type.add(method, Kind.METHOD);
}
private static final char[] ALL = "all".toCharArray();
diff --git a/src/core/lombok/eclipse/handlers/HandleCleanup.java b/src/core/lombok/eclipse/handlers/HandleCleanup.java
index 9a63ce47..4f9615b6 100644
--- a/src/core/lombok/eclipse/handlers/HandleCleanup.java
+++ b/src/core/lombok/eclipse/handlers/HandleCleanup.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2009-2010 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans.
+ * Copyright © 2009-2011 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -59,23 +59,23 @@ import org.mangosdk.spi.ProviderFor;
*/
@ProviderFor(EclipseAnnotationHandler.class)
public class HandleCleanup implements EclipseAnnotationHandler<Cleanup> {
- public boolean handle(AnnotationValues<Cleanup> annotation, Annotation ast, EclipseNode annotationNode) {
+ public void handle(AnnotationValues<Cleanup> annotation, Annotation ast, EclipseNode annotationNode) {
String cleanupName = annotation.getInstance().value();
if (cleanupName.length() == 0) {
annotationNode.addError("cleanupName cannot be the empty string.");
- return true;
+ return;
}
if (annotationNode.up().getKind() != Kind.LOCAL) {
annotationNode.addError("@Cleanup is legal only on local variable declarations.");
- return true;
+ return;
}
LocalDeclaration decl = (LocalDeclaration)annotationNode.up().get();
if (decl.initialization == null) {
annotationNode.addError("@Cleanup variable declarations need to be initialized.");
- return true;
+ return;
}
EclipseNode ancestor = annotationNode.up().directUp();
@@ -94,12 +94,12 @@ public class HandleCleanup implements EclipseAnnotationHandler<Cleanup> {
statements = ((SwitchStatement)blockNode).statements;
} else {
annotationNode.addError("@Cleanup is legal only on a local variable declaration inside a block.");
- return true;
+ return;
}
if (statements == null) {
annotationNode.addError("LOMBOK BUG: Parent block does not contain any statements.");
- return true;
+ return;
}
int start = 0;
@@ -109,7 +109,7 @@ public class HandleCleanup implements EclipseAnnotationHandler<Cleanup> {
if (start == statements.length) {
annotationNode.addError("LOMBOK BUG: Can't find this local variable declaration inside its parent.");
- return true;
+ return;
}
start++; //We start with try{} *AFTER* the var declaration.
@@ -205,8 +205,6 @@ public class HandleCleanup implements EclipseAnnotationHandler<Cleanup> {
}
ancestor.rebuild();
-
- return true;
}
private MessageSend preventNullAnalysis(Annotation ast, Expression expr) {
diff --git a/src/core/lombok/eclipse/handlers/HandleConstructor.java b/src/core/lombok/eclipse/handlers/HandleConstructor.java
index db26beed..e0715961 100644
--- a/src/core/lombok/eclipse/handlers/HandleConstructor.java
+++ b/src/core/lombok/eclipse/handlers/HandleConstructor.java
@@ -73,34 +73,32 @@ import org.mangosdk.spi.ProviderFor;
public class HandleConstructor {
@ProviderFor(EclipseAnnotationHandler.class)
public static class HandleNoArgsConstructor implements EclipseAnnotationHandler<NoArgsConstructor> {
- @Override public boolean handle(AnnotationValues<NoArgsConstructor> annotation, Annotation ast, EclipseNode annotationNode) {
+ @Override public void handle(AnnotationValues<NoArgsConstructor> annotation, Annotation ast, EclipseNode annotationNode) {
EclipseNode typeNode = annotationNode.up();
- if (!checkLegality(typeNode, annotationNode, NoArgsConstructor.class.getSimpleName())) return true;
+ if (!checkLegality(typeNode, annotationNode, NoArgsConstructor.class.getSimpleName())) return;
NoArgsConstructor ann = annotation.getInstance();
AccessLevel level = ann.access();
String staticName = ann.staticName();
- if (level == AccessLevel.NONE) return true;
+ if (level == AccessLevel.NONE) return;
List<EclipseNode> fields = new ArrayList<EclipseNode>();
Annotation[] onConstructor = getAndRemoveAnnotationParameter(ast, "onConstructor");
new HandleConstructor().generateConstructor(typeNode, level, fields, staticName, onConstructor, false, false, ast);
- return true;
}
}
@ProviderFor(EclipseAnnotationHandler.class)
public static class HandleRequiredArgsConstructor implements EclipseAnnotationHandler<RequiredArgsConstructor> {
- @Override public boolean handle(AnnotationValues<RequiredArgsConstructor> annotation, Annotation ast, EclipseNode annotationNode) {
+ @Override public void handle(AnnotationValues<RequiredArgsConstructor> annotation, Annotation ast, EclipseNode annotationNode) {
EclipseNode typeNode = annotationNode.up();
- if (!checkLegality(typeNode, annotationNode, RequiredArgsConstructor.class.getSimpleName())) return true;
+ if (!checkLegality(typeNode, annotationNode, RequiredArgsConstructor.class.getSimpleName())) return;
RequiredArgsConstructor ann = annotation.getInstance();
AccessLevel level = ann.access();
String staticName = ann.staticName();
@SuppressWarnings("deprecation")
boolean suppressConstructorProperties = ann.suppressConstructorProperties();
- if (level == AccessLevel.NONE) return true;
+ if (level == AccessLevel.NONE) return;
Annotation[] onConstructor = getAndRemoveAnnotationParameter(ast, "onConstructor");
new HandleConstructor().generateConstructor(typeNode, level, findRequiredFields(typeNode), staticName, onConstructor, false, suppressConstructorProperties, ast);
- return true;
}
}
@@ -119,15 +117,15 @@ public class HandleConstructor {
@ProviderFor(EclipseAnnotationHandler.class)
public static class HandleAllArgsConstructor implements EclipseAnnotationHandler<AllArgsConstructor> {
- @Override public boolean handle(AnnotationValues<AllArgsConstructor> annotation, Annotation ast, EclipseNode annotationNode) {
+ @Override public void handle(AnnotationValues<AllArgsConstructor> annotation, Annotation ast, EclipseNode annotationNode) {
EclipseNode typeNode = annotationNode.up();
- if (!checkLegality(typeNode, annotationNode, AllArgsConstructor.class.getSimpleName())) return true;
+ if (!checkLegality(typeNode, annotationNode, AllArgsConstructor.class.getSimpleName())) return;
AllArgsConstructor ann = annotation.getInstance();
AccessLevel level = ann.access();
String staticName = ann.staticName();
@SuppressWarnings("deprecation")
boolean suppressConstructorProperties = ann.suppressConstructorProperties();
- if (level == AccessLevel.NONE) return true;
+ if (level == AccessLevel.NONE) return;
List<EclipseNode> fields = new ArrayList<EclipseNode>();
for (EclipseNode child : typeNode.down()) {
if (child.getKind() != Kind.FIELD) continue;
@@ -135,13 +133,12 @@ public class HandleConstructor {
if (!EclipseHandlerUtil.filterField(fieldDecl)) continue;
// Skip initialized final fields.
- if (((fieldDecl.modifiers & ClassFileConstants.AccFinal) != 0) && fieldDecl.initialization != null) return false;
+ if (((fieldDecl.modifiers & ClassFileConstants.AccFinal) != 0) && fieldDecl.initialization != null) return;
fields.add(child);
}
Annotation[] onConstructor = getAndRemoveAnnotationParameter(ast, "onConstructor");
new HandleConstructor().generateConstructor(typeNode, level, fields, staticName, onConstructor, false, suppressConstructorProperties, ast);
- return true;
}
}
diff --git a/src/core/lombok/eclipse/handlers/HandleData.java b/src/core/lombok/eclipse/handlers/HandleData.java
index 0a28ccf4..9b3d7e51 100644
--- a/src/core/lombok/eclipse/handlers/HandleData.java
+++ b/src/core/lombok/eclipse/handlers/HandleData.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker.
+ * Copyright © 2009-2011 Reinier Zwitserloot and Roel Spilker.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -37,7 +37,7 @@ import org.mangosdk.spi.ProviderFor;
*/
@ProviderFor(EclipseAnnotationHandler.class)
public class HandleData implements EclipseAnnotationHandler<Data> {
- public boolean handle(AnnotationValues<Data> annotation, Annotation ast, EclipseNode annotationNode) {
+ public void handle(AnnotationValues<Data> annotation, Annotation ast, EclipseNode annotationNode) {
Data ann = annotation.getInstance();
EclipseNode typeNode = annotationNode.up();
@@ -49,7 +49,7 @@ public class HandleData implements EclipseAnnotationHandler<Data> {
if (typeDecl == null || notAClass) {
annotationNode.addError("@Data is only supported on a class.");
- return false;
+ return;
}
//Careful: Generate the public static constructor (if there is one) LAST, so that any attempt to
@@ -63,7 +63,5 @@ public class HandleData implements EclipseAnnotationHandler<Data> {
new HandleEqualsAndHashCode().generateEqualsAndHashCodeForType(typeNode, annotationNode);
new HandleToString().generateToStringForType(typeNode, annotationNode);
new HandleConstructor().generateRequiredArgsConstructor(typeNode, AccessLevel.PUBLIC, ann.staticConstructor(), true, ast);
-
- return false;
}
}
diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
index 8ee7272c..3be8fdfa 100644
--- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
+++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2009-2010 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans.
+ * Copyright © 2009-2011 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -116,7 +116,7 @@ public class HandleEqualsAndHashCode implements EclipseAnnotationHandler<EqualsA
generateMethods(typeNode, errorNode, null, null, null, false, FieldAccess.GETTER);
}
- @Override public boolean handle(AnnotationValues<EqualsAndHashCode> annotation,
+ @Override public void handle(AnnotationValues<EqualsAndHashCode> annotation,
Annotation ast, EclipseNode annotationNode) {
EqualsAndHashCode ann = annotation.getInstance();
List<String> excludes = Arrays.asList(ann.exclude());
@@ -137,10 +137,10 @@ public class HandleEqualsAndHashCode implements EclipseAnnotationHandler<EqualsA
FieldAccess fieldAccess = ann.doNotUseGetters() ? FieldAccess.PREFER_FIELD : FieldAccess.GETTER;
- return generateMethods(typeNode, annotationNode, excludes, includes, callSuper, true, fieldAccess);
+ generateMethods(typeNode, annotationNode, excludes, includes, callSuper, true, fieldAccess);
}
- public boolean generateMethods(EclipseNode typeNode, EclipseNode errorNode, List<String> excludes, List<String> includes,
+ public void generateMethods(EclipseNode typeNode, EclipseNode errorNode, List<String> excludes, List<String> includes,
Boolean callSuper, boolean whineIfExists, FieldAccess fieldAccess) {
assert excludes == null || includes == null;
@@ -153,7 +153,7 @@ public class HandleEqualsAndHashCode implements EclipseAnnotationHandler<EqualsA
if (typeDecl == null || notAClass) {
errorNode.addError("@EqualsAndHashCode is only supported on a class.");
- return false;
+ return;
}
boolean implicitCallSuper = callSuper == null;
@@ -175,7 +175,7 @@ public class HandleEqualsAndHashCode implements EclipseAnnotationHandler<EqualsA
if (isDirectDescendantOfObject && callSuper) {
errorNode.addError("Generating equals/hashCode with a supercall to java.lang.Object is pointless.");
- return true;
+ return;
}
if (!isDirectDescendantOfObject && !callSuper && implicitCallSuper) {
@@ -249,8 +249,6 @@ public class HandleEqualsAndHashCode implements EclipseAnnotationHandler<EqualsA
}
break;
}
-
- return true;
}
private MethodDeclaration createHashCode(EclipseNode type, Collection<EclipseNode> fields, boolean callSuper, ASTNode source, FieldAccess fieldAccess) {
diff --git a/src/core/lombok/eclipse/handlers/HandleGetter.java b/src/core/lombok/eclipse/handlers/HandleGetter.java
index f39e55b5..3af09afb 100644
--- a/src/core/lombok/eclipse/handlers/HandleGetter.java
+++ b/src/core/lombok/eclipse/handlers/HandleGetter.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker.
+ * Copyright © 2009-2011 Reinier Zwitserloot and Roel Spilker.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -131,7 +131,7 @@ public class HandleGetter implements EclipseAnnotationHandler<Getter> {
createGetterForField(level, fieldNode, fieldNode, pos, false, onMethod, lazy);
}
- public boolean handle(AnnotationValues<Getter> annotation, Annotation ast, EclipseNode annotationNode) {
+ public void handle(AnnotationValues<Getter> annotation, Annotation ast, EclipseNode annotationNode) {
EclipseNode node = annotationNode.up();
Getter annotationInstance = annotation.getInstance();
AccessLevel level = annotationInstance.value();
@@ -140,46 +140,46 @@ public class HandleGetter implements EclipseAnnotationHandler<Getter> {
if (lazy) {
annotationNode.addWarning("'lazy' does not work with AccessLevel.NONE.");
}
- return true;
+ return;
}
- if (node == null) return false;
+ if (node == null) return;
Annotation[] onMethod = getAndRemoveAnnotationParameter(ast, "onMethod");
- if (node.getKind() == Kind.FIELD) {
- return createGetterForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, annotationNode.get(), true, onMethod, lazy);
- }
- if (node.getKind() == Kind.TYPE) {
+ switch (node.getKind()) {
+ case FIELD:
+ createGetterForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, annotationNode.get(), true, onMethod, lazy);
+ break;
+ case TYPE:
if (onMethod != null && onMethod.length != 0) annotationNode.addError("'onMethod' is not supported for @Getter on a type.");
if (lazy) annotationNode.addError("'lazy' is not supported for @Getter on a type.");
- return generateGetterForType(node, annotationNode, level, false);
+ generateGetterForType(node, annotationNode, level, false);
+ break;
}
- return false;
}
- private boolean createGetterForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists, Annotation[] onMethod, boolean lazy) {
+ private void createGetterForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists, Annotation[] onMethod, boolean lazy) {
for (EclipseNode fieldNode : fieldNodes) {
createGetterForField(level, fieldNode, errorNode, source, whineIfExists, onMethod, lazy);
}
- return true;
}
- private boolean createGetterForField(AccessLevel level,
+ private void createGetterForField(AccessLevel level,
EclipseNode fieldNode, EclipseNode errorNode, ASTNode source, boolean whineIfExists, Annotation[] onMethod, boolean lazy) {
if (fieldNode.getKind() != Kind.FIELD) {
errorNode.addError("@Getter is only supported on a class or a field.");
- return true;
+ return;
}
FieldDeclaration field = (FieldDeclaration) fieldNode.get();
if (lazy) {
if ((field.modifiers & ClassFileConstants.AccPrivate) == 0 || (field.modifiers & ClassFileConstants.AccFinal) == 0) {
errorNode.addError("'lazy' requires the field to be private and final.");
- return true;
+ return;
}
if (field.initialization == null) {
errorNode.addError("'lazy' requires field initialization.");
- return true;
+ return;
}
}
@@ -193,7 +193,7 @@ public class HandleGetter implements EclipseAnnotationHandler<Getter> {
for (String altName : TransformationsUtil.toAllGetterNames(fieldName, isBoolean)) {
switch (methodExists(altName, fieldNode, false)) {
case EXISTS_BY_LOMBOK:
- return true;
+ return;
case EXISTS_BY_USER:
if (whineIfExists) {
String altNameExpl = "";
@@ -201,7 +201,7 @@ public class HandleGetter implements EclipseAnnotationHandler<Getter> {
errorNode.addWarning(
String.format("Not generating %s(): A method with that name already exists%s", getterName, altNameExpl));
}
- return true;
+ return;
default:
case NOT_EXISTS:
//continue scanning the other alt names.
@@ -215,8 +215,6 @@ public class HandleGetter implements EclipseAnnotationHandler<Getter> {
}
injectMethod(fieldNode.up(), method);
-
- return true;
}
private MethodDeclaration generateGetter(TypeDeclaration parent, EclipseNode fieldNode, String name, int modifier, ASTNode source, boolean lazy) {
diff --git a/src/core/lombok/eclipse/handlers/HandleLog.java b/src/core/lombok/eclipse/handlers/HandleLog.java
index be856208..a51d8e7e 100644
--- a/src/core/lombok/eclipse/handlers/HandleLog.java
+++ b/src/core/lombok/eclipse/handlers/HandleLog.java
@@ -51,7 +51,7 @@ public class HandleLog {
throw new UnsupportedOperationException();
}
- public static boolean processAnnotation(LoggingFramework framework, AnnotationValues<? extends java.lang.annotation.Annotation> annotation, Annotation source, EclipseNode annotationNode) {
+ public static void processAnnotation(LoggingFramework framework, AnnotationValues<? extends java.lang.annotation.Annotation> annotation, Annotation source, EclipseNode annotationNode) {
EclipseNode owner = annotationNode.up();
switch (owner.getKind()) {
case TYPE:
@@ -64,22 +64,22 @@ public class HandleLog {
if (typeDecl == null || notAClass) {
annotationNode.addError("@Log is legal only on classes and enums.");
- return false;
+ return;
}
if (fieldExists("log", owner) != MemberExistsResult.NOT_EXISTS) {
annotationNode.addWarning("Field 'log' already exists.");
- return true;
+ return;
}
ClassLiteralAccess loggingType = selfType(owner, source);
injectField(owner, createField(framework, source, loggingType));
owner.rebuild();
- return true;
+ break;
default:
annotationNode.addError("@Log is legal only on types.");
- return true;
+ break;
}
}
@@ -154,8 +154,8 @@ public class HandleLog {
*/
@ProviderFor(EclipseAnnotationHandler.class)
public static class HandleCommonsLog implements EclipseAnnotationHandler<lombok.extern.apachecommons.CommonsLog> {
- @Override public boolean handle(AnnotationValues<lombok.extern.apachecommons.CommonsLog> annotation, Annotation source, EclipseNode annotationNode) {
- return processAnnotation(LoggingFramework.COMMONS, annotation, source, annotationNode);
+ @Override public void handle(AnnotationValues<lombok.extern.apachecommons.CommonsLog> annotation, Annotation source, EclipseNode annotationNode) {
+ processAnnotation(LoggingFramework.COMMONS, annotation, source, annotationNode);
}
}
@@ -164,8 +164,8 @@ public class HandleLog {
*/
@ProviderFor(EclipseAnnotationHandler.class)
public static class HandleJulLog implements EclipseAnnotationHandler<lombok.extern.java.Log> {
- @Override public boolean handle(AnnotationValues<lombok.extern.java.Log> annotation, Annotation source, EclipseNode annotationNode) {
- return processAnnotation(LoggingFramework.JUL, annotation, source, annotationNode);
+ @Override public void handle(AnnotationValues<lombok.extern.java.Log> annotation, Annotation source, EclipseNode annotationNode) {
+ processAnnotation(LoggingFramework.JUL, annotation, source, annotationNode);
}
}
@@ -174,8 +174,8 @@ public class HandleLog {
*/
@ProviderFor(EclipseAnnotationHandler.class)
public static class HandleLog4jLog implements EclipseAnnotationHandler<lombok.extern.log4j.Log4j> {
- @Override public boolean handle(AnnotationValues<lombok.extern.log4j.Log4j> annotation, Annotation source, EclipseNode annotationNode) {
- return processAnnotation(LoggingFramework.LOG4J, annotation, source, annotationNode);
+ @Override public void handle(AnnotationValues<lombok.extern.log4j.Log4j> annotation, Annotation source, EclipseNode annotationNode) {
+ processAnnotation(LoggingFramework.LOG4J, annotation, source, annotationNode);
}
}
@@ -184,8 +184,8 @@ public class HandleLog {
*/
@ProviderFor(EclipseAnnotationHandler.class)
public static class HandleSlf4jLog implements EclipseAnnotationHandler<lombok.extern.slf4j.Slf4j> {
- @Override public boolean handle(AnnotationValues<lombok.extern.slf4j.Slf4j> annotation, Annotation source, EclipseNode annotationNode) {
- return processAnnotation(LoggingFramework.SLF4J, annotation, source, annotationNode);
+ @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 580a54a2..be86a566 100644
--- a/src/core/lombok/eclipse/handlers/HandlePrintAST.java
+++ b/src/core/lombok/eclipse/handlers/HandlePrintAST.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2009 Reinier Zwitserloot and Roel Spilker.
+ * Copyright © 2009-2011 Reinier Zwitserloot and Roel Spilker.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -40,8 +40,8 @@ import lombok.eclipse.EclipseNode;
*/
@ProviderFor(EclipseAnnotationHandler.class)
public class HandlePrintAST implements EclipseAnnotationHandler<PrintAST> {
- public boolean handle(AnnotationValues<PrintAST> annotation, Annotation ast, EclipseNode annotationNode) {
- if (!annotationNode.isCompleteParse()) return false;
+ public void handle(AnnotationValues<PrintAST> annotation, Annotation ast, EclipseNode annotationNode) {
+ if (!annotationNode.isCompleteParse()) return;
PrintStream stream = System.out;
String fileName = annotation.getInstance().outfile();
@@ -52,6 +52,5 @@ public class HandlePrintAST implements EclipseAnnotationHandler<PrintAST> {
}
annotationNode.up().traverse(new EclipseASTVisitor.Printer(annotation.getInstance().printContent(), stream));
- return true;
}
}
diff --git a/src/core/lombok/eclipse/handlers/HandleSetter.java b/src/core/lombok/eclipse/handlers/HandleSetter.java
index 945495c6..ac3ff2a2 100644
--- a/src/core/lombok/eclipse/handlers/HandleSetter.java
+++ b/src/core/lombok/eclipse/handlers/HandleSetter.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker.
+ * Copyright © 2009-2011 Reinier Zwitserloot and Roel Spilker.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -120,40 +120,37 @@ public class HandleSetter implements EclipseAnnotationHandler<Setter> {
createSetterForField(level, fieldNode, fieldNode, pos, false, onMethod, onParam);
}
- public boolean handle(AnnotationValues<Setter> annotation, Annotation ast, EclipseNode annotationNode) {
+ public void handle(AnnotationValues<Setter> annotation, Annotation ast, EclipseNode annotationNode) {
EclipseNode node = annotationNode.up();
AccessLevel level = annotation.getInstance().value();
- if (level == AccessLevel.NONE) return true;
-
- if (node == null) return false;
+ if (level == AccessLevel.NONE || node == null) return;
Annotation[] onMethod = getAndRemoveAnnotationParameter(ast, "onMethod");
Annotation[] onParam = getAndRemoveAnnotationParameter(ast, "onParam");
- if (node.getKind() == Kind.FIELD) {
- return createSetterForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, annotationNode.get(), true, onMethod, onParam);
-
- }
- if (node.getKind() == Kind.TYPE) {
+ switch (node.getKind()) {
+ case FIELD:
+ createSetterForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, annotationNode.get(), true, onMethod, onParam);
+ break;
+ case TYPE:
if (onMethod != null && onMethod.length != 0) annotationNode.addError("'onMethod' is not supported for @Setter on a type.");
if (onParam != null && onParam.length != 0) annotationNode.addError("'onParam' is not supported for @Setter on a type.");
- return generateSetterForType(node, annotationNode, level, false);
+ generateSetterForType(node, annotationNode, level, false);
+ break;
}
- return false;
}
- private boolean createSetterForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists, Annotation[] onMethod , Annotation[] onParam) {
+ private void createSetterForFields(AccessLevel level, Collection<EclipseNode> fieldNodes, EclipseNode errorNode, ASTNode source, boolean whineIfExists, Annotation[] onMethod , Annotation[] onParam) {
for (EclipseNode fieldNode : fieldNodes) {
createSetterForField(level, fieldNode, errorNode, source, whineIfExists, onMethod, onParam);
}
- return true;
}
- private boolean createSetterForField(AccessLevel level,
+ private void createSetterForField(AccessLevel level,
EclipseNode fieldNode, EclipseNode errorNode, ASTNode source, boolean whineIfExists, Annotation[] onMethod , Annotation[] onParam) {
if (fieldNode.getKind() != Kind.FIELD) {
errorNode.addError("@Setter is only supported on a class or a field.");
- return true;
+ return;
}
FieldDeclaration field = (FieldDeclaration) fieldNode.get();
@@ -166,7 +163,7 @@ public class HandleSetter implements EclipseAnnotationHandler<Setter> {
for (String altName : TransformationsUtil.toAllSetterNames(new String(field.name), isBoolean)) {
switch (methodExists(altName, fieldNode, false)) {
case EXISTS_BY_LOMBOK:
- return true;
+ return;
case EXISTS_BY_USER:
if (whineIfExists) {
String altNameExpl = "";
@@ -174,7 +171,7 @@ public class HandleSetter implements EclipseAnnotationHandler<Setter> {
errorNode.addWarning(
String.format("Not generating %s(): A method with that name already exists%s", setterName, altNameExpl));
}
- return true;
+ return;
default:
case NOT_EXISTS:
//continue scanning the other alt names.
@@ -188,8 +185,6 @@ public class HandleSetter implements EclipseAnnotationHandler<Setter> {
}
injectMethod(fieldNode.up(), method);
-
- return true;
}
private MethodDeclaration generateSetter(TypeDeclaration parent, EclipseNode fieldNode, String name, int modifier, ASTNode source, Annotation[] onParam) {
diff --git a/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java b/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java
index 38f22b2a..4b36d688 100644
--- a/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java
+++ b/src/core/lombok/eclipse/handlers/HandleSneakyThrows.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2009 Reinier Zwitserloot and Roel Spilker.
+ * Copyright © 2009-2011 Reinier Zwitserloot and Roel Spilker.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -69,7 +69,7 @@ public class HandleSneakyThrows implements EclipseAnnotationHandler<SneakyThrows
}
}
- @Override public boolean handle(AnnotationValues<SneakyThrows> annotation, Annotation source, EclipseNode annotationNode) {
+ @Override public void handle(AnnotationValues<SneakyThrows> annotation, Annotation source, EclipseNode annotationNode) {
List<String> exceptionNames = annotation.getRawExpressions("value");
List<DeclaredException> exceptions = new ArrayList<DeclaredException>();
@@ -101,10 +101,10 @@ public class HandleSneakyThrows implements EclipseAnnotationHandler<SneakyThrows
// case FIELD:
// return handleField(annotationNode, (FieldDeclaration)owner.get(), exceptions);
case METHOD:
- return handleMethod(annotationNode, (AbstractMethodDeclaration)owner.get(), exceptions);
+ handleMethod(annotationNode, (AbstractMethodDeclaration)owner.get(), exceptions);
+ break;
default:
annotationNode.addError("@SneakyThrows is legal only on methods and constructors.");
- return true;
}
}
@@ -140,13 +140,13 @@ public class HandleSneakyThrows implements EclipseAnnotationHandler<SneakyThrows
// return true;
// }
- private boolean handleMethod(EclipseNode annotation, AbstractMethodDeclaration method, List<DeclaredException> exceptions) {
+ private void handleMethod(EclipseNode annotation, AbstractMethodDeclaration method, List<DeclaredException> exceptions) {
if (method.isAbstract()) {
annotation.addError("@SneakyThrows can only be used on concrete methods.");
- return true;
+ return;
}
- if (method.statements == null) return false;
+ if (method.statements == null) return;
Statement[] contents = method.statements;
@@ -156,8 +156,6 @@ public class HandleSneakyThrows implements EclipseAnnotationHandler<SneakyThrows
method.statements = contents;
annotation.up().rebuild();
-
- return true;
}
private Statement buildTryCatchBlock(Statement[] contents, DeclaredException exception, ASTNode source) {
diff --git a/src/core/lombok/eclipse/handlers/HandleSynchronized.java b/src/core/lombok/eclipse/handlers/HandleSynchronized.java
index b77099b5..ace1c6dc 100644
--- a/src/core/lombok/eclipse/handlers/HandleSynchronized.java
+++ b/src/core/lombok/eclipse/handlers/HandleSynchronized.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2009 Reinier Zwitserloot and Roel Spilker.
+ * Copyright © 2009-2011 Reinier Zwitserloot and Roel Spilker.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -57,20 +57,20 @@ public class HandleSynchronized implements EclipseAnnotationHandler<Synchronized
private static final char[] INSTANCE_LOCK_NAME = "$lock".toCharArray();
private static final char[] STATIC_LOCK_NAME = "$LOCK".toCharArray();
- @Override public boolean handle(AnnotationValues<Synchronized> annotation, Annotation source, EclipseNode annotationNode) {
+ @Override public void handle(AnnotationValues<Synchronized> annotation, Annotation source, EclipseNode annotationNode) {
int p1 = source.sourceStart -1;
int p2 = source.sourceStart -2;
long pos = (((long)p1) << 32) | p2;
EclipseNode methodNode = annotationNode.up();
if (methodNode == null || methodNode.getKind() != Kind.METHOD || !(methodNode.get() instanceof MethodDeclaration)) {
annotationNode.addError("@Synchronized is legal only on methods.");
- return true;
+ return;
}
MethodDeclaration method = (MethodDeclaration)methodNode.get();
if (method.isAbstract()) {
annotationNode.addError("@Synchronized is legal only on concrete methods.");
- return true;
+ return;
}
char[] lockName = annotation.getInstance().value().toCharArray();
@@ -83,7 +83,7 @@ public class HandleSynchronized implements EclipseAnnotationHandler<Synchronized
if (fieldExists(new String(lockName), methodNode) == MemberExistsResult.NOT_EXISTS) {
if (!autoMake) {
annotationNode.addError("The field " + new String(lockName) + " does not exist.");
- return true;
+ return;
}
FieldDeclaration fieldDecl = new FieldDeclaration(lockName, 0, -1);
Eclipse.setGeneratedBy(fieldDecl, source);
@@ -104,7 +104,7 @@ public class HandleSynchronized implements EclipseAnnotationHandler<Synchronized
injectFieldSuppressWarnings(annotationNode.up().up(), fieldDecl);
}
- if (method.statements == null) return false;
+ if (method.statements == null) return;
Block block = new Block(0);
Eclipse.setGeneratedBy(block, source);
@@ -126,7 +126,5 @@ public class HandleSynchronized implements EclipseAnnotationHandler<Synchronized
Eclipse.setGeneratedBy(method.statements[0], source);
methodNode.rebuild();
-
- return true;
}
}
diff --git a/src/core/lombok/eclipse/handlers/HandleToString.java b/src/core/lombok/eclipse/handlers/HandleToString.java
index 8d722247..553f097b 100644
--- a/src/core/lombok/eclipse/handlers/HandleToString.java
+++ b/src/core/lombok/eclipse/handlers/HandleToString.java
@@ -1,5 +1,5 @@
/*
- * Copyright © 2009-2010 Reinier Zwitserloot and Roel Spilker.
+ * Copyright © 2009-2011 Reinier Zwitserloot and Roel Spilker.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -98,7 +98,7 @@ public class HandleToString implements EclipseAnnotationHandler<ToString> {
generateToString(typeNode, errorNode, null, null, includeFieldNames, null, false, FieldAccess.GETTER);
}
- public boolean handle(AnnotationValues<ToString> annotation, Annotation ast, EclipseNode annotationNode) {
+ public void handle(AnnotationValues<ToString> annotation, Annotation ast, EclipseNode annotationNode) {
ToString ann = annotation.getInstance();
List<String> excludes = Arrays.asList(ann.exclude());
List<String> includes = Arrays.asList(ann.of());
@@ -118,10 +118,10 @@ public class HandleToString implements EclipseAnnotationHandler<ToString> {
FieldAccess fieldAccess = ann.doNotUseGetters() ? FieldAccess.PREFER_FIELD : FieldAccess.GETTER;
- return generateToString(typeNode, annotationNode, excludes, includes, ann.includeFieldNames(), callSuper, true, fieldAccess);
+ generateToString(typeNode, annotationNode, excludes, includes, ann.includeFieldNames(), callSuper, true, fieldAccess);
}
- public boolean generateToString(EclipseNode typeNode, EclipseNode errorNode, List<String> excludes, List<String> includes,
+ public void generateToString(EclipseNode typeNode, EclipseNode errorNode, List<String> excludes, List<String> includes,
boolean includeFieldNames, Boolean callSuper, boolean whineIfExists, FieldAccess fieldAccess) {
TypeDeclaration typeDecl = null;
@@ -132,7 +132,6 @@ public class HandleToString implements EclipseAnnotationHandler<ToString> {
if (typeDecl == null || notAClass) {
errorNode.addError("@ToString is only supported on a class or enum.");
- return false;
}
if (callSuper == null) {
@@ -165,15 +164,14 @@ public class HandleToString implements EclipseAnnotationHandler<ToString> {
case NOT_EXISTS:
MethodDeclaration toString = createToString(typeNode, nodesForToString, includeFieldNames, callSuper, errorNode.get(), fieldAccess);
injectMethod(typeNode, toString);
- return true;
+ break;
case EXISTS_BY_LOMBOK:
- return true;
+ break;
default:
case EXISTS_BY_USER:
if (whineIfExists) {
errorNode.addWarning("Not generating toString(): A method with that name already exists");
}
- return true;
}
}