All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jetbrains.kotlin.diagnostics.KtDiagnosticFactoryDsl.kt Maven / Gradle / Ivy

There is a newer version: 2.1.20-Beta1
Show newest version
/*
 * 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.
 */

package org.jetbrains.kotlin.diagnostics

import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.config.LanguageFeature
import kotlin.properties.ReadOnlyProperty
import kotlin.reflect.KClass
import kotlin.reflect.KProperty

inline fun  warning0(
    positioningStrategy: AbstractSourceElementPositioningStrategy = AbstractSourceElementPositioningStrategy.DEFAULT
): DiagnosticFactory0DelegateProvider {
    return DiagnosticFactory0DelegateProvider(Severity.WARNING, positioningStrategy, P::class)
}

inline fun  warning1(
    positioningStrategy: AbstractSourceElementPositioningStrategy = AbstractSourceElementPositioningStrategy.DEFAULT
): DiagnosticFactory1DelegateProvider {
    return DiagnosticFactory1DelegateProvider(Severity.WARNING, positioningStrategy, P::class)
}

inline fun  warning2(
    positioningStrategy: AbstractSourceElementPositioningStrategy = AbstractSourceElementPositioningStrategy.DEFAULT
): DiagnosticFactory2DelegateProvider {
    return DiagnosticFactory2DelegateProvider(Severity.WARNING, positioningStrategy, P::class)
}

inline fun  warning3(
    positioningStrategy: AbstractSourceElementPositioningStrategy = AbstractSourceElementPositioningStrategy.DEFAULT
): DiagnosticFactory3DelegateProvider {
    return DiagnosticFactory3DelegateProvider(Severity.WARNING, positioningStrategy, P::class)
}

inline fun  warning4(
    positioningStrategy: AbstractSourceElementPositioningStrategy = AbstractSourceElementPositioningStrategy.DEFAULT
): DiagnosticFactory4DelegateProvider {
    return DiagnosticFactory4DelegateProvider(Severity.WARNING, positioningStrategy, P::class)
}

inline fun  error0(
    positioningStrategy: AbstractSourceElementPositioningStrategy = AbstractSourceElementPositioningStrategy.DEFAULT
): DiagnosticFactory0DelegateProvider {
    return DiagnosticFactory0DelegateProvider(Severity.ERROR, positioningStrategy, P::class)
}

inline fun  error1(
    positioningStrategy: AbstractSourceElementPositioningStrategy = AbstractSourceElementPositioningStrategy.DEFAULT
): DiagnosticFactory1DelegateProvider {
    return DiagnosticFactory1DelegateProvider(Severity.ERROR, positioningStrategy, P::class)
}

inline fun  error2(
    positioningStrategy: AbstractSourceElementPositioningStrategy = AbstractSourceElementPositioningStrategy.DEFAULT
): DiagnosticFactory2DelegateProvider {
    return DiagnosticFactory2DelegateProvider(Severity.ERROR, positioningStrategy, P::class)
}

inline fun  error3(
    positioningStrategy: AbstractSourceElementPositioningStrategy = AbstractSourceElementPositioningStrategy.DEFAULT
): DiagnosticFactory3DelegateProvider {
    return DiagnosticFactory3DelegateProvider(Severity.ERROR, positioningStrategy, P::class)
}

inline fun  error4(
    positioningStrategy: AbstractSourceElementPositioningStrategy = AbstractSourceElementPositioningStrategy.DEFAULT
): DiagnosticFactory4DelegateProvider {
    return DiagnosticFactory4DelegateProvider(Severity.ERROR, positioningStrategy, P::class)
}

inline fun  deprecationError0(
    featureForError: LanguageFeature,
    positioningStrategy: AbstractSourceElementPositioningStrategy = AbstractSourceElementPositioningStrategy.DEFAULT
): DeprecationDiagnosticFactory0DelegateProvider {
    return DeprecationDiagnosticFactory0DelegateProvider(featureForError, positioningStrategy, P::class)
}

inline fun  deprecationError1(
    featureForError: LanguageFeature,
    positioningStrategy: AbstractSourceElementPositioningStrategy = AbstractSourceElementPositioningStrategy.DEFAULT
): DeprecationDiagnosticFactory1DelegateProvider {
    return DeprecationDiagnosticFactory1DelegateProvider(featureForError, positioningStrategy, P::class)
}

