FIR IDE: get rid of DiagnosticCollectorDeclarationAction
This commit is contained in:
-6
@@ -67,12 +67,6 @@ abstract class AbstractDiagnosticCollector(
|
||||
}
|
||||
}
|
||||
|
||||
enum class DiagnosticCollectorDeclarationAction(val checkInCurrentDeclaration: Boolean, val lookupForNestedDeclaration: Boolean) {
|
||||
CHECK_IN_CURRENT_DECLARATION_AND_LOOKUP_FOR_NESTED(checkInCurrentDeclaration = true, lookupForNestedDeclaration = true),
|
||||
CHECK_IN_CURRENT_DECLARATION_AND_DO_NOT_LOOKUP_FOR_NESTED(checkInCurrentDeclaration = true, lookupForNestedDeclaration = false),
|
||||
DO_NOT_CHECK_IN_CURRENT_DECLARATION_AND_LOOKUP_FOR_NESTED(checkInCurrentDeclaration = false, lookupForNestedDeclaration = true),
|
||||
SKIP(checkInCurrentDeclaration = false, lookupForNestedDeclaration = false),
|
||||
}
|
||||
|
||||
fun AbstractDiagnosticCollector.registerAllComponents() {
|
||||
initializeComponents(
|
||||
|
||||
+3
-25
@@ -28,7 +28,6 @@ abstract class AbstractDiagnosticCollectorVisitor(
|
||||
@set:PrivateForInline var context: PersistentCheckerContext,
|
||||
protected val components: List<AbstractDiagnosticCollectorComponent>,
|
||||
) : FirDefaultVisitor<Unit, Nothing?>() {
|
||||
protected var currentAction = DiagnosticCollectorDeclarationAction.CHECK_IN_CURRENT_DECLARATION_AND_LOOKUP_FOR_NESTED
|
||||
|
||||
protected open fun beforeRunningAllComponentsOnElement(element: FirElement) {}
|
||||
protected open fun beforeRunningSingleComponentOnElement(element: FirElement) {}
|
||||
@@ -182,16 +181,10 @@ abstract class AbstractDiagnosticCollectorVisitor(
|
||||
declaration: FirDeclaration,
|
||||
block: () -> Unit = { declaration.acceptChildren(this, null) }
|
||||
) {
|
||||
if (!currentAction.lookupForNestedDeclaration) return
|
||||
|
||||
val action = getDeclarationActionOnDeclarationEnter(declaration)
|
||||
withDiagnosticsAction(action) {
|
||||
runComponents(declaration)
|
||||
withDeclaration(declaration) {
|
||||
block()
|
||||
}
|
||||
runComponents(declaration)
|
||||
withDeclaration(declaration) {
|
||||
block()
|
||||
}
|
||||
onDeclarationExit(declaration)
|
||||
}
|
||||
|
||||
private fun visitWithDeclarationAndReceiver(declaration: FirDeclaration, labelName: Name?, receiverTypeRef: FirTypeRef?) {
|
||||
@@ -220,21 +213,6 @@ abstract class AbstractDiagnosticCollectorVisitor(
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun getDeclarationActionOnDeclarationEnter(declaration: FirDeclaration): DiagnosticCollectorDeclarationAction =
|
||||
DiagnosticCollectorDeclarationAction.CHECK_IN_CURRENT_DECLARATION_AND_LOOKUP_FOR_NESTED
|
||||
|
||||
protected open fun onDeclarationExit(declaration: FirDeclaration) {}
|
||||
|
||||
private inline fun <R> withDiagnosticsAction(action: DiagnosticCollectorDeclarationAction, block: () -> R): R {
|
||||
val oldAction = currentAction
|
||||
currentAction = action
|
||||
return try {
|
||||
block()
|
||||
} finally {
|
||||
currentAction = oldAction
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(PrivateForInline::class)
|
||||
inline fun <R> withQualifiedAccess(qualifiedAccess: FirQualifiedAccess, block: () -> R): R {
|
||||
val existingContext = context
|
||||
|
||||
+4
-6
@@ -20,12 +20,10 @@ open class CheckerRunningDiagnosticCollectorVisitor(
|
||||
}
|
||||
|
||||
override fun runComponents(element: FirElement) {
|
||||
if (currentAction.checkInCurrentDeclaration) {
|
||||
beforeRunningAllComponentsOnElement(element)
|
||||
components.forEach {
|
||||
beforeRunningSingleComponentOnElement(element)
|
||||
element.accept(it, context)
|
||||
}
|
||||
beforeRunningAllComponentsOnElement(element)
|
||||
components.forEach {
|
||||
beforeRunningSingleComponentOnElement(element)
|
||||
element.accept(it, context)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,11 @@ interface SessionHolder {
|
||||
val scopeSession: ScopeSession
|
||||
}
|
||||
|
||||
data class SessionHolderImpl(override val session: FirSession, override val scopeSession: ScopeSession): SessionHolder
|
||||
data class SessionHolderImpl(override val session: FirSession, override val scopeSession: ScopeSession) : SessionHolder {
|
||||
companion object {
|
||||
fun createWithEmptyScopeSession(session: FirSession): SessionHolderImpl = SessionHolderImpl(session, ScopeSession())
|
||||
}
|
||||
}
|
||||
|
||||
abstract class BodyResolveComponents : SessionHolder {
|
||||
abstract val returnTypeCalculator: ReturnTypeCalculator
|
||||
|
||||
Reference in New Issue
Block a user