org.jetbrains.kotlin.diagnostics.KtDiagnosticFactoryDsl.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-compiler-embeddable Show documentation
Show all versions of kotlin-compiler-embeddable Show documentation
the Kotlin compiler embeddable
/*
* Copyright 2010-2023 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.
*/
package org.jetbrains.kotlin.diagnostics
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.utils.DummyDelegate
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KClass
import kotlin.reflect.KProperty
inline fun warning0(
positioningStrategy: AbstractSourceElementPositioningStrategy = SourceElementPositioningStrategies.DEFAULT
): DiagnosticFactory0DelegateProvider {
return DiagnosticFactory0DelegateProvider(Severity.WARNING, positioningStrategy, P::class)
}
inline fun warning1(
positioningStrategy: AbstractSourceElementPositioningStrategy = SourceElementPositioningStrategies.DEFAULT
): DiagnosticFactory1DelegateProvider {
return DiagnosticFactory1DelegateProvider(Severity.WARNING, positioningStrategy, P::class)
}
inline fun warning2(
positioningStrategy: AbstractSourceElementPositioningStrategy = SourceElementPositioningStrategies.DEFAULT
): DiagnosticFactory2DelegateProvider {
return DiagnosticFactory2DelegateProvider(Severity.WARNING, positioningStrategy, P::class)
}
inline fun warning3(
positioningStrategy: AbstractSourceElementPositioningStrategy = SourceElementPositioningStrategies.DEFAULT
): DiagnosticFactory3DelegateProvider {
return DiagnosticFactory3DelegateProvider(Severity.WARNING, positioningStrategy, P::class)
}
inline fun warning4(
positioningStrategy: AbstractSourceElementPositioningStrategy = SourceElementPositioningStrategies.DEFAULT
): DiagnosticFactory4DelegateProvider {
return DiagnosticFactory4DelegateProvider(Severity.WARNING, positioningStrategy, P::class)
}
inline fun error0(
positioningStrategy: AbstractSourceElementPositioningStrategy = SourceElementPositioningStrategies.DEFAULT
): DiagnosticFactory0DelegateProvider {
return DiagnosticFactory0DelegateProvider(Severity.ERROR, positioningStrategy, P::class)
}
inline fun error1(
positioningStrategy: AbstractSourceElementPositioningStrategy = SourceElementPositioningStrategies.DEFAULT
): DiagnosticFactory1DelegateProvider {
return DiagnosticFactory1DelegateProvider(Severity.ERROR, positioningStrategy, P::class)
}
inline fun error2(
positioningStrategy: AbstractSourceElementPositioningStrategy = SourceElementPositioningStrategies.DEFAULT
): DiagnosticFactory2DelegateProvider {
return DiagnosticFactory2DelegateProvider(Severity.ERROR, positioningStrategy, P::class)
}
inline fun error3(
positioningStrategy: AbstractSourceElementPositioningStrategy = SourceElementPositioningStrategies.DEFAULT
): DiagnosticFactory3DelegateProvider {
return DiagnosticFactory3DelegateProvider(Severity.ERROR, positioningStrategy, P::class)
}
inline fun error4(
positioningStrategy: AbstractSourceElementPositioningStrategy = SourceElementPositioningStrategies.DEFAULT
): DiagnosticFactory4DelegateProvider {
return DiagnosticFactory4DelegateProvider(Severity.ERROR, positioningStrategy, P::class)
}
inline fun deprecationError0(
featureForError: LanguageFeature,
positioningStrategy: AbstractSourceElementPositioningStrategy = SourceElementPositioningStrategies.DEFAULT
): DeprecationDiagnosticFactory0DelegateProvider {
return DeprecationDiagnosticFactory0DelegateProvider(featureForError, positioningStrategy, P::class)
}
inline fun deprecationError1(
featureForError: LanguageFeature,
positioningStrategy: AbstractSourceElementPositioningStrategy = SourceElementPositioningStrategies.DEFAULT
): DeprecationDiagnosticFactory1DelegateProvider {
return DeprecationDiagnosticFactory1DelegateProvider(featureForError, positioningStrategy, P::class)
}
inline fun deprecationError2(
featureForError: LanguageFeature,
positioningStrategy: AbstractSourceElementPositioningStrategy = SourceElementPositioningStrategies.DEFAULT
): DeprecationDiagnosticFactory2DelegateProvider {
return DeprecationDiagnosticFactory2DelegateProvider(featureForError, positioningStrategy, P::class)
}
inline fun deprecationError3(
featureForError: LanguageFeature,
positioningStrategy: AbstractSourceElementPositioningStrategy = SourceElementPositioningStrategies.DEFAULT
): DeprecationDiagnosticFactory3DelegateProvider {
return DeprecationDiagnosticFactory3DelegateProvider(featureForError, positioningStrategy, P::class)
}
inline fun deprecationError4(
featureForError: LanguageFeature,
positioningStrategy: AbstractSourceElementPositioningStrategy = SourceElementPositioningStrategies.DEFAULT
): DeprecationDiagnosticFactory4DelegateProvider {
return DeprecationDiagnosticFactory4DelegateProvider(featureForError, positioningStrategy, P::class)
}
// ------------------------------ Providers ------------------------------
class DiagnosticFactory0DelegateProvider(
private val severity: Severity,
private val positioningStrategy: AbstractSourceElementPositioningStrategy,
private val psiType: KClass<*>
) {
operator fun provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty {
return DummyDelegate(KtDiagnosticFactory0(prop.name, severity, positioningStrategy, psiType))
}
}
class DiagnosticFactory1DelegateProvider(
private val severity: Severity,
private val positioningStrategy: AbstractSourceElementPositioningStrategy,
private val psiType: KClass<*>
) {
operator fun provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty> {
return DummyDelegate(KtDiagnosticFactory1(prop.name, severity, positioningStrategy, psiType))
}
}
class DiagnosticFactory2DelegateProvider(
private val severity: Severity,
private val positioningStrategy: AbstractSourceElementPositioningStrategy,
private val psiType: KClass<*>
) {
operator fun provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty> {
return DummyDelegate(KtDiagnosticFactory2(prop.name, severity, positioningStrategy, psiType))
}
}
class DiagnosticFactory3DelegateProvider(
private val severity: Severity,
private val positioningStrategy: AbstractSourceElementPositioningStrategy,
private val psiType: KClass<*>
) {
operator fun provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty> {
return DummyDelegate(KtDiagnosticFactory3(prop.name, severity, positioningStrategy, psiType))
}
}
class DiagnosticFactory4DelegateProvider(
private val severity: Severity,
private val positioningStrategy: AbstractSourceElementPositioningStrategy,
private val psiType: KClass<*>
) {
operator fun provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty> {
return DummyDelegate(KtDiagnosticFactory4(prop.name, severity, positioningStrategy, psiType))
}
}
class DeprecationDiagnosticFactory0DelegateProvider(
private val featureForError: LanguageFeature,
private val positioningStrategy: AbstractSourceElementPositioningStrategy,
private val psiType: KClass<*>
) {
operator fun provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty {
return DummyDelegate(KtDiagnosticFactoryForDeprecation0(prop.name, featureForError, positioningStrategy, psiType))
}
}
class DeprecationDiagnosticFactory1DelegateProvider(
private val featureForError: LanguageFeature,
private val positioningStrategy: AbstractSourceElementPositioningStrategy,
private val psiType: KClass<*>
) {
operator fun provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty> {
return DummyDelegate(KtDiagnosticFactoryForDeprecation1(prop.name, featureForError, positioningStrategy, psiType))
}
}
class DeprecationDiagnosticFactory2DelegateProvider(
private val featureForError: LanguageFeature,
private val positioningStrategy: AbstractSourceElementPositioningStrategy,
private val psiType: KClass<*>
) {
operator fun provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty> {
return DummyDelegate(KtDiagnosticFactoryForDeprecation2(prop.name, featureForError, positioningStrategy, psiType))
}
}
class DeprecationDiagnosticFactory3DelegateProvider(
private val featureForError: LanguageFeature,
private val positioningStrategy: AbstractSourceElementPositioningStrategy,
private val psiType: KClass<*>
) {
operator fun provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty> {
return DummyDelegate(KtDiagnosticFactoryForDeprecation3(prop.name, featureForError, positioningStrategy, psiType))
}
}
class DeprecationDiagnosticFactory4DelegateProvider(
private val featureForError: LanguageFeature,
private val positioningStrategy: AbstractSourceElementPositioningStrategy,
private val psiType: KClass<*>
) {
operator fun provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty> {
return DummyDelegate(KtDiagnosticFactoryForDeprecation4(prop.name, featureForError, positioningStrategy, psiType))
}
}