[FIR] Don't inherit FIR diagnostics from FE 1.0 diagnostics
This commit is contained in:
+1
-2
@@ -1,5 +1,4 @@
|
||||
# Note that this file is also present in idea/src/META-INF/services
|
||||
org.jetbrains.kotlin.resolve.jvm.diagnostics.DefaultErrorMessagesJvm
|
||||
org.jetbrains.kotlin.js.resolve.diagnostics.DefaultErrorMessagesJs
|
||||
org.jetbrains.kotlin.fir.analysis.diagnostics.FirDefaultErrorMessages
|
||||
org.jetbrains.kotlin.resolve.konan.diagnostics.DefaultErrorMessagesNative
|
||||
org.jetbrains.kotlin.resolve.konan.diagnostics.DefaultErrorMessagesNative
|
||||
|
||||
+5
-4
@@ -147,10 +147,11 @@ object FirKotlinToJvmBytecodeCompiler {
|
||||
|
||||
firAnalyzerFacade.runResolution()
|
||||
val firDiagnostics = firAnalyzerFacade.runCheckers().values.flatten()
|
||||
AnalyzerWithCompilerReport.reportDiagnostics(
|
||||
SimpleGenericDiagnostics(firDiagnostics),
|
||||
environment.messageCollector
|
||||
)
|
||||
// TODO
|
||||
// AnalyzerWithCompilerReport.reportDiagnostics(
|
||||
// SimpleGenericDiagnostics(firDiagnostics),
|
||||
// environment.messageCollector
|
||||
// )
|
||||
performanceManager?.notifyAnalysisFinished()
|
||||
|
||||
if (syntaxErrors || firDiagnostics.any { it.severity == Severity.ERROR }) {
|
||||
|
||||
+1
-5
@@ -377,11 +377,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_SETTER_PARA
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.WRONG_SETTER_RETURN_TYPE
|
||||
|
||||
@Suppress("unused")
|
||||
class FirDefaultErrorMessages : DefaultErrorMessages.Extension {
|
||||
override fun getMap(): DiagnosticFactoryToRendererMap {
|
||||
return MAP.psiDiagnosticMap
|
||||
}
|
||||
|
||||
class FirDefaultErrorMessages {
|
||||
companion object {
|
||||
fun getRendererForDiagnostic(diagnostic: FirDiagnostic<*>): FirDiagnosticRenderer<*> {
|
||||
val factory = diagnostic.factory
|
||||
|
||||
+12
-11
@@ -8,25 +8,23 @@ package org.jetbrains.kotlin.fir.analysis.diagnostics
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
import org.jetbrains.kotlin.diagnostics.UnboundDiagnostic
|
||||
import org.jetbrains.kotlin.fir.FirLightSourceElement
|
||||
import org.jetbrains.kotlin.fir.FirPsiSourceElement
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
|
||||
// ------------------------------ diagnostics ------------------------------
|
||||
|
||||
sealed class FirDiagnostic<out E : FirSourceElement> : UnboundDiagnostic {
|
||||
sealed class FirDiagnostic<out E : FirSourceElement> {
|
||||
abstract val element: E
|
||||
abstract override val severity: Severity
|
||||
abstract override val factory: AbstractFirDiagnosticFactory<*, *>
|
||||
abstract val severity: Severity
|
||||
abstract val factory: AbstractFirDiagnosticFactory<*, *>
|
||||
abstract val positioningStrategy: SourceElementPositioningStrategy<*>
|
||||
|
||||
override val textRanges: List<TextRange>
|
||||
val textRanges: List<TextRange>
|
||||
get() = positioningStrategy.markDiagnostic(this)
|
||||
|
||||
override val isValid: Boolean
|
||||
val isValid: Boolean
|
||||
get() = positioningStrategy.isValid(element)
|
||||
}
|
||||
|
||||
@@ -62,13 +60,16 @@ sealed class FirDiagnosticWithParameters4<out E : FirSourceElement, A, B, C, D>
|
||||
|
||||
// ------------------------------ psi diagnostics ------------------------------
|
||||
|
||||
interface FirPsiDiagnostic<P : PsiElement> : Diagnostic {
|
||||
interface FirPsiDiagnostic<P : PsiElement> {
|
||||
val factory: AbstractFirDiagnosticFactory<*, P>
|
||||
val element: FirPsiSourceElement<P>
|
||||
val textRanges: List<TextRange>
|
||||
val severity: Severity
|
||||
|
||||
override val psiElement: PsiElement
|
||||
val psiElement: PsiElement
|
||||
get() = element.psi
|
||||
|
||||
override val psiFile: PsiFile
|
||||
val psiFile: PsiFile
|
||||
get() = psiElement.containingFile
|
||||
}
|
||||
|
||||
@@ -119,7 +120,7 @@ data class FirPsiDiagnosticWithParameters4<P : PsiElement, A, B, C, D>(
|
||||
|
||||
// ------------------------------ light tree diagnostics ------------------------------
|
||||
|
||||
interface FirLightDiagnostic : UnboundDiagnostic {
|
||||
interface FirLightDiagnostic {
|
||||
val element: FirLightSourceElement
|
||||
}
|
||||
|
||||
|
||||
+3
-15
@@ -1,16 +1,9 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.
|
||||
*/
|
||||
|
||||
@file:Suppress("UNCHECKED_CAST")
|
||||
|
||||
package org.jetbrains.kotlin.fir.analysis.diagnostics
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticRenderer
|
||||
import org.jetbrains.kotlin.fir.FirLightSourceElement
|
||||
import org.jetbrains.kotlin.fir.FirPsiSourceElement
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
@@ -19,16 +12,11 @@ import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
annotation class InternalDiagnosticFactoryMethod
|
||||
|
||||
sealed class AbstractFirDiagnosticFactory<D : FirDiagnostic<*>, P : PsiElement>(
|
||||
override val name: String,
|
||||
override val severity: Severity,
|
||||
val name: String,
|
||||
val severity: Severity,
|
||||
val defaultPositioningStrategy: SourceElementPositioningStrategy<P>,
|
||||
) : DiagnosticFactory<D>(name, severity) {
|
||||
) {
|
||||
abstract val firRenderer: FirDiagnosticRenderer<D>
|
||||
|
||||
override var defaultRenderer: DiagnosticRenderer<D>?
|
||||
get() = firRenderer
|
||||
set(_) {
|
||||
}
|
||||
}
|
||||
|
||||
class FirDiagnosticFactory0<P : PsiElement>(
|
||||
|
||||
-3
@@ -5,12 +5,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.analysis.diagnostics
|
||||
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticFactoryToRendererMap
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticParameterRenderer
|
||||
|
||||
class FirDiagnosticFactoryToRendererMap(val name: String) {
|
||||
private val renderersMap: MutableMap<AbstractFirDiagnosticFactory<*, *>, FirDiagnosticRenderer<*>> = mutableMapOf()
|
||||
val psiDiagnosticMap: DiagnosticFactoryToRendererMap = DiagnosticFactoryToRendererMap()
|
||||
|
||||
operator fun get(factory: AbstractFirDiagnosticFactory<*, *>): FirDiagnosticRenderer<*>? = renderersMap[factory]
|
||||
|
||||
@@ -58,6 +56,5 @@ class FirDiagnosticFactoryToRendererMap(val name: String) {
|
||||
|
||||
private fun put(factory: AbstractFirDiagnosticFactory<*, *>, renderer: FirDiagnosticRenderer<*>) {
|
||||
renderersMap[factory] = renderer
|
||||
psiDiagnosticMap.put(factory, renderer)
|
||||
}
|
||||
}
|
||||
|
||||
+12
-6
@@ -6,11 +6,11 @@
|
||||
package org.jetbrains.kotlin.fir.analysis.diagnostics
|
||||
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.*
|
||||
import java.text.MessageFormat
|
||||
|
||||
interface FirDiagnosticRenderer<D : FirDiagnostic<*>> : DiagnosticRenderer<D> {
|
||||
override fun render(diagnostic: D): String
|
||||
|
||||
override fun renderParameters(diagnostic: D): Array<out Any?>
|
||||
sealed interface FirDiagnosticRenderer<D : FirDiagnostic<*>> {
|
||||
fun render(diagnostic: D): String
|
||||
fun renderParameters(diagnostic: D): Array<out Any?>
|
||||
}
|
||||
|
||||
class SimpleFirDiagnosticRenderer(private val message: String) : FirDiagnosticRenderer<FirSimpleDiagnostic<*>> {
|
||||
@@ -19,13 +19,19 @@ class SimpleFirDiagnosticRenderer(private val message: String) : FirDiagnosticRe
|
||||
}
|
||||
|
||||
override fun renderParameters(diagnostic: FirSimpleDiagnostic<*>): Array<out Any?> {
|
||||
return arrayOf()
|
||||
return emptyArray()
|
||||
}
|
||||
}
|
||||
|
||||
sealed class AbstractFirDiagnosticWithParametersRenderer<D : FirDiagnostic<*>>(
|
||||
protected val message: String
|
||||
) : FirDiagnosticRenderer<D>, AbstractDiagnosticWithParametersRenderer<D>(message)
|
||||
) : FirDiagnosticRenderer<D> {
|
||||
private val messageFormat = MessageFormat(message)
|
||||
|
||||
final override fun render(diagnostic: D): String {
|
||||
return messageFormat.format(renderParameters(diagnostic))
|
||||
}
|
||||
}
|
||||
|
||||
class FirDiagnosticWithParameters1Renderer<A>(
|
||||
message: String,
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
# Note that this file is also present in compiler/cli/src/META-INF/services
|
||||
org.jetbrains.kotlin.resolve.jvm.diagnostics.DefaultErrorMessagesJvm
|
||||
org.jetbrains.kotlin.js.resolve.diagnostics.DefaultErrorMessagesJs
|
||||
org.jetbrains.kotlin.fir.analysis.diagnostics.FirDefaultErrorMessages
|
||||
org.jetbrains.kotlin.resolve.konan.diagnostics.DefaultErrorMessagesNative
|
||||
org.jetbrains.kotlin.resolve.konan.diagnostics.DefaultErrorMessagesNative
|
||||
|
||||
Reference in New Issue
Block a user