aboutsummaryrefslogtreecommitdiff
path: root/src/eclipseAgent
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2012-01-19 00:33:18 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2012-01-19 00:44:48 +0100
commitacea9efcff67c7a0bdb85175b84e75a9dad172b8 (patch)
tree0018557920c980277f2cd3270cb7dd1a95bcd449 /src/eclipseAgent
parent99743e16e6741cbb858377c31acfb91ccfb027c6 (diff)
downloadlombok-acea9efcff67c7a0bdb85175b84e75a9dad172b8.tar.gz
lombok-acea9efcff67c7a0bdb85175b84e75a9dad172b8.tar.bz2
lombok-acea9efcff67c7a0bdb85175b84e75a9dad172b8.zip
@Delegate is no longer legal on static entities (previously no immediate errors but I don't think it would work right anyway), and prettied up the error message when you use @Delegate wrong (on static items or methods with args).
Also put back something I accidentally deleted with the previous merge.
Diffstat (limited to 'src/eclipseAgent')
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java b/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java
index d6310de1..e510d37b 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchDelegate.java
@@ -198,6 +198,12 @@ public class PatchDelegate {
if (!isDelegate(ann, decl)) continue;
if (alreadyApplied.put(ann, MARKER) == MARKER) continue;
+ if ((field.modifiers & ClassFileConstants.AccStatic) != 0) {
+ EclipseAST eclipseAst = TransformEclipseAST.getAST(cud, true);
+ eclipseAst.get(ann).addError(LEGALITY_OF_DELEGATE);
+ break;
+ }
+
List<ClassLiteralAccess> rawTypes = rawTypes(ann, "types");
List<ClassLiteralAccess> excludedRawTypes = rawTypes(ann, "excludes");
@@ -233,6 +239,8 @@ public class PatchDelegate {
}
}
+ private static final String LEGALITY_OF_DELEGATE = "@Delegate is legal only on instance fields or no-argument instance methods.";
+
private static void fillMethodBindingsForMethods(CompilationUnitDeclaration cud, ClassScope scope, List<BindingTuple> methodsToDelegate) {
TypeDeclaration decl = scope.referenceContext;
if (decl == null) return;
@@ -244,13 +252,18 @@ public class PatchDelegate {
if (alreadyApplied.put(ann, MARKER) == MARKER) continue;
if (!(methodDecl instanceof MethodDeclaration)) {
EclipseAST eclipseAst = TransformEclipseAST.getAST(cud, true);
- eclipseAst.get(ann).addError("@Delegate is legal only on no-argument methods.");
- continue;
+ eclipseAst.get(ann).addError(LEGALITY_OF_DELEGATE);
+ break;
}
if (methodDecl.arguments != null) {
EclipseAST eclipseAst = TransformEclipseAST.getAST(cud, true);
- eclipseAst.get(ann).addError("@Delegate is legal only on no-argument methods.");
- continue;
+ eclipseAst.get(ann).addError(LEGALITY_OF_DELEGATE);
+ break;
+ }
+ if ((methodDecl.modifiers & ClassFileConstants.AccStatic) != 0) {
+ EclipseAST eclipseAst = TransformEclipseAST.getAST(cud, true);
+ eclipseAst.get(ann).addError(LEGALITY_OF_DELEGATE);
+ break;
}
MethodDeclaration method = (MethodDeclaration) methodDecl;