Migrate some FIR/Analysis API KotlinExceptionWithAttachment usages to buildErrorWithAttachment API
This commit is contained in:
committed by
Space Team
parent
24f60a542d
commit
24db4e62f5
@@ -5,33 +5,20 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.symbols.impl
|
||||
|
||||
import kotlin.reflect.KClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvedDeclarationStatus
|
||||
import org.jetbrains.kotlin.fir.psi
|
||||
import org.jetbrains.kotlin.fir.renderer.FirDeclarationRendererWithAttributes
|
||||
import org.jetbrains.kotlin.fir.renderer.FirFileAnnotationsContainerRenderer
|
||||
import org.jetbrains.kotlin.fir.renderer.FirRenderer
|
||||
import org.jetbrains.kotlin.fir.renderer.FirResolvePhaseRenderer
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
|
||||
import org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments
|
||||
import org.jetbrains.kotlin.fir.utils.exceptions.withFirEntry
|
||||
import org.jetbrains.kotlin.fir.utils.exceptions.withFirSymbolIdEntry
|
||||
import org.jetbrains.kotlin.utils.exceptions.errorWithAttachment
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
internal fun FirBasedSymbol<*>.errorInLazyResolve(name: String, actualClass: KClass<*>, expected: KClass<*>): Nothing {
|
||||
throw KotlinExceptionWithAttachments("Unexpected $name. Expected is ${expected.simpleName}, but was ${actualClass.simpleName}").apply {
|
||||
withAttachment(
|
||||
"FirElement.txt",
|
||||
FirRenderer(
|
||||
resolvePhaseRenderer = FirResolvePhaseRenderer(),
|
||||
declarationRenderer = FirDeclarationRendererWithAttributes(),
|
||||
fileAnnotationsContainerRenderer = FirFileAnnotationsContainerRenderer(),
|
||||
).renderElementAsString(fir),
|
||||
)
|
||||
|
||||
withAttachment("FirBasedSymbol.txt", this@errorInLazyResolve::class.simpleName)
|
||||
withAttachment("KtSourceElementKind.txt", fir.source?.kind?.let { it::class.simpleName })
|
||||
withPsiAttachment("PsiElement.txt", fir.psi)
|
||||
errorWithAttachment("Unexpected $name. Expected is ${expected.simpleName}, but was ${actualClass.simpleName}") {
|
||||
withFirEntry("firElement", fir)
|
||||
withFirSymbolIdEntry("firSymbol", this@errorInLazyResolve)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user