org.jetbrains.kotlin.diagnostics.KtDiagnosticReportHelpers.kt Maven / Gradle / Ivy
/*
* Copyright 2010-2021 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:OptIn(InternalDiagnosticFactoryMethod::class)
package org.jetbrains.kotlin.diagnostics
import org.jetbrains.kotlin.AbstractKtSourceElement
fun DiagnosticReporter.reportOn(
source: AbstractKtSourceElement?,
factory: KtDiagnosticFactory0,
context: DiagnosticContext,
positioningStrategy: AbstractSourceElementPositioningStrategy? = null
) {
report(factory.on(source.requireNotNull(), positioningStrategy), context)
}
fun DiagnosticReporter.reportOn(
source: AbstractKtSourceElement?,
factory: KtDiagnosticFactory1,
a: A,
context: DiagnosticContext,
positioningStrategy: AbstractSourceElementPositioningStrategy? = null
) {
report(factory.on(source.requireNotNull(), a, positioningStrategy), context)
}
fun DiagnosticReporter.reportOn(
source: AbstractKtSourceElement?,
factory: KtDiagnosticFactory2,
a: A,
b: B,
context: DiagnosticContext,
positioningStrategy: AbstractSourceElementPositioningStrategy? = null
) {
report(factory.on(source.requireNotNull(), a, b, positioningStrategy), context)
}
fun DiagnosticReporter.reportOn(
source: AbstractKtSourceElement?,
factory: KtDiagnosticFactory3,
a: A,
b: B,
c: C,
context: DiagnosticContext,
positioningStrategy: AbstractSourceElementPositioningStrategy? = null
) {
report(factory.on(source.requireNotNull(), a, b, c, positioningStrategy), context)
}
fun DiagnosticReporter.reportOn(
source: AbstractKtSourceElement?,
factory: KtDiagnosticFactory4,
a: A,
b: B,
c: C,
d: D,
context: DiagnosticContext,
positioningStrategy: AbstractSourceElementPositioningStrategy? = null
) {
report(factory.on(source.requireNotNull(), a, b, c, d, positioningStrategy), context)
}
fun AbstractKtSourceElement?.requireNotNull(): AbstractKtSourceElement =
requireNotNull(this) { "source must not be null" }
fun DiagnosticReporter.reportOn(
source: AbstractKtSourceElement?,
factory: KtDiagnosticFactoryForDeprecation0,
context: DiagnosticContext,
positioningStrategy: AbstractSourceElementPositioningStrategy? = null
) {
reportOn(source, factory.chooseFactory(context), context, positioningStrategy)
}
fun DiagnosticReporter.reportOn(
source: AbstractKtSourceElement?,
factory: KtDiagnosticFactoryForDeprecation1,
a: A,
context: DiagnosticContext,
positioningStrategy: AbstractSourceElementPositioningStrategy? = null
) {
reportOn(source, factory.chooseFactory(context), a, context, positioningStrategy)
}
fun DiagnosticReporter.reportOn(
source: AbstractKtSourceElement?,
factory: KtDiagnosticFactoryForDeprecation2,
a: A,
b: B,
context: DiagnosticContext,
positioningStrategy: AbstractSourceElementPositioningStrategy? = null
) {
reportOn(source, factory.chooseFactory(context), a, b, context, positioningStrategy)
}
fun DiagnosticReporter.reportOn(
source: AbstractKtSourceElement?,
factory: KtDiagnosticFactoryForDeprecation3,
a: A,
b: B,
c: C,
context: DiagnosticContext,
positioningStrategy: AbstractSourceElementPositioningStrategy? = null
) {
reportOn(source, factory.chooseFactory(context), a, b, c, context, positioningStrategy)
}
fun DiagnosticReporter.reportOn(
source: AbstractKtSourceElement?,
factory: KtDiagnosticFactoryForDeprecation4,
a: A,
b: B,
c: C,
d: D,
context: DiagnosticContext,
positioningStrategy: AbstractSourceElementPositioningStrategy? = null
) {
reportOn(source, factory.chooseFactory(context), a, b, c, d, context, positioningStrategy)
}
fun KtDiagnosticFactoryForDeprecation.chooseFactory(context: DiagnosticContext): F {
return if (context.languageVersionSettings.supportsFeature(deprecatingFeature)) {
errorFactory
} else {
warningFactory
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy