diff options
Diffstat (limited to 'src/lombok/javac/handlers/PKG.java')
-rw-r--r-- | src/lombok/javac/handlers/PKG.java | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lombok/javac/handlers/PKG.java b/src/lombok/javac/handlers/PKG.java index 4ea44274..161248c8 100644 --- a/src/lombok/javac/handlers/PKG.java +++ b/src/lombok/javac/handlers/PKG.java @@ -2,10 +2,14 @@ package lombok.javac.handlers; import java.lang.reflect.Modifier; +import com.sun.tools.javac.tree.JCTree; +import com.sun.tools.javac.tree.JCTree.JCClassDecl; +import com.sun.tools.javac.tree.JCTree.JCMethodDecl; import com.sun.tools.javac.tree.JCTree.JCVariableDecl; import lombok.AccessLevel; import lombok.core.TransformationsUtil; +import lombok.javac.JavacAST; class PKG { static String toGetterName(JCVariableDecl field) { @@ -22,6 +26,24 @@ class PKG { return TransformationsUtil.toSetterName(fieldName); } + static boolean methodExists(String methodName, JavacAST.Node node) { + while ( node != null && !(node.get() instanceof JCClassDecl) ) { + node = node.up(); + } + + if ( node.get() instanceof JCClassDecl ) { + for ( JCTree def : ((JCClassDecl)node.get()).defs ) { + if ( def instanceof JCMethodDecl ) { + if ( ((JCMethodDecl)def).name.contentEquals(methodName) ) { + return true; + } + } + } + } + + return false; + } + static int toJavacModifier(AccessLevel accessLevel) { switch ( accessLevel ) { case MODULE: |