From f8b3056dc4f61251aba7adf627c942c85e8618ca Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Sun, 1 Jun 2014 11:02:18 +0200 Subject: Fixed up and extended Tolerate with support for constructors, and added docs. --- .../lombok/javac/handlers/JavacHandlerUtil.java | 23 +++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/core/lombok/javac') 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 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("")) { - if ((((JCMethodDecl)def).mods.flags & Flags.GENERATEDCONSTR) != 0) continue; + JCMethodDecl md = (JCMethodDecl) def; + if (md.name.contentEquals("")) { + if ((md.mods.flags & Flags.GENERATEDCONSTR) != 0) continue; + List 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; } } -- cgit