diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java | 17 | ||||
-rw-r--r-- | src/core/lombok/experimental/Tolerate.java | 7 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/JavacHandlerUtil.java | 23 |
3 files changed, 25 insertions, 22 deletions
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index 11f31c9d..b37dbd81 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -1203,7 +1203,7 @@ public class EclipseHandlerUtil { if (node != null && node.get() instanceof TypeDeclaration) { TypeDeclaration typeDecl = (TypeDeclaration)node.get(); - if (typeDecl.methods != null) for (AbstractMethodDeclaration def : typeDecl.methods) { + if (typeDecl.methods != null) top: for (AbstractMethodDeclaration def : typeDecl.methods) { if (def instanceof MethodDeclaration) { char[] mName = def.selector; if (mName == null) continue; @@ -1225,13 +1225,9 @@ public class EclipseHandlerUtil { if (params < minArgs || params > maxArgs) continue; } - boolean tolerate = false; - if (def.annotations != null) { - for (Annotation anno : def.annotations) { - tolerate |= typeMatches(Tolerate.class, node, anno.type); - } + if (def.annotations != null) for (Annotation anno : def.annotations) { + if (typeMatches(Tolerate.class, node, anno.type)) continue top; } - if (tolerate) continue; return getGeneratedBy(def) == null ? MemberExistsResult.EXISTS_BY_USER : MemberExistsResult.EXISTS_BY_LOMBOK; } @@ -1255,9 +1251,14 @@ public class EclipseHandlerUtil { if (node != null && node.get() instanceof TypeDeclaration) { TypeDeclaration typeDecl = (TypeDeclaration)node.get(); - if (typeDecl.methods != null) for (AbstractMethodDeclaration def : typeDecl.methods) { + if (typeDecl.methods != null) top: for (AbstractMethodDeclaration def : typeDecl.methods) { if (def instanceof ConstructorDeclaration) { if ((def.bits & ASTNode.IsDefaultConstructor) != 0) continue; + + if (def.annotations != null) for (Annotation anno : def.annotations) { + if (typeMatches(Tolerate.class, node, anno.type)) continue top; + } + return getGeneratedBy(def) == null ? MemberExistsResult.EXISTS_BY_USER : MemberExistsResult.EXISTS_BY_LOMBOK; } } diff --git a/src/core/lombok/experimental/Tolerate.java b/src/core/lombok/experimental/Tolerate.java index 626a5890..4bc04b8b 100644 --- a/src/core/lombok/experimental/Tolerate.java +++ b/src/core/lombok/experimental/Tolerate.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2013 The Project Lombok Authors. + * 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 @@ -27,9 +27,10 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** - * Put on any method to make lombok pretend it doesn't exist, i.e., to generate a method which would otherwise be skipped due to possible conflicts. + * Put on any method or constructor to make lombok pretend it doesn't exist, + * i.e., to generate a method which would otherwise be skipped due to possible conflicts. */ -@Target({ElementType.METHOD}) +@Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) @Retention(RetentionPolicy.SOURCE) public @interface Tolerate { } diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index 474c5faa..25b95590 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -570,7 +570,7 @@ public class JavacHandlerUtil { node = upToTypeNode(node); if (node != null && node.get() instanceof JCClassDecl) { - for (JCTree def : ((JCClassDecl)node.get()).defs) { + top: for (JCTree def : ((JCClassDecl)node.get()).defs) { if (def instanceof JCMethodDecl) { JCMethodDecl md = (JCMethodDecl) def; String name = md.name.toString(); @@ -592,15 +592,11 @@ public class JavacHandlerUtil { if (params < minArgs || params > maxArgs) continue; } - - boolean tolerate = false; + List<JCAnnotation> annotations = md.getModifiers().getAnnotations(); - if (annotations != null) { - for (JCAnnotation anno : annotations) { - tolerate |= typeMatches(Tolerate.class, node, anno.getAnnotationType()); - } + if (annotations != null) for (JCAnnotation anno : annotations) { + if (typeMatches(Tolerate.class, node, anno.getAnnotationType())) continue top; } - if (tolerate) continue; return getGeneratedBy(def) == null ? MemberExistsResult.EXISTS_BY_USER : MemberExistsResult.EXISTS_BY_LOMBOK; } @@ -621,10 +617,15 @@ public class JavacHandlerUtil { node = upToTypeNode(node); if (node != null && node.get() instanceof JCClassDecl) { - for (JCTree def : ((JCClassDecl)node.get()).defs) { + top: for (JCTree def : ((JCClassDecl)node.get()).defs) { if (def instanceof JCMethodDecl) { - if (((JCMethodDecl)def).name.contentEquals("<init>")) { - if ((((JCMethodDecl)def).mods.flags & Flags.GENERATEDCONSTR) != 0) continue; + JCMethodDecl md = (JCMethodDecl) def; + if (md.name.contentEquals("<init>")) { + if ((md.mods.flags & Flags.GENERATEDCONSTR) != 0) continue; + List<JCAnnotation> annotations = md.getModifiers().getAnnotations(); + if (annotations != null) for (JCAnnotation anno : annotations) { + if (typeMatches(Tolerate.class, node, anno.getAnnotationType())) continue top; + } return getGeneratedBy(def) == null ? MemberExistsResult.EXISTS_BY_USER : MemberExistsResult.EXISTS_BY_LOMBOK; } } |