context: i am trying to replicate the behavior of ...
# detekt
v
context: i am trying to replicate the behavior of https://github.com/JetBrains/intellij-community/blob/master/jvm/jvm-analysis-impl/[…]ion/blockingCallsDetection/ThrowsTypeBlockingMethodChecker.java problem: KtCallExpression.getResolvedCall(bindingContext) gives JavaMethodDescriptor; the referenced PsiMethod for the JavaMethodDescriptor would be in rt.jar; 1. how to resolve to the PsiMethod from JavaMethodDescriptor? 2. or get the PsiMethod/PsiReferenceList some other way at analysis time? one way I can think of doing 2, is specifically just loading
((descriptor.source as JavaSourceElement).javaElement as BinaryJavaMethod).containingClass
at runtime
g
I’m unsure how to help you 🤔 What is
ThrowsTypeBlockingMethodChecker
even doing? Can you provide some example of compliant/non-compliant code?
v
@gammax, this is used to check if a method is a blocking method
this is used further with another inspection, which sees if this method call is being made in a non-blocking context
g
Can you provide some example of compliant/non-compliant code? 🙂
v
Copy code
V java.util.concurrent.Future#get() throws InterruptedException, ExecutionException; // defined in rt.jar

suspend fun foo() {
    val aFuture = asyncHttpClient.executeRequest(r).get() // this `.get` is identified as a blocking call in non-blocking context
}