diff options
author | Reinier Zwitserloot <reinier@tipit.to> | 2009-12-04 20:54:02 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@tipit.to> | 2009-12-04 20:54:02 +0100 |
commit | 229cbbb0d9e7b18b4a4b214f8d5198c527a4f714 (patch) | |
tree | d72ad1fa441dc8fbe0a393843cb7d2b322094fda /src | |
parent | a23d77f5804f4ac91c48cf78e21905960d45e179 (diff) | |
download | lombok-229cbbb0d9e7b18b4a4b214f8d5198c527a4f714.tar.gz lombok-229cbbb0d9e7b18b4a4b214f8d5198c527a4f714.tar.bz2 lombok-229cbbb0d9e7b18b4a4b214f8d5198c527a4f714.zip |
Prep work for fixing issue #75.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java | 13 | ||||
-rw-r--r-- | src/core/lombok/javac/handlers/JavacHandlerUtil.java | 11 |
2 files changed, 20 insertions, 4 deletions
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java index 8b4a84c1..e6d700f8 100644 --- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java +++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java @@ -138,13 +138,21 @@ public class EclipseHandlerUtil { } /** + * Wrapper for {@link #methodExists(String, EclipseNode, boolean)} with {@code caseSensitive} = {@code true}. + */ + public static MemberExistsResult methodExists(String methodName, EclipseNode node) { + return methodExists(methodName, node, true); + } + + /** * Checks if there is a method with the provided name. In case of multiple methods (overloading), only * the first method decides if EXISTS_BY_USER or EXISTS_BY_LOMBOK is returned. * * @param methodName the method name to check for. * @param node Any node that represents the Type (TypeDeclaration) to look in, or any child node thereof. + * @param caseSensitive If the search should be case sensitive. */ - public static MemberExistsResult methodExists(String methodName, EclipseNode node) { + public static MemberExistsResult methodExists(String methodName, EclipseNode node, boolean caseSensitive) { while (node != null && !(node.get() instanceof TypeDeclaration)) { node = node.up(); } @@ -154,7 +162,8 @@ public class EclipseHandlerUtil { if (typeDecl.methods != null) for (AbstractMethodDeclaration def : typeDecl.methods) { char[] mName = def.selector; if (mName == null) continue; - if (methodName.equals(new String(mName))) { + 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; diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index ae904426..c968a9f7 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -184,14 +184,19 @@ public class JavacHandlerUtil { return MemberExistsResult.NOT_EXISTS; } + public static MemberExistsResult methodExists(String methodName, JavacNode node) { + return methodExists(methodName, node, true); + } + /** * Checks if there is a method with the provided name. In case of multiple methods (overloading), only * the first method decides if EXISTS_BY_USER or EXISTS_BY_LOMBOK is returned. * * @param methodName the method name to check for. * @param node Any node that represents the Type (JCClassDecl) to look in, or any child node thereof. + * @param caseSensitive If the search should be case sensitive. */ - public static MemberExistsResult methodExists(String methodName, JavacNode node) { + public static MemberExistsResult methodExists(String methodName, JavacNode node, boolean caseSensitive) { while (node != null && !(node.get() instanceof JCClassDecl)) { node = node.up(); } @@ -199,7 +204,9 @@ public class JavacHandlerUtil { if (node != null && node.get() instanceof JCClassDecl) { for (JCTree def : ((JCClassDecl)node.get()).defs) { if (def instanceof JCMethodDecl) { - if (((JCMethodDecl)def).name.contentEquals(methodName)) { + String name = ((JCMethodDecl)def).name.toString(); + boolean matches = caseSensitive ? name.equals(methodName) : name.equalsIgnoreCase(methodName); + if (matches) { JavacNode existing = node.getNodeFor(def); if (existing == null || !existing.isHandled()) return MemberExistsResult.EXISTS_BY_USER; return MemberExistsResult.EXISTS_BY_LOMBOK; |