in static-analysis/autodispose-lint/src/main/kotlin/autodispose2/lint/AutoDisposeDetector.kt [190:218]
override fun visitCallExpression(node: UCallExpression) {
node.resolve()?.let { method ->
// Check if it's one of our withScope() higher order functions. If so, we handle that
// separately and visit the passed in lambda body and run the subscribe method call checks
// inside it with the "isInScope" check just hardcoded to true.
if (
method.name == "withScope" && method.containingClass?.qualifiedName == KOTLIN_EXTENSIONS
) {
val args = node.valueArguments
val contextArg = args.filterIsInstance<ULambdaExpression>().firstOrNull() ?: return@let
// Check the lambda type too because it's a cheaper instance check
// This is the AutoDisposeContext.() call
val body = contextArg.body
val visitor =
SubscribeCallVisitor(
context,
callExpressionChecker = { context, node, calledMethod ->
callExpressionChecker(context, node, calledMethod) { _, _ -> true }
},
callableReferenceChecker = { context, node, calledMethod ->
callableReferenceChecker(context, node, calledMethod) { _, _ -> true }
}
)
body.accept(visitor)
return@let
}
callExpressionChecker(context, node, method, ::containingClassScopeChecker)
}
}