[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 {
|
withIndent {
|
||||||
printParameters(diagnostic, diagnosticList)
|
printParameters(diagnostic, diagnosticList)
|
||||||
}
|
}
|
||||||
print(") : KtFirDiagnostic.${diagnostic.className}(), KtAbstractFirDiagnostic<")
|
print(") : KtAbstractFirDiagnostic<")
|
||||||
printTypeWithShortNames(diagnostic.original.psiType)
|
printTypeWithShortNames(diagnostic.original.psiType)
|
||||||
println(">")
|
println(">(firDiagnostic, token), KtFirDiagnostic.${diagnostic.className}")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun SmartPrinter.printParameters(diagnostic: HLDiagnostic, diagnosticList: HLDiagnosticList) {
|
private fun SmartPrinter.printParameters(diagnostic: HLDiagnostic, diagnosticList: HLDiagnosticList) {
|
||||||
for (parameter in diagnostic.parameters) {
|
for (parameter in diagnostic.parameters) {
|
||||||
printParameter(parameter, diagnosticList)
|
printParameter(parameter, diagnosticList)
|
||||||
}
|
}
|
||||||
println("override val firDiagnostic: KtPsiDiagnostic,")
|
println("firDiagnostic: KtPsiDiagnostic,")
|
||||||
println("override val token: KtLifetimeToken,")
|
println("token: KtLifetimeToken,")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun SmartPrinter.printParameter(parameter: HLDiagnosticParameter, diagnosticList: HLDiagnosticList) {
|
private fun SmartPrinter.printParameter(parameter: HLDiagnosticParameter, diagnosticList: HLDiagnosticList) {
|
||||||
|
|||||||
+4
-4
@@ -18,7 +18,7 @@ object KtDiagnosticClassRenderer : AbstractDiagnosticsDataClassRenderer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun SmartPrinter.printDiagnosticClasses(diagnosticList: HLDiagnosticList) {
|
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) {
|
for (diagnostic in diagnosticList.diagnostics) {
|
||||||
printDiagnosticClass(diagnostic, diagnosticList)
|
printDiagnosticClass(diagnostic, diagnosticList)
|
||||||
println()
|
println()
|
||||||
@@ -27,9 +27,9 @@ object KtDiagnosticClassRenderer : AbstractDiagnosticsDataClassRenderer() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun SmartPrinter.printDiagnosticClass(diagnostic: HLDiagnostic, diagnosticList: HLDiagnosticList) {
|
private fun SmartPrinter.printDiagnosticClass(diagnostic: HLDiagnostic, diagnosticList: HLDiagnosticList) {
|
||||||
print("abstract class ${diagnostic.className} : KtFirDiagnostic<")
|
print("interface ${diagnostic.className} : KtFirDiagnostic<")
|
||||||
printTypeWithShortNames(diagnostic.original.psiType)
|
printTypeWithShortNames(diagnostic.original.psiType)
|
||||||
print(">()")
|
print(">")
|
||||||
inBracketsWithIndent {
|
inBracketsWithIndent {
|
||||||
println("override val diagnosticClass get() = ${diagnostic.className}::class")
|
println("override val diagnosticClass get() = ${diagnostic.className}::class")
|
||||||
printDiagnosticParameters(diagnostic, diagnosticList)
|
printDiagnosticParameters(diagnostic, diagnosticList)
|
||||||
@@ -38,7 +38,7 @@ object KtDiagnosticClassRenderer : AbstractDiagnosticsDataClassRenderer() {
|
|||||||
|
|
||||||
private fun SmartPrinter.printDiagnosticParameters(diagnostic: HLDiagnostic, diagnosticList: HLDiagnosticList) {
|
private fun SmartPrinter.printDiagnosticParameters(diagnostic: HLDiagnostic, diagnosticList: HLDiagnosticList) {
|
||||||
diagnostic.parameters.forEach { parameter ->
|
diagnostic.parameters.forEach { parameter ->
|
||||||
print("abstract val ${parameter.name}: ")
|
print("val ${parameter.name}: ")
|
||||||
printTypeWithShortNames(parameter.type) { type ->
|
printTypeWithShortNames(parameter.type) { type ->
|
||||||
diagnosticList.containsClashingBySimpleNameType(type)
|
diagnosticList.containsClashingBySimpleNameType(type)
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -9,14 +9,17 @@ import com.intellij.openapi.util.TextRange
|
|||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeOwner
|
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeOwner
|
||||||
import org.jetbrains.kotlin.analysis.api.diagnostics.KtDiagnosticWithPsi
|
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.analysis.api.lifetime.withValidityAssertion
|
||||||
import org.jetbrains.kotlin.diagnostics.KtDiagnostic
|
import org.jetbrains.kotlin.diagnostics.KtDiagnostic
|
||||||
import org.jetbrains.kotlin.diagnostics.KtPsiDiagnostic
|
import org.jetbrains.kotlin.diagnostics.KtPsiDiagnostic
|
||||||
import org.jetbrains.kotlin.diagnostics.Severity
|
import org.jetbrains.kotlin.diagnostics.Severity
|
||||||
import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory
|
import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory
|
||||||
|
|
||||||
internal interface KtAbstractFirDiagnostic<PSI : PsiElement> : KtDiagnosticWithPsi<PSI>, KtLifetimeOwner {
|
internal abstract class KtAbstractFirDiagnostic<PSI : PsiElement>(
|
||||||
val firDiagnostic: KtPsiDiagnostic
|
private val firDiagnostic: KtPsiDiagnostic,
|
||||||
|
override val token: KtLifetimeToken,
|
||||||
|
) : KtDiagnosticWithPsi<PSI>, KtLifetimeOwner {
|
||||||
|
|
||||||
override val factoryName: String
|
override val factoryName: String
|
||||||
get() = withValidityAssertion { firDiagnostic.factory.name }
|
get() = withValidityAssertion { firDiagnostic.factory.name }
|
||||||
|
|||||||
+20
-20
@@ -7,41 +7,41 @@ package org.jetbrains.kotlin.analysis.api.fir.diagnostics
|
|||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
|
||||||
abstract class KtCompilerPluginDiagnostic0 : KtFirDiagnostic<PsiElement>(), KtAbstractFirDiagnostic<PsiElement> {
|
interface KtCompilerPluginDiagnostic0 : KtFirDiagnostic<PsiElement> {
|
||||||
final override val diagnosticClass
|
override val diagnosticClass
|
||||||
get() = KtCompilerPluginDiagnostic0::class
|
get() = KtCompilerPluginDiagnostic0::class
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class KtCompilerPluginDiagnostic1 : KtFirDiagnostic<PsiElement>(), KtAbstractFirDiagnostic<PsiElement> {
|
interface KtCompilerPluginDiagnostic1 : KtFirDiagnostic<PsiElement> {
|
||||||
abstract val parameter1: Any?
|
val parameter1: Any?
|
||||||
|
|
||||||
final override val diagnosticClass
|
override val diagnosticClass
|
||||||
get() = KtCompilerPluginDiagnostic1::class
|
get() = KtCompilerPluginDiagnostic1::class
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class KtCompilerPluginDiagnostic2 : KtFirDiagnostic<PsiElement>(), KtAbstractFirDiagnostic<PsiElement> {
|
interface KtCompilerPluginDiagnostic2 : KtFirDiagnostic<PsiElement> {
|
||||||
abstract val parameter1: Any?
|
val parameter1: Any?
|
||||||
abstract val parameter2: Any?
|
val parameter2: Any?
|
||||||
|
|
||||||
final override val diagnosticClass
|
override val diagnosticClass
|
||||||
get() = KtCompilerPluginDiagnostic2::class
|
get() = KtCompilerPluginDiagnostic2::class
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class KtCompilerPluginDiagnostic3 : KtFirDiagnostic<PsiElement>(), KtAbstractFirDiagnostic<PsiElement> {
|
interface KtCompilerPluginDiagnostic3 : KtFirDiagnostic<PsiElement> {
|
||||||
abstract val parameter1: Any?
|
val parameter1: Any?
|
||||||
abstract val parameter2: Any?
|
val parameter2: Any?
|
||||||
abstract val parameter3: Any?
|
val parameter3: Any?
|
||||||
|
|
||||||
final override val diagnosticClass
|
override val diagnosticClass
|
||||||
get() = KtCompilerPluginDiagnostic3::class
|
get() = KtCompilerPluginDiagnostic3::class
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class KtCompilerPluginDiagnostic4 : KtFirDiagnostic<PsiElement>(), KtAbstractFirDiagnostic<PsiElement> {
|
interface KtCompilerPluginDiagnostic4 : KtFirDiagnostic<PsiElement> {
|
||||||
abstract val parameter1: Any?
|
val parameter1: Any?
|
||||||
abstract val parameter2: Any?
|
val parameter2: Any?
|
||||||
abstract val parameter3: Any?
|
val parameter3: Any?
|
||||||
abstract val parameter4: Any?
|
val parameter4: Any?
|
||||||
|
|
||||||
final override val diagnosticClass
|
override val diagnosticClass
|
||||||
get() = KtCompilerPluginDiagnostic4::class
|
get() = KtCompilerPluginDiagnostic4::class
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-15
@@ -5,40 +5,41 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.analysis.api.fir.diagnostics
|
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.analysis.api.lifetime.KtLifetimeToken
|
||||||
import org.jetbrains.kotlin.diagnostics.*
|
import org.jetbrains.kotlin.diagnostics.*
|
||||||
|
|
||||||
internal class KtCompilerPluginDiagnostic0Impl(
|
internal class KtCompilerPluginDiagnostic0Impl(
|
||||||
override val firDiagnostic: KtPsiSimpleDiagnostic,
|
firDiagnostic: KtPsiSimpleDiagnostic,
|
||||||
override val token: KtLifetimeToken
|
token: KtLifetimeToken
|
||||||
) : KtCompilerPluginDiagnostic0()
|
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtCompilerPluginDiagnostic0
|
||||||
|
|
||||||
internal class KtCompilerPluginDiagnostic1Impl(
|
internal class KtCompilerPluginDiagnostic1Impl(
|
||||||
override val firDiagnostic: KtPsiDiagnosticWithParameters1<*>,
|
firDiagnostic: KtPsiDiagnosticWithParameters1<*>,
|
||||||
override val token: KtLifetimeToken,
|
token: KtLifetimeToken,
|
||||||
override val parameter1: Any?
|
override val parameter1: Any?
|
||||||
) : KtCompilerPluginDiagnostic1()
|
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtCompilerPluginDiagnostic1
|
||||||
|
|
||||||
internal class KtCompilerPluginDiagnostic2Impl(
|
internal class KtCompilerPluginDiagnostic2Impl(
|
||||||
override val firDiagnostic: KtPsiDiagnosticWithParameters2<*, *>,
|
firDiagnostic: KtPsiDiagnosticWithParameters2<*, *>,
|
||||||
override val token: KtLifetimeToken,
|
token: KtLifetimeToken,
|
||||||
override val parameter1: Any?,
|
override val parameter1: Any?,
|
||||||
override val parameter2: Any?
|
override val parameter2: Any?
|
||||||
) : KtCompilerPluginDiagnostic2()
|
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtCompilerPluginDiagnostic2
|
||||||
|
|
||||||
internal class KtCompilerPluginDiagnostic3Impl(
|
internal class KtCompilerPluginDiagnostic3Impl(
|
||||||
override val firDiagnostic: KtPsiDiagnosticWithParameters3<*, *, *>,
|
firDiagnostic: KtPsiDiagnosticWithParameters3<*, *, *>,
|
||||||
override val token: KtLifetimeToken,
|
token: KtLifetimeToken,
|
||||||
override val parameter1: Any?,
|
override val parameter1: Any?,
|
||||||
override val parameter2: Any?,
|
override val parameter2: Any?,
|
||||||
override val parameter3: Any?
|
override val parameter3: Any?
|
||||||
) : KtCompilerPluginDiagnostic3()
|
) : KtAbstractFirDiagnostic<PsiElement>(firDiagnostic, token), KtCompilerPluginDiagnostic3
|
||||||
|
|
||||||
internal class KtCompilerPluginDiagnostic4Impl(
|
internal class KtCompilerPluginDiagnostic4Impl(
|
||||||
override val firDiagnostic: KtPsiDiagnosticWithParameters4<*, *, *, *>,
|
firDiagnostic: KtPsiDiagnosticWithParameters4<*, *, *, *>,
|
||||||
override val token: KtLifetimeToken,
|
token: KtLifetimeToken,
|
||||||
override val parameter1: Any?,
|
override val parameter1: Any?,
|
||||||
override val parameter2: Any?,
|
override val parameter2: Any?,
|
||||||
override val parameter3: Any?,
|
override val parameter3: Any?,
|
||||||
override val parameter4: 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