[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
|
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||||
|
|
||||||
sealed class AbstractFirDiagnosticFactory<out E : FirSourceElement, D : FirDiagnostic<E>, P : PsiElement>(
|
sealed class AbstractFirDiagnosticFactory<out E : FirSourceElement, D : FirDiagnostic<E>, P : PsiElement>(
|
||||||
override var name: String?,
|
override val name: String,
|
||||||
override val severity: Severity,
|
override val severity: Severity,
|
||||||
val positioningStrategy: SourceElementPositioningStrategy<P>,
|
val positioningStrategy: SourceElementPositioningStrategy<P>,
|
||||||
) : DiagnosticFactory<D>(name, severity) {
|
) : DiagnosticFactory<D>(name, severity) {
|
||||||
|
|||||||
@@ -9,9 +9,15 @@ import org.jetbrains.kotlin.diagnostics.rendering.DiagnosticRenderer
|
|||||||
import java.lang.IllegalArgumentException
|
import java.lang.IllegalArgumentException
|
||||||
|
|
||||||
abstract class DiagnosticFactory<D : UnboundDiagnostic> protected constructor(
|
abstract class DiagnosticFactory<D : UnboundDiagnostic> protected constructor(
|
||||||
open var name: String?,
|
private var _name: String?,
|
||||||
open val severity: Severity
|
open val severity: Severity
|
||||||
) {
|
) {
|
||||||
|
open val name: String
|
||||||
|
get() = _name!!
|
||||||
|
|
||||||
|
fun initializeName(name: String) {
|
||||||
|
_name = name
|
||||||
|
}
|
||||||
|
|
||||||
open var defaultRenderer: DiagnosticRenderer<D>? = null
|
open var defaultRenderer: DiagnosticRenderer<D>? = null
|
||||||
|
|
||||||
@@ -29,7 +35,7 @@ abstract class DiagnosticFactory<D : UnboundDiagnostic> protected constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun toString(): String {
|
override fun toString(): String {
|
||||||
return name ?: "<Anonymous DiagnosticFactory>"
|
return _name ?: "<Anonymous DiagnosticFactory>"
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|||||||
+1
-2
@@ -34,9 +34,8 @@ class DebugInfoDiagnosticFactory0 private constructor(
|
|||||||
return DebugInfoDiagnostic(expression, this)
|
return DebugInfoDiagnostic(expression, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override var name: String?
|
override val name: String
|
||||||
get() = "DEBUG_INFO_$privateName"
|
get() = "DEBUG_INFO_$privateName"
|
||||||
set(_) {}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val SMARTCAST = DebugInfoDiagnosticFactory0("SMARTCAST", Severity.INFO)
|
val SMARTCAST = DebugInfoDiagnosticFactory0("SMARTCAST", Severity.INFO)
|
||||||
|
|||||||
+1
-2
@@ -21,9 +21,8 @@ class DebugInfoDiagnosticFactory1 : DiagnosticFactory1<PsiElement, String>,
|
|||||||
DebugInfoDiagnosticFactory {
|
DebugInfoDiagnosticFactory {
|
||||||
private val privateName: String
|
private val privateName: String
|
||||||
|
|
||||||
override var name: String?
|
override val name: String
|
||||||
get() = "DEBUG_INFO_$privateName"
|
get() = "DEBUG_INFO_$privateName"
|
||||||
set(_) {}
|
|
||||||
|
|
||||||
override val withExplicitDefinitionOnly: Boolean
|
override val withExplicitDefinitionOnly: Boolean
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -10,9 +10,8 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
|
|||||||
import org.jetbrains.kotlin.diagnostics.Severity
|
import org.jetbrains.kotlin.diagnostics.Severity
|
||||||
|
|
||||||
class SyntaxErrorDiagnosticFactory private constructor() : DiagnosticFactory<SyntaxErrorDiagnostic>(Severity.ERROR) {
|
class SyntaxErrorDiagnosticFactory private constructor() : DiagnosticFactory<SyntaxErrorDiagnostic>(Severity.ERROR) {
|
||||||
override var name: String?
|
override val name: String
|
||||||
get() = "SYNTAX"
|
get() = "SYNTAX"
|
||||||
set(_) {}
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val INSTANCE = SyntaxErrorDiagnosticFactory()
|
val INSTANCE = SyntaxErrorDiagnosticFactory()
|
||||||
|
|||||||
@@ -1199,7 +1199,7 @@ public interface Errors {
|
|||||||
Object value = field.get(null);
|
Object value = field.get(null);
|
||||||
if (value instanceof DiagnosticFactory) {
|
if (value instanceof DiagnosticFactory) {
|
||||||
DiagnosticFactory<?> factory = (DiagnosticFactory<?>)value;
|
DiagnosticFactory<?> factory = (DiagnosticFactory<?>)value;
|
||||||
factory.setName(field.getName());
|
factory.initializeName(field.getName());
|
||||||
|
|
||||||
factory.setDefaultRenderer((DiagnosticRenderer) diagnosticToRendererMap.get(factory));
|
factory.setDefaultRenderer((DiagnosticRenderer) diagnosticToRendererMap.get(factory));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user