Refactor IR reporting and infrastructure

This commit is contained in:
Ilya Chernikov
2021-10-05 16:32:46 +02:00
parent da2d3f29da
commit fc176e9845
16 changed files with 221 additions and 169 deletions
@@ -0,0 +1,19 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.diagnostics
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.diagnostics.rendering.KtDefaultErrorMessages
import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory
object BackendErrors {
val NON_LOCAL_RETURN_IN_DISABLED_INLINE by error0<PsiElement>(SourceElementPositioningStrategies.DEFAULT) // need to reference SourceElementPositioningStrategies at least once to initialize properly
init {
RootDiagnosticRendererFactory.registerFactory(KtDefaultErrorMessages)
}
}
@@ -1,19 +0,0 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.diagnostics
import com.intellij.psi.PsiElement
object KtErrors {
val NON_LOCAL_RETURN_IN_DISABLED_INLINE by error0<PsiElement>()
val TYPEOF_SUSPEND_TYPE by error0<PsiElement>()
val TYPEOF_EXTENSION_FUNCTION_TYPE by error0<PsiElement>()
val TYPEOF_ANNOTATED_TYPE by error0<PsiElement>()
val TYPEOF_NON_REIFIED_TYPE_PARAMETER_WITH_RECURSIVE_BOUND by error1<PsiElement, String>()
val SUSPENSION_POINT_INSIDE_MONITOR by error1<PsiElement, String>()
}
@@ -5,26 +5,13 @@
package org.jetbrains.kotlin.diagnostics.rendering
import org.jetbrains.kotlin.diagnostics.rendering.CommonRenderers.STRING
import org.jetbrains.kotlin.diagnostics.KtDiagnosticFactoryToRendererMap
import org.jetbrains.kotlin.diagnostics.KtErrors.NON_LOCAL_RETURN_IN_DISABLED_INLINE
import org.jetbrains.kotlin.diagnostics.KtErrors.SUSPENSION_POINT_INSIDE_MONITOR
import org.jetbrains.kotlin.diagnostics.KtErrors.TYPEOF_ANNOTATED_TYPE
import org.jetbrains.kotlin.diagnostics.KtErrors.TYPEOF_EXTENSION_FUNCTION_TYPE
import org.jetbrains.kotlin.diagnostics.KtErrors.TYPEOF_NON_REIFIED_TYPE_PARAMETER_WITH_RECURSIVE_BOUND
import org.jetbrains.kotlin.diagnostics.KtErrors.TYPEOF_SUSPEND_TYPE
import org.jetbrains.kotlin.diagnostics.BackendErrors
class KtDefaultErrorMessages {
companion object {
object KtDefaultErrorMessages : BaseDiagnosticRendererFactory() {
val MAP = KtDiagnosticFactoryToRendererMap("KT").also { map ->
map.put(NON_LOCAL_RETURN_IN_DISABLED_INLINE, "Non-local returns are not allowed with inlining disabled")
map.put(TYPEOF_SUSPEND_TYPE, "Suspend functional types are not supported in typeOf")
map.put(TYPEOF_EXTENSION_FUNCTION_TYPE, "Extension function types are not supported in typeOf")
map.put(TYPEOF_ANNOTATED_TYPE, "Annotated types are not supported in typeOf")
map.put(TYPEOF_NON_REIFIED_TYPE_PARAMETER_WITH_RECURSIVE_BOUND, "Non-reified type parameters with recursive bounds are not supported yet: {0}", STRING)
map.put(SUSPENSION_POINT_INSIDE_MONITOR, "A suspension point at {0} is inside a critical section", STRING)
}
override val MAP = KtDiagnosticFactoryToRendererMap("KT").also { map ->
map.put(BackendErrors.NON_LOCAL_RETURN_IN_DISABLED_INLINE, "Non-local returns are not allowed with inlining disabled")
}
}
}