FIR IDE: remove duplicating withFirResolvedToBodyResolve
This commit is contained in:
+1
-1
@@ -61,7 +61,7 @@ internal class KtFirCompletionCandidateChecker(
|
||||
|
||||
private inline fun <reified T : KtFirSymbol<F>, F : FirDeclaration, R> KtCallableSymbol.withResolvedFirOfType(
|
||||
noinline action: (F) -> R,
|
||||
): R? = this.safeAs<T>()?.firRef?.withFirResolvedToBodyResolve(action)
|
||||
): R? = this.safeAs<T>()?.firRef?.withFir(phase = FirResolvePhase.BODY_RESOLVE, action)
|
||||
|
||||
private fun checkExtension(
|
||||
candidateSymbol: FirCallableDeclaration<*>,
|
||||
|
||||
+10
-11
@@ -25,17 +25,16 @@ internal class FirRefWithValidityCheck<D : FirDeclaration>(fir: D, resolveState:
|
||||
val resolveState = resolveStateWeakRef.get()
|
||||
?: throw EntityWasGarbageCollectedException("FirModuleResolveState")
|
||||
fir.resolvedFirToPhase(phase, resolveState)
|
||||
return resolveState.withFirDeclaration(fir) { action(it) }
|
||||
}
|
||||
|
||||
inline fun <R> withFirResolvedToBodyResolve(action: (fir: D) -> R): R {
|
||||
token.assertIsValid()
|
||||
val fir = firWeakRef.get()
|
||||
?: throw EntityWasGarbageCollectedException("FirElement")
|
||||
val resolveState = resolveStateWeakRef.get()
|
||||
?: throw EntityWasGarbageCollectedException("FirModuleResolveState")
|
||||
fir.resolvedFirToPhase(FirResolvePhase.BODY_RESOLVE, resolveState)
|
||||
return action(resolveState.withFirDeclaration(fir) { it })
|
||||
return when (phase) {
|
||||
FirResolvePhase.BODY_RESOLVE -> {
|
||||
/*
|
||||
The BODY_RESOLVE phase is the maximum possible phase we can resolve our declaration to
|
||||
So there is not need to run whole `action` under read lock
|
||||
*/
|
||||
action(resolveState.withFirDeclaration(fir) { it })
|
||||
}
|
||||
else -> resolveState.withFirDeclaration(fir) { action(it) }
|
||||
}
|
||||
}
|
||||
|
||||
val resolveState
|
||||
|
||||
Reference in New Issue
Block a user