in nullaway/src/main/java/com/uber/nullaway/handlers/SynchronousCallbackHandler.java [51:93]
public Predicate<AccessPath> getAccessPathPredicateForNestedMethod(
TreePath path, VisitorState state) {
Tree leafNode = path.getLeaf();
Preconditions.checkArgument(
leafNode instanceof ClassTree || leafNode instanceof LambdaExpressionTree,
"Unexpected leaf type: %s",
leafNode.getClass());
Tree parentNode = path.getParentPath().getLeaf();
if (parentNode instanceof MethodInvocationTree) {
MethodInvocationTree methodInvocationTree = (MethodInvocationTree) parentNode;
Symbol.MethodSymbol symbol = ASTHelpers.getSymbol(methodInvocationTree);
if (symbol == null) {
return FALSE_AP_PREDICATE;
}
Type ownerType = symbol.owner.type;
if (ASTHelpers.isSameType(ownerType, STREAM_TYPE_SUPPLIER.get(state), state)) {
// preserve access paths for all callbacks passed to stream methods
return TRUE_AP_PREDICATE;
}
String invokedMethodName = symbol.getSimpleName().toString();
if (METHOD_NAME_TO_SIG_AND_PARAM_INDEX.containsKey(invokedMethodName)) {
ImmutableMap<MethodRef, Integer> entriesForMethodName =
METHOD_NAME_TO_SIG_AND_PARAM_INDEX.get(invokedMethodName);
for (MethodRef methodRef : entriesForMethodName.keySet()) {
if (symbol.toString().equals(methodRef.fullMethodSig)
&& ASTHelpers.isSubtype(
ownerType, state.getTypeFromString(methodRef.enclosingClass), state)) {
int parameterIndex = -1;
for (int i = 0; i < methodInvocationTree.getArguments().size(); i++) {
if (methodInvocationTree.getArguments().get(i) == leafNode) {
parameterIndex = i;
break;
}
}
if (parameterIndex == entriesForMethodName.get(methodRef)) {
return TRUE_AP_PREDICATE;
}
}
}
}
}
return FALSE_AP_PREDICATE;
}