Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2407,6 +2407,25 @@ private void processFakeOverride(
return findFieldElement(typeElt, enumConstName, astNode);
}

/** Cache all the methods that are in a TypeElement. */
private final Map<TypeElement, List<ExecutableElement>> methodsInTypeElementCache =
CollectionsPlume.createLruCache(100);

/**
* Determine all the methods that are in a TypeElement, caching the result.
*
* @param typeElt the type element
* @return the methods in that type element
*/
private List<ExecutableElement> methodsInTypeElement(TypeElement typeElt) {
List<ExecutableElement> res = methodsInTypeElementCache.get(typeElt);
if (res == null) {
res = ElementFilter.methodsIn(typeElt.getEnclosedElements());
methodsInTypeElementCache.put(typeElt, res);
}
return res;
}

/**
* Looks for a method element in {@code typeElt} that has the same name and formal parameter
* types as {@code methodDecl}. Returns null, and possibly issues a warning, if no such method
Expand All @@ -2428,7 +2447,7 @@ private void processFakeOverride(
int wantedMethodParams =
(methodDecl.getParameters() == null) ? 0 : methodDecl.getParameters().size();
String wantedMethodString = AnnotationFileUtil.toString(methodDecl);
for (ExecutableElement method : ElementFilter.methodsIn(typeElt.getEnclosedElements())) {
for (ExecutableElement method : methodsInTypeElement(typeElt)) {
if (wantedMethodParams == method.getParameters().size()
&& wantedMethodName.contentEquals(method.getSimpleName().toString())
&& ElementUtils.getSimpleSignature(method).equals(wantedMethodString)) {
Expand All @@ -2455,8 +2474,7 @@ private void processFakeOverride(
"method " + wantedMethodString + " not found in type " + typeElt);
if (debugAnnotationFileParser) {
stubDebug(" methods of %s:", typeElt);
for (ExecutableElement method :
ElementFilter.methodsIn(typeElt.getEnclosedElements())) {
for (ExecutableElement method : methodsInTypeElement(typeElt)) {
stubDebug(" %s", method);
}
}
Expand Down
Loading