Skip to content

Commit

Permalink
add support for the 'has' prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Machine-Maker committed Jul 26, 2023
1 parent bebfd67 commit 8617b28
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private LvtAssignmentSuggester() {}
return suggested;
}

suggested = suggestNameFromIs(methodName, insn);
suggested = suggestNameFromIsOrHas(methodName, insn);
if (suggested != null) {
return suggested;
}
Expand Down Expand Up @@ -110,16 +110,21 @@ public static String suggestNameFromRecord(final String methodName) {
}
}

private static @Nullable String suggestNameFromIs(final String methodName, final MethodInsnNode insn) {
private static @Nullable String suggestNameFromIsOrHas(final String methodName, final MethodInsnNode insn) {
if (insn.desc == null || !insn.desc.endsWith("Z")) { // only handle methods that return booleans
return null;
}

if (!methodName.startsWith("is") || methodName.equals("is")) {
final String prefix;
if (!"is".equals(methodName) && methodName.startsWith("is")) {
prefix = "is";
} else if (!"has".equals(methodName) && methodName.startsWith("has")) {
prefix = "has";
} else {
return null;
}

if (Character.isUpperCase(methodName.charAt(2))) {
if (Character.isUpperCase(methodName.charAt(prefix.length()))) {
return methodName;
} else {
return null;
Expand Down

0 comments on commit 8617b28

Please sign in to comment.