FIR LT: add syntax error reporting to LT2Fir

use it in the new pipeline
This commit is contained in:
Ilya Chernikov
2021-12-29 22:08:21 +01:00
committed by teamcity
parent 2689ebf455
commit 9e32188938
21 changed files with 98 additions and 40 deletions
+1
View File
@@ -8,6 +8,7 @@ plugins {
dependencies {
api(project(":compiler:fir:providers"))
api(project(":compiler:fir:semantics"))
api(project(":compiler:fir:raw-fir:raw-fir.common"))
implementation(project(":compiler:frontend.common"))
implementation(project(":compiler:frontend.common-psi"))
implementation(project(":compiler:psi"))
@@ -52,7 +52,6 @@ object DIAGNOSTICS_LIST : DiagnosticList("FirErrors") {
}
val Miscellaneous by object : DiagnosticGroup("Miscellaneous") {
val SYNTAX by error<PsiElement>()
val OTHER_ERROR by error<PsiElement>()
}
@@ -111,7 +111,6 @@ object FirErrors {
val NEW_INFERENCE_ERROR by error1<PsiElement, String>()
// Miscellaneous
val SYNTAX by error0<PsiElement>()
val OTHER_ERROR by error0<PsiElement>()
// General syntax
@@ -473,7 +473,6 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SUPERTYPE_NOT_INI
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SUPER_CALL_FROM_PUBLIC_INLINE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SUPER_IS_NOT_AN_EXPRESSION
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SUPER_NOT_AVAILABLE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.SYNTAX
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.TAILREC_ON_VIRTUAL_MEMBER_ERROR
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.TAIL_RECURSION_IN_TRY_IS_NOT_SUPPORTED
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors.THROWABLE_TYPE_MISMATCH
@@ -586,7 +585,6 @@ object FirErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
map.put(NEW_INFERENCE_ERROR, "New inference error [{0}]", STRING)
// Miscellaneous
map.put(SYNTAX, "Syntax error")
map.put(OTHER_ERROR, "Unknown (other) error")
// General syntax
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.diagnostics.*
import org.jetbrains.kotlin.fir.FirSession
import org.jetbrains.kotlin.fir.analysis.checkers.declaration.isLocalMember
import org.jetbrains.kotlin.fir.analysis.getChild
import org.jetbrains.kotlin.fir.builder.FirSyntaxErrors
import org.jetbrains.kotlin.fir.declarations.utils.isInfix
import org.jetbrains.kotlin.fir.declarations.utils.isOperator
import org.jetbrains.kotlin.fir.diagnostics.*
@@ -386,7 +387,7 @@ private val NewConstraintError.upperConeType: ConeKotlinType get() = upperType a
private fun ConeSimpleDiagnostic.getFactory(source: KtSourceElement): KtDiagnosticFactory0 {
@Suppress("UNCHECKED_CAST")
return when (kind) {
DiagnosticKind.Syntax -> FirErrors.SYNTAX
DiagnosticKind.Syntax -> FirSyntaxErrors.SYNTAX
DiagnosticKind.ReturnNotAllowed -> FirErrors.RETURN_NOT_ALLOWED
DiagnosticKind.NotAFunctionLabel -> FirErrors.NOT_A_FUNCTION_LABEL
DiagnosticKind.UnresolvedLabel -> FirErrors.UNRESOLVED_LABEL