[FE] Make DiagnosticFactory.name not null
This commit is contained in:
-16
@@ -1,16 +0,0 @@
|
||||
/*
|
||||
* 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("PackageDirectoryMismatch")
|
||||
|
||||
package org.jetbrains.kotlin.diagnostics
|
||||
|
||||
/**
|
||||
* This methods should me in `org.jetbrains.kotlin.diagnostics` package
|
||||
* because of `DiagnosticFactory.setName` is package private
|
||||
*/
|
||||
fun DiagnosticFactory<*>.initializeName(name: String) {
|
||||
this.name = name
|
||||
}
|
||||
+1
-1
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.fir.FirPsiSourceElement
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
|
||||
sealed class AbstractFirDiagnosticFactory<out E : FirSourceElement, D : FirDiagnostic<E>, P : PsiElement>(
|
||||
override var name: String?,
|
||||
override val name: String,
|
||||
override val severity: Severity,
|
||||
val positioningStrategy: SourceElementPositioningStrategy<P>,
|
||||
) : DiagnosticFactory<D>(name, severity) {
|
||||
|
||||
@@ -9,9 +9,15 @@ import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticRenderer
|
||||
import java.lang.IllegalArgumentException
|
||||
|
||||
abstract class DiagnosticFactory<D : UnboundDiagnostic> protected constructor(
|
||||
open var name: String?,
|
||||
private var _name: String?,
|
||||
open val severity: Severity
|
||||
) {
|
||||
open val name: String
|
||||
get() = _name!!
|
||||
|
||||
fun initializeName(name: String) {
|
||||
_name = name
|
||||
}
|
||||
|
||||
open var defaultRenderer: DiagnosticRenderer<D>? = null
|
||||
|
||||
@@ -29,7 +35,7 @@ abstract class DiagnosticFactory<D : UnboundDiagnostic> protected constructor(
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return name ?: "<Anonymous DiagnosticFactory>"
|
||||
return _name ?: "<Anonymous DiagnosticFactory>"
|
||||
}
|
||||
|
||||
companion object {
|
||||
@@ -45,4 +51,4 @@ abstract class DiagnosticFactory<D : UnboundDiagnostic> protected constructor(
|
||||
throw IllegalArgumentException("Factory mismatch: expected one of " + factories + " but was " + diagnostic.factory)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -34,9 +34,8 @@ class DebugInfoDiagnosticFactory0 private constructor(
|
||||
return DebugInfoDiagnostic(expression, this)
|
||||
}
|
||||
|
||||
override var name: String?
|
||||
override val name: String
|
||||
get() = "DEBUG_INFO_$privateName"
|
||||
set(_) {}
|
||||
|
||||
companion object {
|
||||
val SMARTCAST = DebugInfoDiagnosticFactory0("SMARTCAST", Severity.INFO)
|
||||
@@ -51,4 +50,4 @@ class DebugInfoDiagnosticFactory0 private constructor(
|
||||
val MISSING_UNRESOLVED = DebugInfoDiagnosticFactory0("MISSING_UNRESOLVED")
|
||||
val DYNAMIC = DebugInfoDiagnosticFactory0("DYNAMIC", Severity.INFO)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-3
@@ -21,9 +21,8 @@ class DebugInfoDiagnosticFactory1 : DiagnosticFactory1<PsiElement, String>,
|
||||
DebugInfoDiagnosticFactory {
|
||||
private val privateName: String
|
||||
|
||||
override var name: String?
|
||||
override val name: String
|
||||
get() = "DEBUG_INFO_$privateName"
|
||||
set(_) {}
|
||||
|
||||
override val withExplicitDefinitionOnly: Boolean
|
||||
|
||||
@@ -85,4 +84,4 @@ class DebugInfoDiagnosticFactory1 : DiagnosticFactory1<PsiElement, String>,
|
||||
return DebugInfoDiagnosticFactory1(name, severity, withExplicitDefinitionOnly)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-2
@@ -10,9 +10,8 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
|
||||
class SyntaxErrorDiagnosticFactory private constructor() : DiagnosticFactory<SyntaxErrorDiagnostic>(Severity.ERROR) {
|
||||
override var name: String?
|
||||
override val name: String
|
||||
get() = "SYNTAX"
|
||||
set(_) {}
|
||||
|
||||
companion object {
|
||||
val INSTANCE = SyntaxErrorDiagnosticFactory()
|
||||
|
||||
@@ -1199,7 +1199,7 @@ public interface Errors {
|
||||
Object value = field.get(null);
|
||||
if (value instanceof DiagnosticFactory) {
|
||||
DiagnosticFactory<?> factory = (DiagnosticFactory<?>)value;
|
||||
factory.setName(field.getName());
|
||||
factory.initializeName(field.getName());
|
||||
|
||||
factory.setDefaultRenderer((DiagnosticRenderer) diagnosticToRendererMap.get(factory));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user