inline fun  deprecationError2(
    featureForError: LanguageFeature,
    positioningStrategy: AbstractSourceElementPositioningStrategy = AbstractSourceElementPositioningStrategy.DEFAULT
): DeprecationDiagnosticFactory2DelegateProvider {
    return DeprecationDiagnosticFactory2DelegateProvider(featureForError, positioningStrategy, P::class)
}

inline fun  deprecationError3(
    featureForError: LanguageFeature,
    positioningStrategy: AbstractSourceElementPositioningStrategy = AbstractSourceElementPositioningStrategy.DEFAULT
): DeprecationDiagnosticFactory3DelegateProvider {
    return DeprecationDiagnosticFactory3DelegateProvider(featureForError, positioningStrategy, P::class)
}

inline fun  deprecationError4(
    featureForError: LanguageFeature,
    positioningStrategy: AbstractSourceElementPositioningStrategy = AbstractSourceElementPositioningStrategy.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))
    }
}

private const val WARNING = "_WARNING"
private const val ERROR = "_ERROR"

class DeprecationDiagnosticFactory0DelegateProvider(
    private val featureForError: LanguageFeature,
    private val positioningStrategy: AbstractSourceElementPositioningStrategy,
    private val psiType: KClass<*>
) {
    operator fun provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty {
        val errorFactory = KtDiagnosticFactory0("${prop.name}$ERROR", Severity.ERROR, positioningStrategy, psiType)
        val warningFactory = KtDiagnosticFactory0("${prop.name}$WARNING", Severity.WARNING, positioningStrategy, psiType)
        return DummyDelegate(KtDiagnosticFactoryForDeprecation0(featureForError, warningFactory, errorFactory))
    }
}

class DeprecationDiagnosticFactory1DelegateProvider(
    private val featureForError: LanguageFeature,
    private val positioningStrategy: AbstractSourceElementPositioningStrategy,
    private val psiType: KClass<*>
) {
    operator fun provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty> {
        val errorFactory = KtDiagnosticFactory1("${prop.name}$ERROR", Severity.ERROR, positioningStrategy, psiType)
        val warningFactory = KtDiagnosticFactory1("${prop.name}$WARNING", Severity.WARNING, positioningStrategy, psiType)
        return DummyDelegate(KtDiagnosticFactoryForDeprecation1(featureForError, warningFactory, errorFactory))
    }
}

class DeprecationDiagnosticFactory2DelegateProvider(
    private val featureForError: LanguageFeature,
    private val positioningStrategy: AbstractSourceElementPositioningStrategy,
    private val psiType: KClass<*>
) {
    operator fun provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty> {
        val errorFactory = KtDiagnosticFactory2("${prop.name}$ERROR", Severity.ERROR, positioningStrategy, psiType)
        val warningFactory = KtDiagnosticFactory2("${prop.name}$WARNING", Severity.WARNING, positioningStrategy, psiType)
        return DummyDelegate(KtDiagnosticFactoryForDeprecation2(featureForError, warningFactory, errorFactory))
    }
}

class DeprecationDiagnosticFactory3DelegateProvider(
    private val featureForError: LanguageFeature,
    private val positioningStrategy: AbstractSourceElementPositioningStrategy,
    private val psiType: KClass<*>
) {
    operator fun provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty> {
        val errorFactory = KtDiagnosticFactory3("${prop.name}$ERROR", Severity.ERROR, positioningStrategy, psiType)
        val warningFactory = KtDiagnosticFactory3("${prop.name}$WARNING", Severity.WARNING, positioningStrategy, psiType)
        return DummyDelegate(KtDiagnosticFactoryForDeprecation3(featureForError, warningFactory, errorFactory))
    }
}

class DeprecationDiagnosticFactory4DelegateProvider(
    private val featureForError: LanguageFeature,
    private val positioningStrategy: AbstractSourceElementPositioningStrategy,
    private val psiType: KClass<*>
) {
    operator fun provideDelegate(thisRef: Any?, prop: KProperty<*>): ReadOnlyProperty> {
        val errorFactory = KtDiagnosticFactory4("${prop.name}$ERROR", Severity.ERROR, positioningStrategy, psiType)
        val warningFactory = KtDiagnosticFactory4("${prop.name}$WARNING", Severity.WARNING, positioningStrategy, psiType)
        return DummyDelegate(KtDiagnosticFactoryForDeprecation4(featureForError, warningFactory, errorFactory))
    }
}


private class DummyDelegate(val value: T) : ReadOnlyProperty {
    override fun getValue(thisRef: Any?, property: KProperty<*>): T {
        return value
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy