[FIR] Inherit FIR with parameter renderer from the old parameter renderer
This commit is contained in:
+4
-13
@@ -7,13 +7,12 @@ package org.jetbrains.kotlin.fir.analysis.diagnostics
|
||||
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.*
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import java.text.MessageFormat
|
||||
|
||||
sealed class FirDiagnosticRenderer<D : FirDiagnostic<*>> : DiagnosticRenderer<D> {
|
||||
abstract override fun render(diagnostic: D): String
|
||||
interface FirDiagnosticRenderer<D : FirDiagnostic<*>> : DiagnosticRenderer<D> {
|
||||
override fun render(diagnostic: D): String
|
||||
}
|
||||
|
||||
class SimpleFirDiagnosticRenderer<E : FirSourceElement>(private val message: String) : FirDiagnosticRenderer<FirSimpleDiagnostic<E>>() {
|
||||
class SimpleFirDiagnosticRenderer<E : FirSourceElement>(private val message: String) : FirDiagnosticRenderer<FirSimpleDiagnostic<E>> {
|
||||
override fun render(diagnostic: FirSimpleDiagnostic<E>): String {
|
||||
return message
|
||||
}
|
||||
@@ -21,15 +20,7 @@ class SimpleFirDiagnosticRenderer<E : FirSourceElement>(private val message: Str
|
||||
|
||||
sealed class AbstractFirDiagnosticWithParametersRenderer<D : FirDiagnostic<*>>(
|
||||
protected val message: String
|
||||
) : FirDiagnosticRenderer<D>() {
|
||||
private val messageFormat = MessageFormat(message)
|
||||
|
||||
override fun render(diagnostic: D): String {
|
||||
return messageFormat.format(renderParameters(diagnostic))
|
||||
}
|
||||
|
||||
abstract fun renderParameters(diagnostic: D): Array<out Any>
|
||||
}
|
||||
) : FirDiagnosticRenderer<D>, AbstractDiagnosticWithParametersRenderer<D>(message)
|
||||
|
||||
class FirDiagnosticWithParameters1Renderer<E : FirSourceElement, A : Any>(
|
||||
message: String,
|
||||
|
||||
+2
-2
@@ -23,8 +23,8 @@ import java.text.MessageFormat
|
||||
abstract class AbstractDiagnosticWithParametersRenderer<D : Diagnostic> protected constructor(message: String) : DiagnosticRenderer<D> {
|
||||
private val messageFormat = MessageFormat(message)
|
||||
|
||||
override fun render(obj: D): String {
|
||||
return messageFormat.format(renderParameters(obj))
|
||||
override fun render(diagnostic: D): String {
|
||||
return messageFormat.format(renderParameters(diagnostic))
|
||||
}
|
||||
|
||||
abstract fun renderParameters(diagnostic: D): Array<out Any>
|
||||
|
||||
@@ -203,6 +203,7 @@ abstract class AbstractFirDiagnosticsTest : AbstractFirBaseDiagnosticsTest() {
|
||||
argument: () -> String,
|
||||
): FirDiagnosticWithParameters1<FirSourceElement, String>? {
|
||||
val sourceElement = element.source ?: return null
|
||||
if (sourceElement.kind != FirRealSourceElementKind) return null
|
||||
val name = name ?: return null
|
||||
if (diagnosedRangesToDiagnosticNames[sourceElement.startOffset..sourceElement.endOffset]?.contains(name) != true) return null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user