KT-61689 [LL API] Improve readability of withInterceptor function

This commit is contained in:
Roman Golyshev
2023-09-04 16:06:13 +02:00
parent 90ed90c9a7
commit 83049dc25c
@@ -156,7 +156,7 @@ private class ContextCollectorVisitor(
private val holder: SessionHolder,
private val shouldCollectBodyContext: Boolean,
private val filter: (PsiElement) -> FilterResponse,
private val interceptor: () -> FirElement?
private val designationPathInterceptor: () -> FirElement?
) : FirDefaultVisitorVoid() {
private data class ContextKey(val element: PsiElement, val kind: ContextKind)
@@ -595,8 +595,13 @@ private class ContextCollectorVisitor(
}
}
private inline fun withInterceptor(block: () -> Unit) {
val target = interceptor()
/**
* Ensures that the visitor is going through the path specified by the initial [FirDesignation].
*
* If the designation is over, then allows the [block] code to take control.
*/
private fun withInterceptor(block: () -> Unit) {
val target = designationPathInterceptor()
if (target != null) {
target.accept(this)
} else {