[Analysis API] Hide FIR-specific diagnostic details.
Change the public-facing KtFirDiagnostic to be an interface, not a class, and change the internal implementations to be classes, not interfaces. This allows hiding access to the KtPsiDiagnostic underlying the AA diagnostic class.
This commit is contained in:
committed by
Ilya Kirillov
parent
3eeb867f56
commit
dd9e127d2c
+4
-4
@@ -32,17 +32,17 @@ object KtDiagnosticClassImplementationRenderer : AbstractDiagnosticsDataClassRen
|
||||
withIndent {
|
||||
printParameters(diagnostic, diagnosticList)
|
||||
}
|
||||
print(") : KtFirDiagnostic.${diagnostic.className}(), KtAbstractFirDiagnostic<")
|
||||
print(") : KtAbstractFirDiagnostic<")
|
||||
printTypeWithShortNames(diagnostic.original.psiType)
|
||||
println(">")
|
||||
println(">(firDiagnostic, token), KtFirDiagnostic.${diagnostic.className}")
|
||||
}
|
||||
|
||||
private fun SmartPrinter.printParameters(diagnostic: HLDiagnostic, diagnosticList: HLDiagnosticList) {
|
||||
for (parameter in diagnostic.parameters) {
|
||||
printParameter(parameter, diagnosticList)
|
||||
}
|
||||
println("override val firDiagnostic: KtPsiDiagnostic,")
|
||||
println("override val token: KtLifetimeToken,")
|
||||
println("firDiagnostic: KtPsiDiagnostic,")
|
||||
println("token: KtLifetimeToken,")
|
||||
}
|
||||
|
||||
private fun SmartPrinter.printParameter(parameter: HLDiagnosticParameter, diagnosticList: HLDiagnosticList) {
|
||||
|
||||
+4
-4
@@ -18,7 +18,7 @@ object KtDiagnosticClassRenderer : AbstractDiagnosticsDataClassRenderer() {
|
||||
}
|
||||
|
||||
private fun SmartPrinter.printDiagnosticClasses(diagnosticList: HLDiagnosticList) {
|
||||
inBracketsWithIndent("sealed class KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI>") {
|
||||
inBracketsWithIndent("sealed interface KtFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI>") {
|
||||
for (diagnostic in diagnosticList.diagnostics) {
|
||||
printDiagnosticClass(diagnostic, diagnosticList)
|
||||
println()
|
||||
@@ -27,9 +27,9 @@ object KtDiagnosticClassRenderer : AbstractDiagnosticsDataClassRenderer() {
|
||||
}
|
||||
|
||||
private fun SmartPrinter.printDiagnosticClass(diagnostic: HLDiagnostic, diagnosticList: HLDiagnosticList) {
|
||||
print("abstract class ${diagnostic.className} : KtFirDiagnostic<")
|
||||
print("interface ${diagnostic.className} : KtFirDiagnostic<")
|
||||
printTypeWithShortNames(diagnostic.original.psiType)
|
||||
print(">()")
|
||||
print(">")
|
||||
inBracketsWithIndent {
|
||||
println("override val diagnosticClass get() = ${diagnostic.className}::class")
|
||||
printDiagnosticParameters(diagnostic, diagnosticList)
|
||||
@@ -38,7 +38,7 @@ object KtDiagnosticClassRenderer : AbstractDiagnosticsDataClassRenderer() {
|
||||
|
||||
private fun SmartPrinter.printDiagnosticParameters(diagnostic: HLDiagnostic, diagnosticList: HLDiagnosticList) {
|
||||
diagnostic.parameters.forEach { parameter ->
|
||||
print("abstract val ${parameter.name}: ")
|
||||
print("val ${parameter.name}: ")
|
||||
printTypeWithShortNames(parameter.type) { type ->
|
||||
diagnosticList.containsClashingBySimpleNameType(type)
|
||||
}
|
||||
|
||||
+5
-2
@@ -9,14 +9,17 @@ import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeOwner
|
||||
import org.jetbrains.kotlin.analysis.api.diagnostics.KtDiagnosticWithPsi
|
||||
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeToken
|
||||
import org.jetbrains.kotlin.analysis.api.lifetime.withValidityAssertion
|
||||
import org.jetbrains.kotlin.diagnostics.KtDiagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.KtPsiDiagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory
|
||||
|
||||
internal interface KtAbstractFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI>, KtLifetimeOwner {
|
||||
val firDiagnostic: KtPsiDiagnostic
|
||||
internal abstract class KtAbstractFirDiagnostic<PSI : PsiElement>(
|
||||
private val firDiagnostic: KtPsiDiagnostic,
|
||||
override val token: KtLifetimeToken,
|
||||
) : KtDiagnosticWithPsi<PSI>, KtLifetimeOwner {
|
||||
|
||||
override val factoryName: String
|
||||
get() = withValidityAssertion { firDiagnostic.factory.name }
|
||||
|
||||
+20
-20
@@ -7,41 +7,41 @@ package org.jetbrains.kotlin.analysis.api.fir.diagnostics
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
|
||||
abstract class KtCompilerPluginDiagnostic0 : KtFirDiagnostic<PsiElement>(), KtAbstractFirDiagnostic<PsiElement> {
|
||||
final override val diagnosticClass
|
||||
interface KtCompilerPluginDiagnostic0 : KtFirDiagnostic<PsiElement> {
|
||||
override val diagnosticClass
|
||||
get() = KtCompilerPluginDiagnostic0::class
|
||||
}
|
||||
|
||||
abstract class KtCompilerPluginDiagnostic1 : KtFirDiagnostic<PsiElement>(), KtAbstractFirDiagnostic<PsiElement> {
|
||||
abstract val parameter1: Any?
|
||||
interface KtCompilerPluginDiagnostic1 : KtFirDiagnostic<PsiElement> {
|
||||
val parameter1: Any?
|
||||
|
||||
final override val diagnosticClass
|
||||
override val diagnosticClass
|
||||
get() = KtCompilerPluginDiagnostic1::class
|
||||
}
|
||||
|
||||
abstract class KtCompilerPluginDiagnostic2 : KtFirDiagnostic<PsiElement>(), KtAbstractFirDiagnostic<PsiElement> {
|
||||
abstract val parameter1: Any?
|
||||
abstract val parameter2: Any?
|
||||
interface KtCompilerPluginDiagnostic2 : KtFirDiagnostic<PsiElement> {
|
||||
val parameter1: Any?
|
||||
val parameter2: Any?
|
||||
|
||||
final override val diagnosticClass
|
||||
override val diagnosticClass
|
||||
get() = KtCompilerPluginDiagnostic2::class
|
||||
}
|
||||
|
||||
abstract class KtCompilerPluginDiagnostic3 : KtFirDiagnostic<PsiElement>(), KtAbstractFirDiagnostic<PsiElement> {
|
||||
abstract val parameter1: Any?
|
||||
abstract val parameter2: Any?
|
||||
abstract val parameter3: Any?
|
||||
interface KtCompilerPluginDiagnostic3 : KtFirDiagnostic<PsiElement> {
|
||||
val parameter1: Any?
|
||||
val parameter2: Any?
|
||||
val parameter3: Any?
|
||||
|
||||
final override val diagnosticClass
|
||||
override val diagnosticClass
|
||||
get() = KtCompilerPluginDiagnostic3::class
|
||||
}
|
||||
|
||||
abstract class KtCompilerPluginDiagnostic4 : KtFirDiagnostic<PsiElement>(), KtAbstractFirDiagnostic<PsiElement> {
|
||||
abstract val parameter1: Any?
|
||||
abstract val parameter2: Any?
|
||||
abstract val parameter3: Any?
|
||||
abstract val parameter4: Any?
|
||||
interface KtCompilerPluginDiagnostic4 : KtFirDiagnostic<PsiElement> {
|
||||
val parameter1: Any?
|
||||
val parameter2: Any?
|
||||
val parameter3: Any?
|
||||
val parameter4: Any?
|
||||
|
||||
final override val diagnosticClass
|
||||
override val diagnosticClass
|
||||
get() = KtCompilerPluginDiagnostic4::class
|
||||
}
|
||||
|
||||
+16
-15
@@ -5,40 +5,41 @@
|
||||
|
||||
package org.jetbrains.kotlin.analysis.api.fir.diagnostics
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeToken
|
||||
import org.jetbrains.kotlin.diagnostics.*
|
||||
|
||||
internal class KtCompilerPluginDiagnostic0Impl(
|
||||
override val firDiagnostic: KtPsiSimpleDiagnostic,
|
||||
override val token: KtLifetimeToken
|
||||
) : KtCompilerPluginDiagnostic0()
|
||||
firDiagnostic: KtPsiSimpleDiagnostic,
|
||||
token: KtLifetimeToken
|
||||
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtCompilerPluginDiagnostic0
|
||||
|
||||
internal class KtCompilerPluginDiagnostic1Impl(
|
||||
override val firDiagnostic: KtPsiDiagnosticWithParameters1<*>,
|
||||
override val token: KtLifetimeToken,
|
||||
firDiagnostic: KtPsiDiagnosticWithParameters1<*>,
|
||||
token: KtLifetimeToken,
|
||||
override val parameter1: Any?
|
||||
) : KtCompilerPluginDiagnostic1()
|
||||
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtCompilerPluginDiagnostic1
|
||||
|
||||
internal class KtCompilerPluginDiagnostic2Impl(
|
||||
override val firDiagnostic: KtPsiDiagnosticWithParameters2<*, *>,
|
||||
override val token: KtLifetimeToken,
|
||||
firDiagnostic: KtPsiDiagnosticWithParameters2<*, *>,
|
||||
token: KtLifetimeToken,
|
||||
override val parameter1: Any?,
|
||||
override val parameter2: Any?
|
||||
) : KtCompilerPluginDiagnostic2()
|
||||
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtCompilerPluginDiagnostic2
|
||||
|
||||
internal class KtCompilerPluginDiagnostic3Impl(
|
||||
override val firDiagnostic: KtPsiDiagnosticWithParameters3<*, *, *>,
|
||||
override val token: KtLifetimeToken,
|
||||
firDiagnostic: KtPsiDiagnosticWithParameters3<*, *, *>,
|
||||
token: KtLifetimeToken,
|
||||
override val parameter1: Any?,
|
||||
override val parameter2: Any?,
|
||||
override val parameter3: Any?
|
||||
) : KtCompilerPluginDiagnostic3()
|
||||
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtCompilerPluginDiagnostic3
|
||||
|
||||
internal class KtCompilerPluginDiagnostic4Impl(
|
||||
override val firDiagnostic: KtPsiDiagnosticWithParameters4<*, *, *, *>,
|
||||
override val token: KtLifetimeToken,
|
||||
firDiagnostic: KtPsiDiagnosticWithParameters4<*, *, *, *>,
|
||||
token: KtLifetimeToken,
|
||||
override val parameter1: Any?,
|
||||
override val parameter2: Any?,
|
||||
override val parameter3: Any?,
|
||||
override val parameter4: Any?
|
||||
) : KtCompilerPluginDiagnostic4()
|
||||
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtCompilerPluginDiagnostic4
|
||||
|
||||
+1236
-1236
File diff suppressed because it is too large
Load Diff
+2238
-2238
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user