Implement common Diagnostic(Factory/Renderer) in related FIR classes
This commit is contained in:
+1
-1
@@ -128,7 +128,7 @@ class AnalyzerWithCompilerReport(
|
||||
psiElement: E, factory: DiagnosticFactory0<E>, val message: String
|
||||
) : SimpleDiagnostic<E>(psiElement, factory, Severity.ERROR) {
|
||||
|
||||
override fun isValid(): Boolean = true
|
||||
override val isValid: Boolean = true
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
+2
-2
@@ -28,9 +28,9 @@ class DefaultDiagnosticReporter(override val messageCollector: MessageCollector)
|
||||
interface MessageCollectorBasedReporter : DiagnosticMessageReporter {
|
||||
val messageCollector: MessageCollector
|
||||
|
||||
override fun report(diagnostic: Diagnostic, file: PsiFile, render: String) = messageCollector.report(
|
||||
override fun report(diagnostic: Diagnostic, file: PsiFile?, render: String) = messageCollector.report(
|
||||
AnalyzerWithCompilerReport.convertSeverity(diagnostic.severity),
|
||||
render,
|
||||
MessageUtil.psiFileToMessageLocation(file, file.name, DiagnosticUtils.getLineAndColumnRange(diagnostic))
|
||||
MessageUtil.psiFileToMessageLocation(file!!, file.name, DiagnosticUtils.getLineAndColumnRange(diagnostic))
|
||||
)
|
||||
}
|
||||
|
||||
+2
-2
@@ -28,9 +28,9 @@ class DefaultDiagnosticReporter(override val messageCollector: MessageCollector)
|
||||
interface MessageCollectorBasedReporter : DiagnosticMessageReporter {
|
||||
val messageCollector: MessageCollector
|
||||
|
||||
override fun report(diagnostic: Diagnostic, file: PsiFile, render: String) = messageCollector.report(
|
||||
override fun report(diagnostic: Diagnostic, file: PsiFile?, render: String) = messageCollector.report(
|
||||
AnalyzerWithCompilerReport.convertSeverity(diagnostic.severity),
|
||||
render,
|
||||
MessageUtil.psiFileToMessageLocation(file, file.name, DiagnosticUtils.getLineAndColumn(diagnostic))
|
||||
MessageUtil.psiFileToMessageLocation(file!!, file.name, DiagnosticUtils.getLineAndColumn(diagnostic))
|
||||
)
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,5 +20,5 @@ import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
|
||||
interface DiagnosticMessageReporter {
|
||||
fun report(diagnostic: Diagnostic, file: PsiFile, render: String)
|
||||
fun report(diagnostic: Diagnostic, file: PsiFile?, render: String)
|
||||
}
|
||||
|
||||
+1
-27
@@ -343,9 +343,7 @@ object KotlinToJVMBytecodeCompiler {
|
||||
firAnalyzerFacade.runResolution()
|
||||
val firDiagnostics = firAnalyzerFacade.runCheckers().values.flatten()
|
||||
AnalyzerWithCompilerReport.reportDiagnostics(
|
||||
SimpleDiagnostics(
|
||||
firDiagnostics.map { it.toRegularDiagnostic() }
|
||||
),
|
||||
SimpleDiagnostics(firDiagnostics),
|
||||
environment.messageCollector
|
||||
)
|
||||
performanceManager?.notifyAnalysisFinished()
|
||||
@@ -429,30 +427,6 @@ object KotlinToJVMBytecodeCompiler {
|
||||
return writeOutputs(environment, projectConfiguration, chunk, outputs, mainClassFqName)
|
||||
}
|
||||
|
||||
private fun FirDiagnostic<*>.toRegularDiagnostic(): Diagnostic {
|
||||
val psiSource = element as FirPsiSourceElement<*>
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
when (this) {
|
||||
is FirSimpleDiagnostic ->
|
||||
return SimpleDiagnostic(
|
||||
psiSource.psi, factory.psiDiagnosticFactory as DiagnosticFactory0<PsiElement>, severity
|
||||
)
|
||||
is FirDiagnosticWithParameters1<*, *> ->
|
||||
return DiagnosticWithParameters1(
|
||||
psiSource.psi, this.a, factory.psiDiagnosticFactory as DiagnosticFactory1<PsiElement, Any>, severity
|
||||
)
|
||||
is FirDiagnosticWithParameters2<*, *, *> ->
|
||||
return DiagnosticWithParameters2(
|
||||
psiSource.psi, this.a, this.b, factory.psiDiagnosticFactory as DiagnosticFactory2<PsiElement, Any, Any>, severity
|
||||
)
|
||||
is FirDiagnosticWithParameters3<*, *, *, *> ->
|
||||
return DiagnosticWithParameters3(
|
||||
psiSource.psi, this.a, this.b, this.c,
|
||||
factory.psiDiagnosticFactory as DiagnosticFactory3<PsiElement, Any, Any, Any>, severity
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getBuildFilePaths(buildFile: File?, sourceFilePaths: List<String>): List<String> =
|
||||
if (buildFile == null) sourceFilePaths
|
||||
else sourceFilePaths.map { path ->
|
||||
|
||||
Reference in New Issue
Block a user