Skip to content

Commit

Permalink
Don't compute element unless necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst authored Dec 4, 2023
1 parent d146eea commit 918fa9e
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -939,12 +939,19 @@ public static boolean matchesElement(
return true;
}

/** Returns true if the given element is, or overrides, method. */
/**
* Returns true if the given element is, or overrides, {@code method}.
*
* @param questioned an element that might override {@code method}
* @param method a method that might be overridden
* @param env the processing environment
* @return true if {@code questioned} is, or overrides, {@code method}
*/
public static boolean isMethod(
ExecutableElement questioned, ExecutableElement method, ProcessingEnvironment env) {
TypeElement enclosing = (TypeElement) questioned.getEnclosingElement();
return questioned.equals(method)
|| env.getElementUtils().overrides(questioned, method, enclosing);
|| env.getElementUtils()
.overrides(questioned, method, (TypeElement) questioned.getEnclosingElement());
}

/**
Expand Down

0 comments on commit 918fa9e

Please sign in to comment.