FIR: Allow 4 parameters for diagnostics
This commit is contained in:
committed by
Ilya Kirillov
parent
d2b8204fdc
commit
594fbbb4ef
+7
@@ -57,6 +57,13 @@ private fun FirLightDiagnostic.toPsiDiagnostic(): FirPsiDiagnostic<*> {
|
||||
severity,
|
||||
factory as FirDiagnosticFactory3<PsiElement, Any, Any, Any>
|
||||
)
|
||||
|
||||
is FirLightDiagnosticWithParameters4<*, *, *, *> -> FirPsiDiagnosticWithParameters4(
|
||||
psiSourceElement,
|
||||
a, b, c, d,
|
||||
severity,
|
||||
factory as FirDiagnosticFactory4<PsiElement, Any, Any, Any, Any>
|
||||
)
|
||||
else -> error("Unknown diagnostic type ${this::class.simpleName}")
|
||||
}
|
||||
}
|
||||
+11
@@ -27,6 +27,10 @@ internal fun interface KtFirDiagnostic3Creator<A : Any, B : Any, C : Any> : KtFi
|
||||
fun KtFirAnalysisSession.create(diagnostic: FirDiagnosticWithParameters3<*, A, B, C>): KtFirDiagnostic<*>
|
||||
}
|
||||
|
||||
internal fun interface KtFirDiagnostic4Creator<A : Any, B : Any, C : Any, D : Any> : KtFirDiagnosticCreator {
|
||||
fun KtFirAnalysisSession.create(diagnostic: FirDiagnosticWithParameters4<*, A, B, C, D>): KtFirDiagnostic<*>
|
||||
}
|
||||
|
||||
internal class KtDiagnosticConverter(private val conversions: Map<AbstractFirDiagnosticFactory<*, *>, KtFirDiagnosticCreator>) {
|
||||
fun convert(analysisSession: KtFirAnalysisSession, diagnostic: FirDiagnostic<*>): KtFirDiagnostic<*> {
|
||||
val creator = conversions[diagnostic.factory]
|
||||
@@ -47,6 +51,9 @@ internal class KtDiagnosticConverter(private val conversions: Map<AbstractFirDia
|
||||
is KtFirDiagnostic3Creator<*, *, *> -> with(creator as KtFirDiagnostic3Creator<Any, Any, Any>) {
|
||||
create(diagnostic as FirDiagnosticWithParameters3<FirSourceElement, Any, Any, Any>)
|
||||
}
|
||||
is KtFirDiagnostic4Creator<*, *, *, *> -> with(creator as KtFirDiagnostic4Creator<Any, Any, Any, Any>) {
|
||||
create(diagnostic as FirDiagnosticWithParameters4<FirSourceElement, Any, Any, Any, Any>)
|
||||
}
|
||||
else -> error("Invalid KtFirDiagnosticCreator ${creator::class.simpleName}")
|
||||
}
|
||||
}
|
||||
@@ -72,6 +79,10 @@ internal class KtDiagnosticConverterBuilder private constructor() {
|
||||
conversions[diagnostic] = creator
|
||||
}
|
||||
|
||||
fun <A : Any, B : Any, C : Any, D : Any> add(diagnostic: FirDiagnosticFactory4<*, A, B, C, D>, creator: KtFirDiagnostic4Creator<A, B, C, D>) {
|
||||
conversions[diagnostic] = creator
|
||||
}
|
||||
|
||||
private fun build() = KtDiagnosticConverter(conversions)
|
||||
|
||||
companion object {
|
||||
|
||||
Reference in New Issue
Block a user