diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/Printer.java b/core/util.runtime/src/org/jetbrains/kotlin/utils/Printer.java index ccfb3ed5f57..2ac97fc6f35 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/utils/Printer.java +++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/Printer.java @@ -177,4 +177,12 @@ public class Printer { public String toString() { return out.toString(); } + + public int getCurrentIndentLengthInUnits() { + return indent.length() / indentUnit.length(); + } + + public int getIndentUnitLength() { + return indentUnit.length(); + } } diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/highlighter/KotlinHighLevelDiagnosticHighlightingPass.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/highlighter/KotlinHighLevelDiagnosticHighlightingPass.kt index 5767188e69a..4e4eb5b20e8 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/highlighter/KotlinHighLevelDiagnosticHighlightingPass.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/fir/highlighter/KotlinHighLevelDiagnosticHighlightingPass.kt @@ -17,18 +17,11 @@ import com.intellij.openapi.editor.Document import com.intellij.openapi.editor.Editor import com.intellij.openapi.progress.ProgressIndicator import com.intellij.openapi.project.Project -import com.intellij.psi.PsiElement -import com.intellij.psi.PsiElementVisitor import com.intellij.psi.PsiFile -import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.idea.frontend.api.analyze import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnostic -import org.jetbrains.kotlin.idea.frontend.api.diagnostics.getMessageWithFactoryName -import org.jetbrains.kotlin.idea.highlighter.Diagnostic2Annotation -import org.jetbrains.kotlin.idea.highlighter.IdeErrorMessages -import org.jetbrains.kotlin.psi.KtElement +import org.jetbrains.kotlin.idea.frontend.api.diagnostics.getDefaultMessageWithFactoryName import org.jetbrains.kotlin.psi.KtFile -import org.jetbrains.kotlin.psi.KtVisitorVoid class KotlinHighLevelDiagnosticHighlightingPass( private val ktFile: KtFile, @@ -38,7 +31,6 @@ class KotlinHighLevelDiagnosticHighlightingPass( override fun doCollectInformation(progress: ProgressIndicator) = analyze(ktFile) { ktFile.collectDiagnosticsForFile().forEach { diagnostic -> - if (!diagnostic.isValid) return@forEach diagnostic.textRanges.forEach { range -> HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR/*TODO*/) .descriptionAndTooltip(diagnostic.getMessageToRender()) @@ -50,9 +42,14 @@ class KotlinHighLevelDiagnosticHighlightingPass( } private fun KtDiagnostic.getMessageToRender(): String = - if (ApplicationManager.getApplication().isInternal || ApplicationManager.getApplication().isUnitTestMode) - getMessageWithFactoryName() - else message + if (isInternalOrUnitTestMode()) + getDefaultMessageWithFactoryName() + else defaultMessage + + private fun isInternalOrUnitTestMode(): Boolean { + val application = ApplicationManager.getApplication() + return application.isInternal || application.isUnitTestMode + } override fun doApplyInformationToEditor() { diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt index 7e0dc55132c..81957c512f1 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/KtAnalysisSession.kt @@ -9,6 +9,7 @@ import com.intellij.psi.PsiElement import org.jetbrains.kotlin.idea.frontend.api.calls.KtCall import org.jetbrains.kotlin.idea.frontend.api.components.* import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnostic +import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnosticWithPsi import org.jetbrains.kotlin.idea.frontend.api.scopes.* import org.jetbrains.kotlin.idea.frontend.api.symbols.* import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.KtSymbolWithDeclarations @@ -84,7 +85,7 @@ abstract class KtAnalysisSession(final override val token: ValidityToken) : Vali fun KtElement.getDiagnostics(): Collection = diagnosticProvider.getDiagnosticsForElement(this) - fun KtFile.collectDiagnosticsForFile(): Collection = diagnosticProvider.collectDiagnosticsForFile(this) + fun KtFile.collectDiagnosticsForFile(): Collection = diagnosticProvider.collectDiagnosticsForFile(this) fun KtSymbolWithKind.getContainingSymbol(): KtSymbolWithKind? = containingDeclarationProvider.getContainingDeclaration(this) diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtDiagnosticProvider.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtDiagnosticProvider.kt index 692c20eae66..8382ea505f8 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtDiagnosticProvider.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/components/KtDiagnosticProvider.kt @@ -5,11 +5,11 @@ package org.jetbrains.kotlin.idea.frontend.api.components -import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnostic +import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnosticWithPsi import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtFile abstract class KtDiagnosticProvider : KtAnalysisSessionComponent() { - abstract fun getDiagnosticsForElement(element: KtElement): Collection - abstract fun collectDiagnosticsForFile(ktFile: KtFile): Collection + abstract fun getDiagnosticsForElement(element: KtElement): Collection + abstract fun collectDiagnosticsForFile(ktFile: KtFile): Collection } diff --git a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/diagnostics/KtDiagnostic.kt b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/diagnostics/KtDiagnostic.kt index a666b282908..1eb30e9f077 100644 --- a/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/diagnostics/KtDiagnostic.kt +++ b/idea/idea-frontend-api/src/org/jetbrains/kotlin/idea/frontend/api/diagnostics/KtDiagnostic.kt @@ -6,20 +6,28 @@ package org.jetbrains.kotlin.idea.frontend.api.diagnostics import com.intellij.openapi.util.TextRange +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.idea.frontend.api.ValidityToken +import org.jetbrains.kotlin.idea.frontend.api.ValidityTokenOwner +import kotlin.reflect.KClass -interface KtDiagnostic { +interface KtDiagnostic : ValidityTokenOwner { val factoryName: String? - val message: String - val textRanges: Collection - val isValid: Boolean get() = true + val defaultMessage: String } -fun KtDiagnostic.getMessageWithFactoryName(): String = - if (factoryName == null) message - else "[$factoryName] $message" +interface KtDiagnosticWithPsi : KtDiagnostic { + val psi: PsiElement + val textRanges: Collection + val diagnosticClass: KClass +} -data class KtSimpleDiagnostic( +class KtSimpleDiagnostic( override val factoryName: String?, - override val message: String, - override val textRanges: Collection, -) : KtDiagnostic \ No newline at end of file + override val defaultMessage: String, + override val token: ValidityToken, +) : KtDiagnostic + +fun KtDiagnostic.getDefaultMessageWithFactoryName(): String = + if (factoryName == null) defaultMessage + else "[$factoryName] $defaultMessage" \ No newline at end of file diff --git a/idea/idea-frontend-fir/build.gradle.kts b/idea/idea-frontend-fir/build.gradle.kts index b38c1a826f8..56c00c3448c 100644 --- a/idea/idea-frontend-fir/build.gradle.kts +++ b/idea/idea-frontend-fir/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.ideaExt.idea + plugins { kotlin("jvm") id("jps-compatible") @@ -54,3 +56,29 @@ projectTest { testsJar() +val generatorClasspath by configurations.creating + +dependencies { + generatorClasspath(project("idea-frontend-fir-generator")) +} + +val generateCode by tasks.registering(NoDebugJavaExec::class) { + val generatorRoot = "$projectDir/idea/idea-frontend-fir/idea-frontend-fir-generator/src/" + + val generatorConfigurationFiles = fileTree(generatorRoot) { + include("**/*.kt") + } + + inputs.files(generatorConfigurationFiles) + + workingDir = rootDir + classpath = generatorClasspath + main = "org.jetbrains.kotlin.idea.frontend.api.fir.generator.MainKt" + systemProperties["line.separator"] = "\n" +} + +val compileKotlin by tasks + +compileKotlin.dependsOn(generateCode) + + diff --git a/idea/idea-frontend-fir/idea-frontend-fir-generator/build.gradle.kts b/idea/idea-frontend-fir/idea-frontend-fir-generator/build.gradle.kts new file mode 100644 index 00000000000..0b73e6b7c8f --- /dev/null +++ b/idea/idea-frontend-fir/idea-frontend-fir-generator/build.gradle.kts @@ -0,0 +1,43 @@ +plugins { + kotlin("jvm") + id("jps-compatible") + application +} + +dependencies { + implementation(project(":compiler:fir:tree")) + implementation(project(":compiler:fir:tree:tree-generator")) + implementation(project(":compiler:fir:checkers:checkers-component-generator")) + implementation(project(":idea:idea-frontend-api")) + + implementation(project(":kotlin-reflect")) + implementation(project(":kotlin-reflect-api")) + + /* + We do not need guava in the generator, but because of a bug in the IJ project importing, we need to have a dependency on intellijCoreDep + the same as it is in `:fir:tree:tree-generator` module to the project be imported correctly + */ + compileOnly(intellijCoreDep()) { includeJars("intellij-core", "guava", rootProject = rootProject) } + + implementation(project(":compiler:psi")) +} + +val writeCopyright by task { + outputFile = file("$buildDir/copyright/notice.txt") + commented = true +} + +application { + mainClassName = "org.jetbrains.kotlin.idea.frontend.api.fir.generator.MainKt" +} + +val processResources by tasks +processResources.dependsOn(writeCopyright) + +sourceSets { + "main" { + projectDefault() + resources.srcDir("$buildDir/copyright") + } + "test" {} +} diff --git a/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/DiagnosticClassGenerator.kt b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/DiagnosticClassGenerator.kt new file mode 100644 index 00000000000..e24476eae0a --- /dev/null +++ b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/DiagnosticClassGenerator.kt @@ -0,0 +1,22 @@ +/* + * 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.idea.frontend.api.fir.generator + +import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.DiagnosticList +import org.jetbrains.kotlin.fir.checkers.generator.getGenerationPath +import org.jetbrains.kotlin.idea.frontend.api.fir.generator.rendererrs.FirDiagnosticToKtDiagnosticConverterRenderer +import org.jetbrains.kotlin.idea.frontend.api.fir.generator.rendererrs.KtDiagnosticClassImplementationRenderer +import org.jetbrains.kotlin.idea.frontend.api.fir.generator.rendererrs.KtDiagnosticClassRenderer +import java.nio.file.Path + +object DiagnosticClassGenerator { + fun generate(rootPath: Path, diagnosticList: DiagnosticList, packageName: String) { + val path = getGenerationPath(rootPath.toFile(), packageName) + KtDiagnosticClassRenderer.render(path.resolve("KtFirDiagnostics.kt"), diagnosticList, packageName) + KtDiagnosticClassImplementationRenderer.render(path.resolve("KtFirDiagnosticsImpl.kt"), diagnosticList, packageName) + FirDiagnosticToKtDiagnosticConverterRenderer.render(path.resolve("KtFirDataClassConverters.kt"), diagnosticList, packageName) + } +} \ No newline at end of file diff --git a/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/HLDiagnostic.kt b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/HLDiagnostic.kt new file mode 100644 index 00000000000..8e84a070e59 --- /dev/null +++ b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/HLDiagnostic.kt @@ -0,0 +1,28 @@ +/* + * 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.idea.frontend.api.fir.generator + +import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.Diagnostic +import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.DiagnosticParameter +import kotlin.reflect.KType + +data class HLDiagnostic( + val original: Diagnostic, + val className: String, + val implClassName: String, + val parameters: List, +) + +data class HLDiagnosticList(val diagnostics: List) + +data class HLDiagnosticParameter( + val original: DiagnosticParameter, + val name: String, + val type: KType, + val originalParameterName: String, + val conversion: HLParameterConversion, + val importsToAdd: List +) \ No newline at end of file diff --git a/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/HLDiagnosticConverter.kt b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/HLDiagnosticConverter.kt new file mode 100644 index 00000000000..7420975e57a --- /dev/null +++ b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/HLDiagnosticConverter.kt @@ -0,0 +1,161 @@ +/* + * 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.idea.frontend.api.fir.generator + +import org.jetbrains.kotlin.contracts.description.EventOccurrencesRange +import org.jetbrains.kotlin.descriptors.Visibility +import org.jetbrains.kotlin.fir.FirEffectiveVisibility +import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.Diagnostic +import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.DiagnosticList +import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.DiagnosticParameter +import org.jetbrains.kotlin.fir.declarations.FirClass +import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration +import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol +import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol +import org.jetbrains.kotlin.fir.types.ConeKotlinType +import org.jetbrains.kotlin.fir.types.FirTypeRef +import org.jetbrains.kotlin.idea.frontend.api.types.KtType +import org.jetbrains.kotlin.lexer.KtModifierKeywordToken +import org.jetbrains.kotlin.name.Name +import kotlin.reflect.KClass +import kotlin.reflect.KType +import kotlin.reflect.full.createType +import kotlin.reflect.full.isSubclassOf +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.idea.frontend.api.symbols.* + +object HLDiagnosticConverter { + fun convert(diagnosticList: DiagnosticList): HLDiagnosticList = + HLDiagnosticList(diagnosticList.diagnostics.map(::convertDiagnostic)) + + private fun convertDiagnostic(diagnostic: Diagnostic): HLDiagnostic = + HLDiagnostic( + original = diagnostic, + className = diagnostic.getHLDiagnosticClassName(), + implClassName = diagnostic.getHLDiagnosticImplClassName(), + parameters = diagnostic.parameters.mapIndexed(::convertParameter) + ) + + private fun convertParameter(index: Int, diagnosticParameter: DiagnosticParameter): HLDiagnosticParameter { + val conversion = FirToKtConversionCreator.creatConversion(diagnosticParameter.type) + val convertedType = conversion.convertType(diagnosticParameter.type) + return HLDiagnosticParameter( + name = diagnosticParameter.name, + conversion = conversion, + originalParameterName = ('a' + index).toString(), + type = convertedType, + original = diagnosticParameter, + importsToAdd = conversion.importsToAdd + ) + } + + private fun Diagnostic.getHLDiagnosticClassName() = + name.toLowerCase() + .split('_') + .joinToString(separator = "") { + it.capitalize() + } + + private fun Diagnostic.getHLDiagnosticImplClassName() = + "${getHLDiagnosticClassName()}Impl" + +} + + +private object FirToKtConversionCreator { + fun creatConversion(type: KType): HLParameterConversion { + val kClass = type.classifier as KClass<*> + return tryMapAllowedType(kClass) + ?: tryMapPsiElementType(type, kClass) + ?: tryMapFirTypeToKtType(kClass) + ?: tryMapCollectionType(type, kClass) + ?: error("Unsupported type $type, consider add corresponding mapping") + } + + private fun tryMapFirTypeToKtType(kClass: KClass<*>): HLParameterConversion? { + return typeMapping[kClass] + } + + private fun tryMapAllowedType(kClass: KClass<*>): HLParameterConversion? { + if (kClass in allowedTypesWithoutTypeParams) return HLIdParameterConversion + return null + } + + private fun tryMapCollectionType(type: KType, kClass: KClass<*>): HLParameterConversion? { + if (kClass.isSubclassOf(Collection::class)) { + val elementType = type.arguments.single().type ?: return HLIdParameterConversion + return HLMapParameterConversion( + parameterName = elementType.kClass.simpleName!!.decapitalize(), + mappingConversion = creatConversion(elementType) + ) + } + return null + } + + private fun tryMapPsiElementType(type: KType, kClass: KClass<*>): HLParameterConversion? { + if (kClass.isSubclassOf(PsiElement::class)) { + return HLIdParameterConversion + } + return null + } + + private val typeMapping: Map, HLFunctionCallConversion> = mapOf( + AbstractFirBasedSymbol::class to HLFunctionCallConversion( + "firSymbolBuilder.buildSymbol({0}.fir as FirDeclaration)", + KtSymbol::class.createType(), + importsToAdd = listOf("org.jetbrains.kotlin.fir.declarations.FirDeclaration") + ), + FirClass::class to HLFunctionCallConversion( + "firSymbolBuilder.buildClassLikeSymbol({0})", + KtClassLikeSymbol::class.createType() + ), + FirClassLikeSymbol::class to HLFunctionCallConversion( + "firSymbolBuilder.buildClassLikeSymbol({0}.fir as FirClass<*>)", + KtClassLikeSymbol::class.createType(), + importsToAdd = listOf("org.jetbrains.kotlin.fir.declarations.FirClass") + ), + FirMemberDeclaration::class to HLFunctionCallConversion( + "firSymbolBuilder.buildSymbol({0} as FirDeclaration)", + KtSymbol::class.createType(), + importsToAdd = listOf("org.jetbrains.kotlin.fir.declarations.FirDeclaration") + ), + FirTypeParameterSymbol::class to HLFunctionCallConversion( + "firSymbolBuilder.buildTypeParameterSymbol({0}.fir as FirTypeParameter)", + KtTypeParameterSymbol::class.createType(), + importsToAdd = listOf("org.jetbrains.kotlin.fir.declarations.FirTypeParameter") + ), + FirEffectiveVisibility::class to HLFunctionCallConversion( + "{0}.toVisibility()", + Visibility::class.createType() + ), + ConeKotlinType::class to HLFunctionCallConversion( + "firSymbolBuilder.buildKtType({0})", + KtType::class.createType() + ), + FirTypeRef::class to HLFunctionCallConversion( + "firSymbolBuilder.buildKtType({0})", + KtType::class.createType() + ), + FirPropertySymbol::class to HLFunctionCallConversion( + "firSymbolBuilder.buildVariableSymbol({0}.fir as FirProperty)", + KtVariableSymbol::class.createType(), + importsToAdd = listOf("org.jetbrains.kotlin.fir.declarations.FirProperty") + ), + ) + + private val allowedTypesWithoutTypeParams = setOf( + String::class, + Int::class, + Name::class, + EventOccurrencesRange::class, + KtModifierKeywordToken::class, + ) + + private val KType.kClass: KClass<*> + get() = classifier as KClass<*> +} \ No newline at end of file diff --git a/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/HLParameterConversion.kt b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/HLParameterConversion.kt new file mode 100644 index 00000000000..be04c99aa68 --- /dev/null +++ b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/HLParameterConversion.kt @@ -0,0 +1,68 @@ +/* + * 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.idea.frontend.api.fir.generator + +import kotlin.reflect.KType +import kotlin.reflect.KTypeProjection +import kotlin.reflect.KVariance +import kotlin.reflect.full.createType + +sealed class HLParameterConversion { + abstract fun convertExpression(expression: String, context: ConversionContext): String + abstract fun convertType(type: KType): KType + open val importsToAdd: List get() = emptyList() +} + +object HLIdParameterConversion : HLParameterConversion() { + override fun convertExpression(expression: String, context: ConversionContext) = expression + override fun convertType(type: KType): KType = type +} + +class HLMapParameterConversion( + private val parameterName: String, + private val mappingConversion: HLParameterConversion, +) : HLParameterConversion() { + override fun convertExpression(expression: String, context: ConversionContext): String { + val innerExpression = mappingConversion.convertExpression(parameterName, context.increaseIndent()) + return buildString { + appendLine("$expression.map { $parameterName ->") + appendLine(innerExpression.withIndent(context.increaseIndent())) + append("}".withIndent(context)) + } + } + + override fun convertType(type: KType): KType = + List::class.createType( + arguments = listOf( + KTypeProjection( + variance = KVariance.INVARIANT, + type = type.arguments.single().type?.let(mappingConversion::convertType) + ) + ) + ) + + override val importsToAdd get() = mappingConversion.importsToAdd +} + +class HLFunctionCallConversion( + private val callTemplate: String, + private val callType: KType, + override val importsToAdd: List = emptyList() +) : HLParameterConversion() { + override fun convertExpression(expression: String, context: ConversionContext) = + callTemplate.replace("{0}", expression) + + override fun convertType(type: KType): KType = callType +} + +data class ConversionContext(val currentIndent: Int, val indentUnitValue: Int) { + fun increaseIndent() = copy(currentIndent = currentIndent + 1) +} + +private fun String.withIndent(context: ConversionContext): String { + val newIndent = " ".repeat(context.currentIndent * context.indentUnitValue) + return replaceIndent(newIndent) +} diff --git a/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/Main.kt b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/Main.kt new file mode 100644 index 00000000000..1f22e2cf8f7 --- /dev/null +++ b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/Main.kt @@ -0,0 +1,15 @@ +/* + * 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.idea.frontend.api.fir.generator + +import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.DIAGNOSTICS_LIST +import java.nio.file.Paths + +fun main() { + val rootPath = Paths.get("idea/idea-frontend-fir/src").toAbsolutePath() + val packageName = "org.jetbrains.kotlin.idea.frontend.api.fir.diagnostics" + DiagnosticClassGenerator.generate(rootPath, DIAGNOSTICS_LIST, packageName) +} \ No newline at end of file diff --git a/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/generatorUtils.kt b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/generatorUtils.kt new file mode 100644 index 00000000000..b95796f488c --- /dev/null +++ b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/generatorUtils.kt @@ -0,0 +1,32 @@ +/* + * 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.idea.frontend.api.fir.generator + +import org.jetbrains.kotlin.fir.tree.generator.printer.SmartPrinter +import kotlin.reflect.KClass +import kotlin.reflect.KType + +@OptIn(ExperimentalStdlibApi::class) +internal fun KType.collectClassNamesTo(set: MutableSet) { + (classifier as? KClass<*>)?.qualifiedName?.let(set::add) + for (argument in arguments) { + argument.type?.collectClassNamesTo(set) + } +} + +internal fun SmartPrinter.printTypeWithShortNames(type: KType) { + print((type.classifier as KClass<*>).simpleName!!) + if (type.arguments.isNotEmpty()) { + print("<") + type.arguments.map { + when (val typeArgument = it.type) { + null -> "*" + else -> printTypeWithShortNames(typeArgument) + } + } + print(">") + } +} \ No newline at end of file diff --git a/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/rendererrs/AbstractDiagnosticsDataClassRenderer.kt b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/rendererrs/AbstractDiagnosticsDataClassRenderer.kt new file mode 100644 index 00000000000..0d86ae189e8 --- /dev/null +++ b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/rendererrs/AbstractDiagnosticsDataClassRenderer.kt @@ -0,0 +1,57 @@ +/* + * 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.idea.frontend.api.fir.generator.rendererrs + +import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.DiagnosticList +import org.jetbrains.kotlin.fir.checkers.generator.diagnostics.DiagnosticListRenderer +import org.jetbrains.kotlin.fir.checkers.generator.printImports +import org.jetbrains.kotlin.fir.tree.generator.printer.SmartPrinter +import org.jetbrains.kotlin.fir.tree.generator.printer.printCopyright +import org.jetbrains.kotlin.fir.tree.generator.printer.printGeneratedMessage +import org.jetbrains.kotlin.fir.tree.generator.printer.useSmartPrinter +import org.jetbrains.kotlin.idea.frontend.api.fir.generator.HLDiagnosticConverter +import org.jetbrains.kotlin.idea.frontend.api.fir.generator.HLDiagnosticList +import org.jetbrains.kotlin.idea.frontend.api.fir.generator.HLDiagnosticParameter +import org.jetbrains.kotlin.idea.frontend.api.fir.generator.collectClassNamesTo +import java.io.File + +abstract class AbstractDiagnosticsDataClassRenderer : DiagnosticListRenderer() { + override fun render(file: File, diagnosticList: DiagnosticList, packageName: String) { + val hlDiagnosticsList = HLDiagnosticConverter.convert(diagnosticList) + file.useSmartPrinter { render(hlDiagnosticsList, packageName) } + } + + private fun SmartPrinter.collectAndPrintImports(diagnosticList: HLDiagnosticList) { + val imports = collectImports(diagnosticList) + printImports(imports) + } + + protected fun SmartPrinter.printHeader(packageName: String, diagnosticList: HLDiagnosticList) { + printCopyright() + println("package $packageName") + println() + collectAndPrintImports(diagnosticList) + println() + printGeneratedMessage() + } + + @OptIn(ExperimentalStdlibApi::class) + protected fun collectImports(diagnosticList: HLDiagnosticList): Collection = buildSet { + addAll(defaultImports) + for (diagnostic in diagnosticList.diagnostics) { + diagnostic.original.psiType.collectClassNamesTo(this) + diagnostic.parameters.forEach { diagnosticParameter -> + addAll(collectImportsForDiagnosticParameter(diagnosticParameter)) + } + } + } + + protected abstract fun collectImportsForDiagnosticParameter(diagnosticParameter: HLDiagnosticParameter): Collection + + protected abstract fun SmartPrinter.render(diagnosticList: HLDiagnosticList, packageName: String) + + protected abstract val defaultImports: Collection +} \ No newline at end of file diff --git a/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/rendererrs/FirDiagnosticToKtDiagnosticConverterRenderer.kt b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/rendererrs/FirDiagnosticToKtDiagnosticConverterRenderer.kt new file mode 100644 index 00000000000..27eaa69ae8b --- /dev/null +++ b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/rendererrs/FirDiagnosticToKtDiagnosticConverterRenderer.kt @@ -0,0 +1,67 @@ +/* + * 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.idea.frontend.api.fir.generator.rendererrs + +import org.jetbrains.kotlin.fir.checkers.generator.inBracketsWithIndent +import org.jetbrains.kotlin.fir.tree.generator.printer.SmartPrinter +import org.jetbrains.kotlin.fir.tree.generator.printer.withIndent +import org.jetbrains.kotlin.idea.frontend.api.fir.generator.* + +object FirDiagnosticToKtDiagnosticConverterRenderer : AbstractDiagnosticsDataClassRenderer() { + override fun SmartPrinter.render(diagnosticList: HLDiagnosticList, packageName: String) { + printHeader(packageName, diagnosticList) + printDiagnosticConverter(diagnosticList) + } + + private fun SmartPrinter.printDiagnosticConverter(diagnosticList: HLDiagnosticList) { + inBracketsWithIndent("internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConverter") { + for (diagnostic in diagnosticList.diagnostics) { + printConverter(diagnostic) + } + } + } + + private fun SmartPrinter.printConverter(diagnostic: HLDiagnostic) { + println("add(FirErrors.${diagnostic.original.name}) { firDiagnostic ->") + withIndent { + println("${diagnostic.implClassName}(") + withIndent { + printDiagnosticParameters(diagnostic) + } + println(")") + } + println("}") + } + + private fun SmartPrinter.printDiagnosticParameters(diagnostic: HLDiagnostic) { + printCustomParameters(diagnostic) + println("firDiagnostic as FirPsiDiagnostic<*>,") + println("token,") + } + + + private fun SmartPrinter.printCustomParameters(diagnostic: HLDiagnostic) { + diagnostic.parameters.forEach { parameter -> + printParameter(parameter) + } + } + + private fun SmartPrinter.printParameter(parameter: HLDiagnosticParameter) { + val expression = parameter.conversion.convertExpression( + "firDiagnostic.${parameter.originalParameterName}", + ConversionContext(getCurrentIndentInUnits(), getIndentUnit()) + ) + println("$expression,") + } + + override fun collectImportsForDiagnosticParameter(diagnosticParameter: HLDiagnosticParameter): Collection = + diagnosticParameter.importsToAdd + + override val defaultImports = listOf( + "org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic", + "org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors", + ) +} \ No newline at end of file diff --git a/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/rendererrs/KtDiagnosticClassImplementationRenderer.kt b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/rendererrs/KtDiagnosticClassImplementationRenderer.kt new file mode 100644 index 00000000000..1021846ff34 --- /dev/null +++ b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/rendererrs/KtDiagnosticClassImplementationRenderer.kt @@ -0,0 +1,77 @@ +/* + * 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.idea.frontend.api.fir.generator.rendererrs + +import org.jetbrains.kotlin.fir.checkers.generator.inBracketsWithIndent +import org.jetbrains.kotlin.fir.tree.generator.printer.SmartPrinter +import org.jetbrains.kotlin.fir.tree.generator.printer.withIndent +import org.jetbrains.kotlin.idea.frontend.api.fir.generator.* +import org.jetbrains.kotlin.idea.frontend.api.fir.generator.collectClassNamesTo +import org.jetbrains.kotlin.idea.frontend.api.fir.generator.printTypeWithShortNames +import com.intellij.psi.PsiElement + +object KtDiagnosticClassImplementationRenderer : AbstractDiagnosticsDataClassRenderer() { + override fun SmartPrinter.render(diagnosticList: HLDiagnosticList, packageName: String) { + printHeader(packageName, diagnosticList) + printDiagnosticClassesImplementation(diagnosticList) + } + + private fun SmartPrinter.printDiagnosticClassesImplementation(diagnosticList: HLDiagnosticList) { + for (diagnostic in diagnosticList.diagnostics) { + printDiagnosticImplementation(diagnostic) + println() + } + } + + private fun SmartPrinter.printDiagnosticImplementation(diagnostic: HLDiagnostic) { + println("internal class ${diagnostic.implClassName}(") + withIndent { + printParameters(diagnostic) + } + inBracketsWithIndent(") : KtFirDiagnostic.${diagnostic.className}(), KtAbstractFirDiagnostic") { + println("override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic)") + printOverridePsiProperty(diagnostic) + } + } + + private fun SmartPrinter.printParameters(diagnostic: HLDiagnostic) { + for (parameter in diagnostic.parameters) { + printParameter(parameter) + } + println("firDiagnostic: FirPsiDiagnostic<*>,") + println("override val token: ValidityToken,") + } + + private fun SmartPrinter.printOverridePsiProperty(diagnostic: HLDiagnostic) { + print("override val psi: ") + printTypeWithShortNames(diagnostic.original.psiType) + withIndent { + print(" get() = super.psi") + if (diagnostic.original.psiType.classifier != PsiElement::class) { + print(" as ") + printTypeWithShortNames(diagnostic.original.psiType) + } + } + println() + } + + private fun SmartPrinter.printParameter(parameter: HLDiagnosticParameter) { + print("override val ${parameter.name}: ") + printTypeWithShortNames(parameter.type) + println(",") + } + + @OptIn(ExperimentalStdlibApi::class) + override fun collectImportsForDiagnosticParameter(diagnosticParameter: HLDiagnosticParameter): Collection = buildSet { + diagnosticParameter.type.collectClassNamesTo(this) + } + + override val defaultImports = listOf( + "org.jetbrains.kotlin.idea.frontend.api.fir.utils.weakRef", + "org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic", + "org.jetbrains.kotlin.idea.frontend.api.ValidityToken", + ) +} \ No newline at end of file diff --git a/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/rendererrs/KtDiagnosticClassRenderer.kt b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/rendererrs/KtDiagnosticClassRenderer.kt new file mode 100644 index 00000000000..41575ba1b38 --- /dev/null +++ b/idea/idea-frontend-fir/idea-frontend-fir-generator/src/org/jetbrains/kotlin/idea/frontend/api/fir/generator/rendererrs/KtDiagnosticClassRenderer.kt @@ -0,0 +1,62 @@ +/* + * 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.idea.frontend.api.fir.generator.rendererrs + +import org.jetbrains.kotlin.fir.checkers.generator.inBracketsWithIndent +import org.jetbrains.kotlin.fir.tree.generator.printer.SmartPrinter +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.idea.frontend.api.fir.generator.* +import org.jetbrains.kotlin.idea.frontend.api.fir.generator.collectClassNamesTo +import org.jetbrains.kotlin.idea.frontend.api.fir.generator.printTypeWithShortNames + +object KtDiagnosticClassRenderer : AbstractDiagnosticsDataClassRenderer() { + override fun SmartPrinter.render(diagnosticList: HLDiagnosticList, packageName: String) { + printHeader(packageName, diagnosticList) + printDiagnosticClasses(diagnosticList) + } + + private fun SmartPrinter.printDiagnosticClasses(diagnosticList: HLDiagnosticList) { + inBracketsWithIndent("sealed class KtFirDiagnostic : KtDiagnosticWithPsi") { + for (diagnostic in diagnosticList.diagnostics) { + printDiagnosticClass(diagnostic) + println() + } + } + } + + private fun SmartPrinter.printDiagnosticClass(diagnostic: HLDiagnostic) { + inBracketsWithIndent("abstract class ${diagnostic.className} : KtFirDiagnostic()") { + println("override val diagnosticClass get() = ${diagnostic.className}::class") + printPsiParameter(diagnostic) + printDiagnosticParameters(diagnostic) + } + } + + private fun SmartPrinter.printPsiParameter(diagnostic: HLDiagnostic) { + if (diagnostic.original.psiType.classifier != PsiElement::class) { + print("abstract override val psi: ") + printTypeWithShortNames(diagnostic.original.psiType) + println() + } + } + + private fun SmartPrinter.printDiagnosticParameters(diagnostic: HLDiagnostic) { + diagnostic.parameters.forEach { parameter -> + print("abstract val ${parameter.name}: ") + printTypeWithShortNames(parameter.type) + println() + } + } + + @OptIn(ExperimentalStdlibApi::class) + override fun collectImportsForDiagnosticParameter(diagnosticParameter: HLDiagnosticParameter): Collection = buildSet { + diagnosticParameter.type.collectClassNamesTo(this) + } + + override val defaultImports = listOf( + "org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnosticWithPsi", + ) +} \ No newline at end of file diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirAnalysisSessionComponent.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirAnalysisSessionComponent.kt index 93dcfd1dffd..f9a3977a0a1 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirAnalysisSessionComponent.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirAnalysisSessionComponent.kt @@ -11,6 +11,7 @@ import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic import org.jetbrains.kotlin.fir.types.ConeKotlinType import org.jetbrains.kotlin.fir.types.ConeTypeCheckerContext import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnostic +import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnosticWithPsi import org.jetbrains.kotlin.idea.frontend.api.fir.KtFirAnalysisSession internal interface KtFirAnalysisSessionComponent { @@ -20,7 +21,7 @@ internal interface KtFirAnalysisSessionComponent { val firResolveState get() = analysisSession.firResolveState fun ConeKotlinType.asKtType() = analysisSession.firSymbolBuilder.buildKtType(this) - fun FirPsiDiagnostic<*>.asKtDiagnostic(): KtDiagnostic = + fun FirPsiDiagnostic<*>.asKtDiagnostic(): KtDiagnosticWithPsi = (analysisSession.diagnosticProvider as KtFirDiagnosticProvider).firDiagnosticAsKtDiagnostic(this) fun ConeDiagnostic.asKtDiagnostic(source: FirSourceElement): KtDiagnostic? = diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirCallResolver.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirCallResolver.kt index a3fdbef7295..43aeddcd1cd 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirCallResolver.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirCallResolver.kt @@ -113,13 +113,13 @@ internal class KtFirCallResolver( private fun FirErrorNamedReference.createErrorCallTarget(): KtErrorCallTarget = KtErrorCallTarget( getCandidateSymbols().mapNotNull { it.fir.buildSymbol(firSymbolBuilder) as? KtFunctionLikeSymbol }, - source?.let { diagnostic.asKtDiagnostic(it) } ?: KtSimpleDiagnostic(factoryName = null, diagnostic.reason, emptyList()) + source?.let { diagnostic.asKtDiagnostic(it) } ?: KtSimpleDiagnostic(factoryName = null, diagnostic.reason, token) ) private fun FirErrorReferenceWithCandidate.createErrorCallTarget(): KtErrorCallTarget = KtErrorCallTarget( getCandidateSymbols().mapNotNull { it.fir.buildSymbol(firSymbolBuilder) as? KtFunctionLikeSymbol }, - source?.let { diagnostic.asKtDiagnostic(it) } ?: KtSimpleDiagnostic(factoryName = null, diagnostic.reason, emptyList()) + source?.let { diagnostic.asKtDiagnostic(it) } ?: KtSimpleDiagnostic(factoryName = null, diagnostic.reason, token) ) private fun FirResolvedNamedReference.getKtFunctionOrConstructorSymbol(): KtFunctionLikeSymbol? = diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirDiagnosticProvider.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirDiagnosticProvider.kt index 530909f39c5..69836ad1c06 100644 --- a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirDiagnosticProvider.kt +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/components/KtFirDiagnosticProvider.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.idea.frontend.api.fir.components import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnostic import org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic import org.jetbrains.kotlin.fir.analysis.diagnostics.toFirDiagnostic import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic @@ -14,10 +15,10 @@ import org.jetbrains.kotlin.idea.fir.low.level.api.api.getDiagnostics import org.jetbrains.kotlin.idea.frontend.api.ValidityToken import org.jetbrains.kotlin.idea.frontend.api.components.KtDiagnosticProvider import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnostic -import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtSimpleDiagnostic +import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnosticWithPsi import org.jetbrains.kotlin.idea.frontend.api.fir.KtFirAnalysisSession +import org.jetbrains.kotlin.idea.frontend.api.fir.diagnostics.KT_DIAGNOSTIC_CONVERTER import org.jetbrains.kotlin.idea.frontend.api.withValidityAssertion -import org.jetbrains.kotlin.idea.highlighter.IdeErrorMessages import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.psi.KtFile @@ -25,19 +26,18 @@ internal class KtFirDiagnosticProvider( override val analysisSession: KtFirAnalysisSession, override val token: ValidityToken, ) : KtDiagnosticProvider(), KtFirAnalysisSessionComponent { - override fun getDiagnosticsForElement(element: KtElement): Collection = withValidityAssertion { + override fun getDiagnosticsForElement(element: KtElement): Collection = withValidityAssertion { element.getDiagnostics(firResolveState).map { it.asKtDiagnostic() } } - override fun collectDiagnosticsForFile(ktFile: KtFile): Collection = + override fun collectDiagnosticsForFile(ktFile: KtFile): Collection = ktFile.collectDiagnosticsForFile(firResolveState).map { it.asKtDiagnostic() } - fun firDiagnosticAsKtDiagnostic(diagnostic: FirPsiDiagnostic<*>): KtDiagnostic { - val message = IdeErrorMessages.render(diagnostic) - return KtSimpleDiagnostic(diagnostic.factory.name, message, diagnostic.textRanges) + fun firDiagnosticAsKtDiagnostic(diagnostic: FirPsiDiagnostic<*>): KtDiagnosticWithPsi { + return KT_DIAGNOSTIC_CONVERTER.convert(analysisSession, diagnostic as FirDiagnostic<*>) } - fun coneDiagnosticAsKtDiagnostic(coneDiagnostic: ConeDiagnostic, source: FirSourceElement): KtDiagnostic? { + fun coneDiagnosticAsKtDiagnostic(coneDiagnostic: ConeDiagnostic, source: FirSourceElement): KtDiagnosticWithPsi? { val firDiagnostic = coneDiagnostic.toFirDiagnostic(source) ?: return null check(firDiagnostic is FirPsiDiagnostic<*>) return firDiagnosticAsKtDiagnostic(firDiagnostic) diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/DiagnosticConverter.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/DiagnosticConverter.kt new file mode 100644 index 00000000000..02bc79c1429 --- /dev/null +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/DiagnosticConverter.kt @@ -0,0 +1,81 @@ +/* + * 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.idea.frontend.api.fir.diagnostics + +import org.jetbrains.kotlin.fir.FirSourceElement +import org.jetbrains.kotlin.fir.analysis.diagnostics.* +import org.jetbrains.kotlin.idea.frontend.api.fir.KtFirAnalysisSession + +internal interface KtFirDiagnosticCreator + +internal fun interface KtFirDiagnostic0Creator : KtFirDiagnosticCreator { + fun KtFirAnalysisSession.create(diagnostic: FirSimpleDiagnostic<*>): KtFirDiagnostic +} + +internal fun interface KtFirDiagnostic1Creator : KtFirDiagnosticCreator { + fun KtFirAnalysisSession.create(diagnostic: FirDiagnosticWithParameters1<*, A>): KtFirDiagnostic +} + +internal fun interface KtFirDiagnostic2Creator : KtFirDiagnosticCreator { + fun KtFirAnalysisSession.create(diagnostic: FirDiagnosticWithParameters2<*, A, B>): KtFirDiagnostic +} + +internal fun interface KtFirDiagnostic3Creator : KtFirDiagnosticCreator { + fun KtFirAnalysisSession.create(diagnostic: FirDiagnosticWithParameters3<*, A, B, C>): KtFirDiagnostic +} + +internal class KtDiagnosticConverter(private val conversions: Map, KtFirDiagnosticCreator>) { + fun convert(analysisSession: KtFirAnalysisSession, diagnostic: FirDiagnostic<*>): KtFirDiagnostic { + val creator = conversions[diagnostic.factory] + ?: error("No conversion was found for ${diagnostic.factory}") + + @Suppress("UNCHECKED_CAST") + return with(analysisSession) { + when (creator) { + is KtFirDiagnostic0Creator -> with(creator) { + create(diagnostic as FirSimpleDiagnostic<*>) + } + is KtFirDiagnostic1Creator<*> -> with(creator as KtFirDiagnostic1Creator) { + create(diagnostic as FirDiagnosticWithParameters1) + } + is KtFirDiagnostic2Creator<*, *> -> with(creator as KtFirDiagnostic2Creator) { + create(diagnostic as FirDiagnosticWithParameters2) + } + is KtFirDiagnostic3Creator<*, *, *> -> with(creator as KtFirDiagnostic3Creator) { + create(diagnostic as FirDiagnosticWithParameters3) + } + else -> error("Invalid KtFirDiagnosticCreator ${creator::class.simpleName}") + } + } + } +} + +internal class KtDiagnosticConverterBuilder private constructor() { + private val conversions = mutableMapOf, KtFirDiagnosticCreator>() + + fun add(diagnostic: FirDiagnosticFactory0<*, *>, creator: KtFirDiagnostic0Creator) { + conversions[diagnostic] = creator + } + + fun add(diagnostic: FirDiagnosticFactory1<*, *, A>, creator: KtFirDiagnostic1Creator) { + conversions[diagnostic] = creator + } + + fun add(diagnostic: FirDiagnosticFactory2<*, *, A, B>, creator: KtFirDiagnostic2Creator) { + conversions[diagnostic] = creator + } + + fun add(diagnostic: FirDiagnosticFactory3<*, *, A, B, C>, creator: KtFirDiagnostic3Creator) { + conversions[diagnostic] = creator + } + + private fun build() = KtDiagnosticConverter(conversions) + + companion object { + inline fun buildConverter(init: KtDiagnosticConverterBuilder.() -> Unit) = + KtDiagnosticConverterBuilder().apply(init).build() + } +} \ No newline at end of file diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtAbstractFirDiagnostic.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtAbstractFirDiagnostic.kt new file mode 100644 index 00000000000..0d62f581e04 --- /dev/null +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtAbstractFirDiagnostic.kt @@ -0,0 +1,38 @@ +/* + * 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.idea.frontend.api.fir.diagnostics + +import com.intellij.openapi.util.TextRange +import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDefaultErrorMessages +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnostic +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderer +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic +import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnostic +import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnosticWithPsi + +internal interface KtAbstractFirDiagnostic : KtDiagnosticWithPsi { + val firDiagnostic: FirPsiDiagnostic<*> + + override val factoryName: String + get() = firDiagnostic.factory.name + + override val defaultMessage: String + get() { + val diagnostic = firDiagnostic as FirDiagnostic<*> + + @Suppress("UNCHECKED_CAST") + val firDiagnosticRenderer = + FirDefaultErrorMessages.getRendererForDiagnostic(diagnostic) as FirDiagnosticRenderer> + return firDiagnosticRenderer.render(diagnostic) + } + + override val textRanges: Collection + get() = firDiagnostic.textRanges + + override val psi: PsiElement + get() = firDiagnostic.psiElement +} diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt new file mode 100644 index 00000000000..088813d9efc --- /dev/null +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDataClassConverters.kt @@ -0,0 +1,983 @@ +/* + * 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.idea.frontend.api.fir.diagnostics + +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiTypeElement +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic +import org.jetbrains.kotlin.fir.declarations.FirClass +import org.jetbrains.kotlin.fir.declarations.FirDeclaration +import org.jetbrains.kotlin.fir.declarations.FirProperty +import org.jetbrains.kotlin.fir.declarations.FirTypeParameter +import org.jetbrains.kotlin.psi.KtClassOrObject +import org.jetbrains.kotlin.psi.KtDeclaration +import org.jetbrains.kotlin.psi.KtDestructuringDeclaration +import org.jetbrains.kotlin.psi.KtExpression +import org.jetbrains.kotlin.psi.KtFunction +import org.jetbrains.kotlin.psi.KtModifierListOwner +import org.jetbrains.kotlin.psi.KtNamedDeclaration +import org.jetbrains.kotlin.psi.KtParameter +import org.jetbrains.kotlin.psi.KtProperty +import org.jetbrains.kotlin.psi.KtPropertyAccessor +import org.jetbrains.kotlin.psi.KtPropertyDelegate +import org.jetbrains.kotlin.psi.KtTypeReference + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +internal val KT_DIAGNOSTIC_CONVERTER = KtDiagnosticConverterBuilder.buildConverter { + add(FirErrors.SYNTAX) { firDiagnostic -> + SyntaxImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.OTHER_ERROR) { firDiagnostic -> + OtherErrorImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ILLEGAL_CONST_EXPRESSION) { firDiagnostic -> + IllegalConstExpressionImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ILLEGAL_UNDERSCORE) { firDiagnostic -> + IllegalUnderscoreImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.EXPRESSION_REQUIRED) { firDiagnostic -> + ExpressionRequiredImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.BREAK_OR_CONTINUE_OUTSIDE_A_LOOP) { firDiagnostic -> + BreakOrContinueOutsideALoopImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.NOT_A_LOOP_LABEL) { firDiagnostic -> + NotALoopLabelImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.VARIABLE_EXPECTED) { firDiagnostic -> + VariableExpectedImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.RETURN_NOT_ALLOWED) { firDiagnostic -> + ReturnNotAllowedImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.DELEGATION_IN_INTERFACE) { firDiagnostic -> + DelegationInInterfaceImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.HIDDEN) { firDiagnostic -> + HiddenImpl( + firSymbolBuilder.buildSymbol(firDiagnostic.a.fir as FirDeclaration), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.UNRESOLVED_REFERENCE) { firDiagnostic -> + UnresolvedReferenceImpl( + firDiagnostic.a, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.UNRESOLVED_LABEL) { firDiagnostic -> + UnresolvedLabelImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.DESERIALIZATION_ERROR) { firDiagnostic -> + DeserializationErrorImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ERROR_FROM_JAVA_RESOLUTION) { firDiagnostic -> + ErrorFromJavaResolutionImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.UNKNOWN_CALLABLE_KIND) { firDiagnostic -> + UnknownCallableKindImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.MISSING_STDLIB_CLASS) { firDiagnostic -> + MissingStdlibClassImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.NO_THIS) { firDiagnostic -> + NoThisImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.SUPER_IS_NOT_AN_EXPRESSION) { firDiagnostic -> + SuperIsNotAnExpressionImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.SUPER_NOT_AVAILABLE) { firDiagnostic -> + SuperNotAvailableImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ABSTRACT_SUPER_CALL) { firDiagnostic -> + AbstractSuperCallImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.INSTANCE_ACCESS_BEFORE_SUPER_CALL) { firDiagnostic -> + InstanceAccessBeforeSuperCallImpl( + firDiagnostic.a, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.TYPE_PARAMETER_AS_SUPERTYPE) { firDiagnostic -> + TypeParameterAsSupertypeImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ENUM_AS_SUPERTYPE) { firDiagnostic -> + EnumAsSupertypeImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.RECURSION_IN_SUPERTYPES) { firDiagnostic -> + RecursionInSupertypesImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.NOT_A_SUPERTYPE) { firDiagnostic -> + NotASupertypeImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.SUPERCLASS_NOT_ACCESSIBLE_FROM_INTERFACE) { firDiagnostic -> + SuperclassNotAccessibleFromInterfaceImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.QUALIFIED_SUPERTYPE_EXTENDED_BY_OTHER_SUPERTYPE) { firDiagnostic -> + QualifiedSupertypeExtendedByOtherSupertypeImpl( + firSymbolBuilder.buildClassLikeSymbol(firDiagnostic.a), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.SUPERTYPE_INITIALIZED_IN_INTERFACE) { firDiagnostic -> + SupertypeInitializedInInterfaceImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.INTERFACE_WITH_SUPERCLASS) { firDiagnostic -> + InterfaceWithSuperclassImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.CLASS_IN_SUPERTYPE_FOR_ENUM) { firDiagnostic -> + ClassInSupertypeForEnumImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.SEALED_SUPERTYPE) { firDiagnostic -> + SealedSupertypeImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.SEALED_SUPERTYPE_IN_LOCAL_CLASS) { firDiagnostic -> + SealedSupertypeInLocalClassImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.CONSTRUCTOR_IN_OBJECT) { firDiagnostic -> + ConstructorInObjectImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.CONSTRUCTOR_IN_INTERFACE) { firDiagnostic -> + ConstructorInInterfaceImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.NON_PRIVATE_CONSTRUCTOR_IN_ENUM) { firDiagnostic -> + NonPrivateConstructorInEnumImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.NON_PRIVATE_CONSTRUCTOR_IN_SEALED) { firDiagnostic -> + NonPrivateConstructorInSealedImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.CYCLIC_CONSTRUCTOR_DELEGATION_CALL) { firDiagnostic -> + CyclicConstructorDelegationCallImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED) { firDiagnostic -> + PrimaryConstructorDelegationCallExpectedImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.SUPERTYPE_INITIALIZED_WITHOUT_PRIMARY_CONSTRUCTOR) { firDiagnostic -> + SupertypeInitializedWithoutPrimaryConstructorImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.DELEGATION_SUPER_CALL_IN_ENUM_CONSTRUCTOR) { firDiagnostic -> + DelegationSuperCallInEnumConstructorImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.PRIMARY_CONSTRUCTOR_REQUIRED_FOR_DATA_CLASS) { firDiagnostic -> + PrimaryConstructorRequiredForDataClassImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.EXPLICIT_DELEGATION_CALL_REQUIRED) { firDiagnostic -> + ExplicitDelegationCallRequiredImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.SEALED_CLASS_CONSTRUCTOR_CALL) { firDiagnostic -> + SealedClassConstructorCallImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ANNOTATION_ARGUMENT_KCLASS_LITERAL_OF_TYPE_PARAMETER_ERROR) { firDiagnostic -> + AnnotationArgumentKclassLiteralOfTypeParameterErrorImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ANNOTATION_ARGUMENT_MUST_BE_CONST) { firDiagnostic -> + AnnotationArgumentMustBeConstImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ANNOTATION_ARGUMENT_MUST_BE_ENUM_CONST) { firDiagnostic -> + AnnotationArgumentMustBeEnumConstImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ANNOTATION_ARGUMENT_MUST_BE_KCLASS_LITERAL) { firDiagnostic -> + AnnotationArgumentMustBeKclassLiteralImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ANNOTATION_CLASS_MEMBER) { firDiagnostic -> + AnnotationClassMemberImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT) { firDiagnostic -> + AnnotationParameterDefaultValueMustBeConstantImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.INVALID_TYPE_OF_ANNOTATION_MEMBER) { firDiagnostic -> + InvalidTypeOfAnnotationMemberImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.LOCAL_ANNOTATION_CLASS_ERROR) { firDiagnostic -> + LocalAnnotationClassErrorImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.MISSING_VAL_ON_ANNOTATION_PARAMETER) { firDiagnostic -> + MissingValOnAnnotationParameterImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION) { firDiagnostic -> + NonConstValUsedInConstantExpressionImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.NOT_AN_ANNOTATION_CLASS) { firDiagnostic -> + NotAnAnnotationClassImpl( + firDiagnostic.a, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.NULLABLE_TYPE_OF_ANNOTATION_MEMBER) { firDiagnostic -> + NullableTypeOfAnnotationMemberImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.VAR_ANNOTATION_PARAMETER) { firDiagnostic -> + VarAnnotationParameterImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.EXPOSED_TYPEALIAS_EXPANDED_TYPE) { firDiagnostic -> + ExposedTypealiasExpandedTypeImpl( + firDiagnostic.a.toVisibility(), + firSymbolBuilder.buildSymbol(firDiagnostic.b as FirDeclaration), + firDiagnostic.c.toVisibility(), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.EXPOSED_FUNCTION_RETURN_TYPE) { firDiagnostic -> + ExposedFunctionReturnTypeImpl( + firDiagnostic.a.toVisibility(), + firSymbolBuilder.buildSymbol(firDiagnostic.b as FirDeclaration), + firDiagnostic.c.toVisibility(), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.EXPOSED_RECEIVER_TYPE) { firDiagnostic -> + ExposedReceiverTypeImpl( + firDiagnostic.a.toVisibility(), + firSymbolBuilder.buildSymbol(firDiagnostic.b as FirDeclaration), + firDiagnostic.c.toVisibility(), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.EXPOSED_PROPERTY_TYPE) { firDiagnostic -> + ExposedPropertyTypeImpl( + firDiagnostic.a.toVisibility(), + firSymbolBuilder.buildSymbol(firDiagnostic.b as FirDeclaration), + firDiagnostic.c.toVisibility(), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.EXPOSED_PARAMETER_TYPE) { firDiagnostic -> + ExposedParameterTypeImpl( + firDiagnostic.a.toVisibility(), + firSymbolBuilder.buildSymbol(firDiagnostic.b as FirDeclaration), + firDiagnostic.c.toVisibility(), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.EXPOSED_SUPER_INTERFACE) { firDiagnostic -> + ExposedSuperInterfaceImpl( + firDiagnostic.a.toVisibility(), + firSymbolBuilder.buildSymbol(firDiagnostic.b as FirDeclaration), + firDiagnostic.c.toVisibility(), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.EXPOSED_SUPER_CLASS) { firDiagnostic -> + ExposedSuperClassImpl( + firDiagnostic.a.toVisibility(), + firSymbolBuilder.buildSymbol(firDiagnostic.b as FirDeclaration), + firDiagnostic.c.toVisibility(), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.EXPOSED_TYPE_PARAMETER_BOUND) { firDiagnostic -> + ExposedTypeParameterBoundImpl( + firDiagnostic.a.toVisibility(), + firSymbolBuilder.buildSymbol(firDiagnostic.b as FirDeclaration), + firDiagnostic.c.toVisibility(), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.INAPPLICABLE_INFIX_MODIFIER) { firDiagnostic -> + InapplicableInfixModifierImpl( + firDiagnostic.a, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.REPEATED_MODIFIER) { firDiagnostic -> + RepeatedModifierImpl( + firDiagnostic.a, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.REDUNDANT_MODIFIER) { firDiagnostic -> + RedundantModifierImpl( + firDiagnostic.a, + firDiagnostic.b, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.DEPRECATED_MODIFIER_PAIR) { firDiagnostic -> + DeprecatedModifierPairImpl( + firDiagnostic.a, + firDiagnostic.b, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.INCOMPATIBLE_MODIFIERS) { firDiagnostic -> + IncompatibleModifiersImpl( + firDiagnostic.a, + firDiagnostic.b, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.REDUNDANT_OPEN_IN_INTERFACE) { firDiagnostic -> + RedundantOpenInInterfaceImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.NONE_APPLICABLE) { firDiagnostic -> + NoneApplicableImpl( + firDiagnostic.a.map { abstractFirBasedSymbol -> + firSymbolBuilder.buildSymbol(abstractFirBasedSymbol.fir as FirDeclaration) + }, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.INAPPLICABLE_CANDIDATE) { firDiagnostic -> + InapplicableCandidateImpl( + firSymbolBuilder.buildSymbol(firDiagnostic.a.fir as FirDeclaration), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.INAPPLICABLE_LATEINIT_MODIFIER) { firDiagnostic -> + InapplicableLateinitModifierImpl( + firDiagnostic.a, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.AMBIGUITY) { firDiagnostic -> + AmbiguityImpl( + firDiagnostic.a.map { abstractFirBasedSymbol -> + firSymbolBuilder.buildSymbol(abstractFirBasedSymbol.fir as FirDeclaration) + }, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ASSIGN_OPERATOR_AMBIGUITY) { firDiagnostic -> + AssignOperatorAmbiguityImpl( + firDiagnostic.a.map { abstractFirBasedSymbol -> + firSymbolBuilder.buildSymbol(abstractFirBasedSymbol.fir as FirDeclaration) + }, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.TYPE_MISMATCH) { firDiagnostic -> + TypeMismatchImpl( + firSymbolBuilder.buildKtType(firDiagnostic.a), + firSymbolBuilder.buildKtType(firDiagnostic.b), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.RECURSION_IN_IMPLICIT_TYPES) { firDiagnostic -> + RecursionInImplicitTypesImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.INFERENCE_ERROR) { firDiagnostic -> + InferenceErrorImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT) { firDiagnostic -> + ProjectionOnNonClassTypeArgumentImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.UPPER_BOUND_VIOLATED) { firDiagnostic -> + UpperBoundViolatedImpl( + firSymbolBuilder.buildTypeParameterSymbol(firDiagnostic.a.fir as FirTypeParameter), + firSymbolBuilder.buildKtType(firDiagnostic.b), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.TYPE_ARGUMENTS_NOT_ALLOWED) { firDiagnostic -> + TypeArgumentsNotAllowedImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.WRONG_NUMBER_OF_TYPE_ARGUMENTS) { firDiagnostic -> + WrongNumberOfTypeArgumentsImpl( + firDiagnostic.a, + firSymbolBuilder.buildClassLikeSymbol(firDiagnostic.b.fir as FirClass<*>), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.NO_TYPE_FOR_TYPE_PARAMETER) { firDiagnostic -> + NoTypeForTypeParameterImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.TYPE_PARAMETERS_IN_OBJECT) { firDiagnostic -> + TypeParametersInObjectImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ILLEGAL_PROJECTION_USAGE) { firDiagnostic -> + IllegalProjectionUsageImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.TYPE_PARAMETERS_IN_ENUM) { firDiagnostic -> + TypeParametersInEnumImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.CONFLICTING_PROJECTION) { firDiagnostic -> + ConflictingProjectionImpl( + firDiagnostic.a, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED) { firDiagnostic -> + VarianceOnTypeParameterNotAllowedImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.RETURN_TYPE_MISMATCH_ON_OVERRIDE) { firDiagnostic -> + ReturnTypeMismatchOnOverrideImpl( + firDiagnostic.a, + firSymbolBuilder.buildSymbol(firDiagnostic.b as FirDeclaration), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.PROPERTY_TYPE_MISMATCH_ON_OVERRIDE) { firDiagnostic -> + PropertyTypeMismatchOnOverrideImpl( + firDiagnostic.a, + firSymbolBuilder.buildSymbol(firDiagnostic.b as FirDeclaration), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.VAR_TYPE_MISMATCH_ON_OVERRIDE) { firDiagnostic -> + VarTypeMismatchOnOverrideImpl( + firDiagnostic.a, + firSymbolBuilder.buildSymbol(firDiagnostic.b as FirDeclaration), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.MANY_COMPANION_OBJECTS) { firDiagnostic -> + ManyCompanionObjectsImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.CONFLICTING_OVERLOADS) { firDiagnostic -> + ConflictingOverloadsImpl( + firDiagnostic.a, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.REDECLARATION) { firDiagnostic -> + RedeclarationImpl( + firDiagnostic.a, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ANY_METHOD_IMPLEMENTED_IN_INTERFACE) { firDiagnostic -> + AnyMethodImplementedInInterfaceImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.LOCAL_OBJECT_NOT_ALLOWED) { firDiagnostic -> + LocalObjectNotAllowedImpl( + firDiagnostic.a, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.LOCAL_INTERFACE_NOT_ALLOWED) { firDiagnostic -> + LocalInterfaceNotAllowedImpl( + firDiagnostic.a, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS) { firDiagnostic -> + AbstractFunctionInNonAbstractClassImpl( + firSymbolBuilder.buildSymbol(firDiagnostic.a as FirDeclaration), + firSymbolBuilder.buildSymbol(firDiagnostic.b as FirDeclaration), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ABSTRACT_FUNCTION_WITH_BODY) { firDiagnostic -> + AbstractFunctionWithBodyImpl( + firSymbolBuilder.buildSymbol(firDiagnostic.a as FirDeclaration), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.NON_ABSTRACT_FUNCTION_WITH_NO_BODY) { firDiagnostic -> + NonAbstractFunctionWithNoBodyImpl( + firSymbolBuilder.buildSymbol(firDiagnostic.a as FirDeclaration), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.PRIVATE_FUNCTION_WITH_NO_BODY) { firDiagnostic -> + PrivateFunctionWithNoBodyImpl( + firSymbolBuilder.buildSymbol(firDiagnostic.a as FirDeclaration), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.NON_MEMBER_FUNCTION_NO_BODY) { firDiagnostic -> + NonMemberFunctionNoBodyImpl( + firSymbolBuilder.buildSymbol(firDiagnostic.a as FirDeclaration), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.FUNCTION_DECLARATION_WITH_NO_NAME) { firDiagnostic -> + FunctionDeclarationWithNoNameImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ANONYMOUS_FUNCTION_PARAMETER_WITH_DEFAULT_VALUE) { firDiagnostic -> + AnonymousFunctionParameterWithDefaultValueImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.USELESS_VARARG_ON_PARAMETER) { firDiagnostic -> + UselessVarargOnParameterImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS) { firDiagnostic -> + AbstractPropertyInNonAbstractClassImpl( + firSymbolBuilder.buildSymbol(firDiagnostic.a as FirDeclaration), + firSymbolBuilder.buildSymbol(firDiagnostic.b as FirDeclaration), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.PRIVATE_PROPERTY_IN_INTERFACE) { firDiagnostic -> + PrivatePropertyInInterfaceImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ABSTRACT_PROPERTY_WITH_INITIALIZER) { firDiagnostic -> + AbstractPropertyWithInitializerImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.PROPERTY_INITIALIZER_IN_INTERFACE) { firDiagnostic -> + PropertyInitializerInInterfaceImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.PROPERTY_WITH_NO_TYPE_NO_INITIALIZER) { firDiagnostic -> + PropertyWithNoTypeNoInitializerImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ABSTRACT_DELEGATED_PROPERTY) { firDiagnostic -> + AbstractDelegatedPropertyImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.DELEGATED_PROPERTY_IN_INTERFACE) { firDiagnostic -> + DelegatedPropertyInInterfaceImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ABSTRACT_PROPERTY_WITH_GETTER) { firDiagnostic -> + AbstractPropertyWithGetterImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ABSTRACT_PROPERTY_WITH_SETTER) { firDiagnostic -> + AbstractPropertyWithSetterImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.PRIVATE_SETTER_FOR_ABSTRACT_PROPERTY) { firDiagnostic -> + PrivateSetterForAbstractPropertyImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.PRIVATE_SETTER_FOR_OPEN_PROPERTY) { firDiagnostic -> + PrivateSetterForOpenPropertyImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.EXPECTED_PRIVATE_DECLARATION) { firDiagnostic -> + ExpectedPrivateDeclarationImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.EXPECTED_DECLARATION_WITH_BODY) { firDiagnostic -> + ExpectedDeclarationWithBodyImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.EXPECTED_PROPERTY_INITIALIZER) { firDiagnostic -> + ExpectedPropertyInitializerImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.EXPECTED_DELEGATED_PROPERTY) { firDiagnostic -> + ExpectedDelegatedPropertyImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.INITIALIZER_REQUIRED_FOR_DESTRUCTURING_DECLARATION) { firDiagnostic -> + InitializerRequiredForDestructuringDeclarationImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.COMPONENT_FUNCTION_MISSING) { firDiagnostic -> + ComponentFunctionMissingImpl( + firDiagnostic.a, + firSymbolBuilder.buildKtType(firDiagnostic.b), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.COMPONENT_FUNCTION_AMBIGUITY) { firDiagnostic -> + ComponentFunctionAmbiguityImpl( + firDiagnostic.a, + firDiagnostic.b.map { abstractFirBasedSymbol -> + firSymbolBuilder.buildSymbol(abstractFirBasedSymbol.fir as FirDeclaration) + }, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.UNINITIALIZED_VARIABLE) { firDiagnostic -> + UninitializedVariableImpl( + firSymbolBuilder.buildVariableSymbol(firDiagnostic.a.fir as FirProperty), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.WRONG_INVOCATION_KIND) { firDiagnostic -> + WrongInvocationKindImpl( + firSymbolBuilder.buildSymbol(firDiagnostic.a.fir as FirDeclaration), + firDiagnostic.b, + firDiagnostic.c, + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.LEAKED_IN_PLACE_LAMBDA) { firDiagnostic -> + LeakedInPlaceLambdaImpl( + firSymbolBuilder.buildSymbol(firDiagnostic.a.fir as FirDeclaration), + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.WRONG_IMPLIES_CONDITION) { firDiagnostic -> + WrongImpliesConditionImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.REDUNDANT_VISIBILITY_MODIFIER) { firDiagnostic -> + RedundantVisibilityModifierImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.REDUNDANT_MODALITY_MODIFIER) { firDiagnostic -> + RedundantModalityModifierImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.REDUNDANT_RETURN_UNIT_TYPE) { firDiagnostic -> + RedundantReturnUnitTypeImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.REDUNDANT_EXPLICIT_TYPE) { firDiagnostic -> + RedundantExplicitTypeImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.REDUNDANT_SINGLE_EXPRESSION_STRING_TEMPLATE) { firDiagnostic -> + RedundantSingleExpressionStringTemplateImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.CAN_BE_VAL) { firDiagnostic -> + CanBeValImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.CAN_BE_REPLACED_WITH_OPERATOR_ASSIGNMENT) { firDiagnostic -> + CanBeReplacedWithOperatorAssignmentImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.REDUNDANT_CALL_OF_CONVERSION_METHOD) { firDiagnostic -> + RedundantCallOfConversionMethodImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ARRAY_EQUALITY_OPERATOR_CAN_BE_REPLACED_WITH_EQUALS) { firDiagnostic -> + ArrayEqualityOperatorCanBeReplacedWithEqualsImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.EMPTY_RANGE) { firDiagnostic -> + EmptyRangeImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.REDUNDANT_SETTER_PARAMETER_TYPE) { firDiagnostic -> + RedundantSetterParameterTypeImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.UNUSED_VARIABLE) { firDiagnostic -> + UnusedVariableImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.ASSIGNED_VALUE_IS_NEVER_READ) { firDiagnostic -> + AssignedValueIsNeverReadImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.VARIABLE_INITIALIZER_IS_REDUNDANT) { firDiagnostic -> + VariableInitializerIsRedundantImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.VARIABLE_NEVER_READ) { firDiagnostic -> + VariableNeverReadImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } + add(FirErrors.USELESS_CALL_ON_NOT_NULL) { firDiagnostic -> + UselessCallOnNotNullImpl( + firDiagnostic as FirPsiDiagnostic<*>, + token, + ) + } +} diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt new file mode 100644 index 00000000000..bc65708881b --- /dev/null +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnostics.kt @@ -0,0 +1,745 @@ +/* + * 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.idea.frontend.api.fir.diagnostics + +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiTypeElement +import org.jetbrains.kotlin.contracts.description.EventOccurrencesRange +import org.jetbrains.kotlin.descriptors.Visibility +import org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnosticWithPsi +import org.jetbrains.kotlin.idea.frontend.api.symbols.KtClassLikeSymbol +import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol +import org.jetbrains.kotlin.idea.frontend.api.symbols.KtTypeParameterSymbol +import org.jetbrains.kotlin.idea.frontend.api.symbols.KtVariableSymbol +import org.jetbrains.kotlin.idea.frontend.api.types.KtType +import org.jetbrains.kotlin.lexer.KtModifierKeywordToken +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.psi.KtClassOrObject +import org.jetbrains.kotlin.psi.KtDeclaration +import org.jetbrains.kotlin.psi.KtDestructuringDeclaration +import org.jetbrains.kotlin.psi.KtExpression +import org.jetbrains.kotlin.psi.KtFunction +import org.jetbrains.kotlin.psi.KtModifierListOwner +import org.jetbrains.kotlin.psi.KtNamedDeclaration +import org.jetbrains.kotlin.psi.KtParameter +import org.jetbrains.kotlin.psi.KtProperty +import org.jetbrains.kotlin.psi.KtPropertyAccessor +import org.jetbrains.kotlin.psi.KtPropertyDelegate +import org.jetbrains.kotlin.psi.KtTypeReference + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +sealed class KtFirDiagnostic : KtDiagnosticWithPsi { + abstract class Syntax : KtFirDiagnostic() { + override val diagnosticClass get() = Syntax::class + } + + abstract class OtherError : KtFirDiagnostic() { + override val diagnosticClass get() = OtherError::class + } + + abstract class IllegalConstExpression : KtFirDiagnostic() { + override val diagnosticClass get() = IllegalConstExpression::class + } + + abstract class IllegalUnderscore : KtFirDiagnostic() { + override val diagnosticClass get() = IllegalUnderscore::class + } + + abstract class ExpressionRequired : KtFirDiagnostic() { + override val diagnosticClass get() = ExpressionRequired::class + } + + abstract class BreakOrContinueOutsideALoop : KtFirDiagnostic() { + override val diagnosticClass get() = BreakOrContinueOutsideALoop::class + } + + abstract class NotALoopLabel : KtFirDiagnostic() { + override val diagnosticClass get() = NotALoopLabel::class + } + + abstract class VariableExpected : KtFirDiagnostic() { + override val diagnosticClass get() = VariableExpected::class + } + + abstract class ReturnNotAllowed : KtFirDiagnostic() { + override val diagnosticClass get() = ReturnNotAllowed::class + } + + abstract class DelegationInInterface : KtFirDiagnostic() { + override val diagnosticClass get() = DelegationInInterface::class + } + + abstract class Hidden : KtFirDiagnostic() { + override val diagnosticClass get() = Hidden::class + abstract val hidden: KtSymbol + } + + abstract class UnresolvedReference : KtFirDiagnostic() { + override val diagnosticClass get() = UnresolvedReference::class + abstract val reference: String + } + + abstract class UnresolvedLabel : KtFirDiagnostic() { + override val diagnosticClass get() = UnresolvedLabel::class + } + + abstract class DeserializationError : KtFirDiagnostic() { + override val diagnosticClass get() = DeserializationError::class + } + + abstract class ErrorFromJavaResolution : KtFirDiagnostic() { + override val diagnosticClass get() = ErrorFromJavaResolution::class + } + + abstract class UnknownCallableKind : KtFirDiagnostic() { + override val diagnosticClass get() = UnknownCallableKind::class + } + + abstract class MissingStdlibClass : KtFirDiagnostic() { + override val diagnosticClass get() = MissingStdlibClass::class + } + + abstract class NoThis : KtFirDiagnostic() { + override val diagnosticClass get() = NoThis::class + } + + abstract class SuperIsNotAnExpression : KtFirDiagnostic() { + override val diagnosticClass get() = SuperIsNotAnExpression::class + } + + abstract class SuperNotAvailable : KtFirDiagnostic() { + override val diagnosticClass get() = SuperNotAvailable::class + } + + abstract class AbstractSuperCall : KtFirDiagnostic() { + override val diagnosticClass get() = AbstractSuperCall::class + } + + abstract class InstanceAccessBeforeSuperCall : KtFirDiagnostic() { + override val diagnosticClass get() = InstanceAccessBeforeSuperCall::class + abstract val target: String + } + + abstract class TypeParameterAsSupertype : KtFirDiagnostic() { + override val diagnosticClass get() = TypeParameterAsSupertype::class + } + + abstract class EnumAsSupertype : KtFirDiagnostic() { + override val diagnosticClass get() = EnumAsSupertype::class + } + + abstract class RecursionInSupertypes : KtFirDiagnostic() { + override val diagnosticClass get() = RecursionInSupertypes::class + } + + abstract class NotASupertype : KtFirDiagnostic() { + override val diagnosticClass get() = NotASupertype::class + } + + abstract class SuperclassNotAccessibleFromInterface : KtFirDiagnostic() { + override val diagnosticClass get() = SuperclassNotAccessibleFromInterface::class + } + + abstract class QualifiedSupertypeExtendedByOtherSupertype : KtFirDiagnostic() { + override val diagnosticClass get() = QualifiedSupertypeExtendedByOtherSupertype::class + abstract val otherSuperType: KtClassLikeSymbol + } + + abstract class SupertypeInitializedInInterface : KtFirDiagnostic() { + override val diagnosticClass get() = SupertypeInitializedInInterface::class + } + + abstract class InterfaceWithSuperclass : KtFirDiagnostic() { + override val diagnosticClass get() = InterfaceWithSuperclass::class + } + + abstract class ClassInSupertypeForEnum : KtFirDiagnostic() { + override val diagnosticClass get() = ClassInSupertypeForEnum::class + } + + abstract class SealedSupertype : KtFirDiagnostic() { + override val diagnosticClass get() = SealedSupertype::class + } + + abstract class SealedSupertypeInLocalClass : KtFirDiagnostic() { + override val diagnosticClass get() = SealedSupertypeInLocalClass::class + } + + abstract class ConstructorInObject : KtFirDiagnostic() { + override val diagnosticClass get() = ConstructorInObject::class + abstract override val psi: KtDeclaration + } + + abstract class ConstructorInInterface : KtFirDiagnostic() { + override val diagnosticClass get() = ConstructorInInterface::class + abstract override val psi: KtDeclaration + } + + abstract class NonPrivateConstructorInEnum : KtFirDiagnostic() { + override val diagnosticClass get() = NonPrivateConstructorInEnum::class + } + + abstract class NonPrivateConstructorInSealed : KtFirDiagnostic() { + override val diagnosticClass get() = NonPrivateConstructorInSealed::class + } + + abstract class CyclicConstructorDelegationCall : KtFirDiagnostic() { + override val diagnosticClass get() = CyclicConstructorDelegationCall::class + } + + abstract class PrimaryConstructorDelegationCallExpected : KtFirDiagnostic() { + override val diagnosticClass get() = PrimaryConstructorDelegationCallExpected::class + } + + abstract class SupertypeInitializedWithoutPrimaryConstructor : KtFirDiagnostic() { + override val diagnosticClass get() = SupertypeInitializedWithoutPrimaryConstructor::class + } + + abstract class DelegationSuperCallInEnumConstructor : KtFirDiagnostic() { + override val diagnosticClass get() = DelegationSuperCallInEnumConstructor::class + } + + abstract class PrimaryConstructorRequiredForDataClass : KtFirDiagnostic() { + override val diagnosticClass get() = PrimaryConstructorRequiredForDataClass::class + } + + abstract class ExplicitDelegationCallRequired : KtFirDiagnostic() { + override val diagnosticClass get() = ExplicitDelegationCallRequired::class + } + + abstract class SealedClassConstructorCall : KtFirDiagnostic() { + override val diagnosticClass get() = SealedClassConstructorCall::class + } + + abstract class AnnotationArgumentKclassLiteralOfTypeParameterError : KtFirDiagnostic() { + override val diagnosticClass get() = AnnotationArgumentKclassLiteralOfTypeParameterError::class + abstract override val psi: KtExpression + } + + abstract class AnnotationArgumentMustBeConst : KtFirDiagnostic() { + override val diagnosticClass get() = AnnotationArgumentMustBeConst::class + abstract override val psi: KtExpression + } + + abstract class AnnotationArgumentMustBeEnumConst : KtFirDiagnostic() { + override val diagnosticClass get() = AnnotationArgumentMustBeEnumConst::class + abstract override val psi: KtExpression + } + + abstract class AnnotationArgumentMustBeKclassLiteral : KtFirDiagnostic() { + override val diagnosticClass get() = AnnotationArgumentMustBeKclassLiteral::class + abstract override val psi: KtExpression + } + + abstract class AnnotationClassMember : KtFirDiagnostic() { + override val diagnosticClass get() = AnnotationClassMember::class + } + + abstract class AnnotationParameterDefaultValueMustBeConstant : KtFirDiagnostic() { + override val diagnosticClass get() = AnnotationParameterDefaultValueMustBeConstant::class + abstract override val psi: KtExpression + } + + abstract class InvalidTypeOfAnnotationMember : KtFirDiagnostic() { + override val diagnosticClass get() = InvalidTypeOfAnnotationMember::class + abstract override val psi: KtTypeReference + } + + abstract class LocalAnnotationClassError : KtFirDiagnostic() { + override val diagnosticClass get() = LocalAnnotationClassError::class + abstract override val psi: KtClassOrObject + } + + abstract class MissingValOnAnnotationParameter : KtFirDiagnostic() { + override val diagnosticClass get() = MissingValOnAnnotationParameter::class + abstract override val psi: KtParameter + } + + abstract class NonConstValUsedInConstantExpression : KtFirDiagnostic() { + override val diagnosticClass get() = NonConstValUsedInConstantExpression::class + abstract override val psi: KtExpression + } + + abstract class NotAnAnnotationClass : KtFirDiagnostic() { + override val diagnosticClass get() = NotAnAnnotationClass::class + abstract val annotationName: String + } + + abstract class NullableTypeOfAnnotationMember : KtFirDiagnostic() { + override val diagnosticClass get() = NullableTypeOfAnnotationMember::class + abstract override val psi: KtTypeReference + } + + abstract class VarAnnotationParameter : KtFirDiagnostic() { + override val diagnosticClass get() = VarAnnotationParameter::class + abstract override val psi: KtParameter + } + + abstract class ExposedTypealiasExpandedType : KtFirDiagnostic() { + override val diagnosticClass get() = ExposedTypealiasExpandedType::class + abstract override val psi: KtNamedDeclaration + abstract val elementVisibility: Visibility + abstract val restrictingDeclaration: KtSymbol + abstract val restrictingVisibility: Visibility + } + + abstract class ExposedFunctionReturnType : KtFirDiagnostic() { + override val diagnosticClass get() = ExposedFunctionReturnType::class + abstract override val psi: KtNamedDeclaration + abstract val elementVisibility: Visibility + abstract val restrictingDeclaration: KtSymbol + abstract val restrictingVisibility: Visibility + } + + abstract class ExposedReceiverType : KtFirDiagnostic() { + override val diagnosticClass get() = ExposedReceiverType::class + abstract override val psi: KtTypeReference + abstract val elementVisibility: Visibility + abstract val restrictingDeclaration: KtSymbol + abstract val restrictingVisibility: Visibility + } + + abstract class ExposedPropertyType : KtFirDiagnostic() { + override val diagnosticClass get() = ExposedPropertyType::class + abstract override val psi: KtNamedDeclaration + abstract val elementVisibility: Visibility + abstract val restrictingDeclaration: KtSymbol + abstract val restrictingVisibility: Visibility + } + + abstract class ExposedParameterType : KtFirDiagnostic() { + override val diagnosticClass get() = ExposedParameterType::class + abstract override val psi: KtParameter + abstract val elementVisibility: Visibility + abstract val restrictingDeclaration: KtSymbol + abstract val restrictingVisibility: Visibility + } + + abstract class ExposedSuperInterface : KtFirDiagnostic() { + override val diagnosticClass get() = ExposedSuperInterface::class + abstract override val psi: KtTypeReference + abstract val elementVisibility: Visibility + abstract val restrictingDeclaration: KtSymbol + abstract val restrictingVisibility: Visibility + } + + abstract class ExposedSuperClass : KtFirDiagnostic() { + override val diagnosticClass get() = ExposedSuperClass::class + abstract override val psi: KtTypeReference + abstract val elementVisibility: Visibility + abstract val restrictingDeclaration: KtSymbol + abstract val restrictingVisibility: Visibility + } + + abstract class ExposedTypeParameterBound : KtFirDiagnostic() { + override val diagnosticClass get() = ExposedTypeParameterBound::class + abstract override val psi: KtTypeReference + abstract val elementVisibility: Visibility + abstract val restrictingDeclaration: KtSymbol + abstract val restrictingVisibility: Visibility + } + + abstract class InapplicableInfixModifier : KtFirDiagnostic() { + override val diagnosticClass get() = InapplicableInfixModifier::class + abstract val modifier: String + } + + abstract class RepeatedModifier : KtFirDiagnostic() { + override val diagnosticClass get() = RepeatedModifier::class + abstract val modifier: KtModifierKeywordToken + } + + abstract class RedundantModifier : KtFirDiagnostic() { + override val diagnosticClass get() = RedundantModifier::class + abstract val redundantModifier: KtModifierKeywordToken + abstract val conflictingModifier: KtModifierKeywordToken + } + + abstract class DeprecatedModifierPair : KtFirDiagnostic() { + override val diagnosticClass get() = DeprecatedModifierPair::class + abstract val deprecatedModifier: KtModifierKeywordToken + abstract val conflictingModifier: KtModifierKeywordToken + } + + abstract class IncompatibleModifiers : KtFirDiagnostic() { + override val diagnosticClass get() = IncompatibleModifiers::class + abstract val modifier1: KtModifierKeywordToken + abstract val modifier2: KtModifierKeywordToken + } + + abstract class RedundantOpenInInterface : KtFirDiagnostic() { + override val diagnosticClass get() = RedundantOpenInInterface::class + abstract override val psi: KtModifierListOwner + } + + abstract class NoneApplicable : KtFirDiagnostic() { + override val diagnosticClass get() = NoneApplicable::class + abstract val candidates: List + } + + abstract class InapplicableCandidate : KtFirDiagnostic() { + override val diagnosticClass get() = InapplicableCandidate::class + abstract val candidate: KtSymbol + } + + abstract class InapplicableLateinitModifier : KtFirDiagnostic() { + override val diagnosticClass get() = InapplicableLateinitModifier::class + abstract val reason: String + } + + abstract class Ambiguity : KtFirDiagnostic() { + override val diagnosticClass get() = Ambiguity::class + abstract val candidates: List + } + + abstract class AssignOperatorAmbiguity : KtFirDiagnostic() { + override val diagnosticClass get() = AssignOperatorAmbiguity::class + abstract val candidates: List + } + + abstract class TypeMismatch : KtFirDiagnostic() { + override val diagnosticClass get() = TypeMismatch::class + abstract val expectedType: KtType + abstract val actualType: KtType + } + + abstract class RecursionInImplicitTypes : KtFirDiagnostic() { + override val diagnosticClass get() = RecursionInImplicitTypes::class + } + + abstract class InferenceError : KtFirDiagnostic() { + override val diagnosticClass get() = InferenceError::class + } + + abstract class ProjectionOnNonClassTypeArgument : KtFirDiagnostic() { + override val diagnosticClass get() = ProjectionOnNonClassTypeArgument::class + } + + abstract class UpperBoundViolated : KtFirDiagnostic() { + override val diagnosticClass get() = UpperBoundViolated::class + abstract val typeParameter: KtTypeParameterSymbol + abstract val violatedType: KtType + } + + abstract class TypeArgumentsNotAllowed : KtFirDiagnostic() { + override val diagnosticClass get() = TypeArgumentsNotAllowed::class + } + + abstract class WrongNumberOfTypeArguments : KtFirDiagnostic() { + override val diagnosticClass get() = WrongNumberOfTypeArguments::class + abstract val expectedCount: Int + abstract val classifier: KtClassLikeSymbol + } + + abstract class NoTypeForTypeParameter : KtFirDiagnostic() { + override val diagnosticClass get() = NoTypeForTypeParameter::class + } + + abstract class TypeParametersInObject : KtFirDiagnostic() { + override val diagnosticClass get() = TypeParametersInObject::class + } + + abstract class IllegalProjectionUsage : KtFirDiagnostic() { + override val diagnosticClass get() = IllegalProjectionUsage::class + } + + abstract class TypeParametersInEnum : KtFirDiagnostic() { + override val diagnosticClass get() = TypeParametersInEnum::class + } + + abstract class ConflictingProjection : KtFirDiagnostic() { + override val diagnosticClass get() = ConflictingProjection::class + abstract val type: String + } + + abstract class VarianceOnTypeParameterNotAllowed : KtFirDiagnostic() { + override val diagnosticClass get() = VarianceOnTypeParameterNotAllowed::class + } + + abstract class ReturnTypeMismatchOnOverride : KtFirDiagnostic() { + override val diagnosticClass get() = ReturnTypeMismatchOnOverride::class + abstract val returnType: String + abstract val superFunction: KtSymbol + } + + abstract class PropertyTypeMismatchOnOverride : KtFirDiagnostic() { + override val diagnosticClass get() = PropertyTypeMismatchOnOverride::class + abstract val propertyType: String + abstract val targetProperty: KtSymbol + } + + abstract class VarTypeMismatchOnOverride : KtFirDiagnostic() { + override val diagnosticClass get() = VarTypeMismatchOnOverride::class + abstract val variableType: String + abstract val targetVariable: KtSymbol + } + + abstract class ManyCompanionObjects : KtFirDiagnostic() { + override val diagnosticClass get() = ManyCompanionObjects::class + } + + abstract class ConflictingOverloads : KtFirDiagnostic() { + override val diagnosticClass get() = ConflictingOverloads::class + abstract val conflictingOverloads: String + } + + abstract class Redeclaration : KtFirDiagnostic() { + override val diagnosticClass get() = Redeclaration::class + abstract val conflictingDeclaration: String + } + + abstract class AnyMethodImplementedInInterface : KtFirDiagnostic() { + override val diagnosticClass get() = AnyMethodImplementedInInterface::class + } + + abstract class LocalObjectNotAllowed : KtFirDiagnostic() { + override val diagnosticClass get() = LocalObjectNotAllowed::class + abstract override val psi: KtNamedDeclaration + abstract val objectName: Name + } + + abstract class LocalInterfaceNotAllowed : KtFirDiagnostic() { + override val diagnosticClass get() = LocalInterfaceNotAllowed::class + abstract override val psi: KtNamedDeclaration + abstract val interfaceName: Name + } + + abstract class AbstractFunctionInNonAbstractClass : KtFirDiagnostic() { + override val diagnosticClass get() = AbstractFunctionInNonAbstractClass::class + abstract override val psi: KtFunction + abstract val function: KtSymbol + abstract val containingClass: KtSymbol + } + + abstract class AbstractFunctionWithBody : KtFirDiagnostic() { + override val diagnosticClass get() = AbstractFunctionWithBody::class + abstract override val psi: KtFunction + abstract val function: KtSymbol + } + + abstract class NonAbstractFunctionWithNoBody : KtFirDiagnostic() { + override val diagnosticClass get() = NonAbstractFunctionWithNoBody::class + abstract override val psi: KtFunction + abstract val function: KtSymbol + } + + abstract class PrivateFunctionWithNoBody : KtFirDiagnostic() { + override val diagnosticClass get() = PrivateFunctionWithNoBody::class + abstract override val psi: KtFunction + abstract val function: KtSymbol + } + + abstract class NonMemberFunctionNoBody : KtFirDiagnostic() { + override val diagnosticClass get() = NonMemberFunctionNoBody::class + abstract override val psi: KtFunction + abstract val function: KtSymbol + } + + abstract class FunctionDeclarationWithNoName : KtFirDiagnostic() { + override val diagnosticClass get() = FunctionDeclarationWithNoName::class + abstract override val psi: KtFunction + } + + abstract class AnonymousFunctionParameterWithDefaultValue : KtFirDiagnostic() { + override val diagnosticClass get() = AnonymousFunctionParameterWithDefaultValue::class + abstract override val psi: KtParameter + } + + abstract class UselessVarargOnParameter : KtFirDiagnostic() { + override val diagnosticClass get() = UselessVarargOnParameter::class + abstract override val psi: KtParameter + } + + abstract class AbstractPropertyInNonAbstractClass : KtFirDiagnostic() { + override val diagnosticClass get() = AbstractPropertyInNonAbstractClass::class + abstract override val psi: KtModifierListOwner + abstract val property: KtSymbol + abstract val containingClass: KtSymbol + } + + abstract class PrivatePropertyInInterface : KtFirDiagnostic() { + override val diagnosticClass get() = PrivatePropertyInInterface::class + abstract override val psi: KtProperty + } + + abstract class AbstractPropertyWithInitializer : KtFirDiagnostic() { + override val diagnosticClass get() = AbstractPropertyWithInitializer::class + abstract override val psi: KtExpression + } + + abstract class PropertyInitializerInInterface : KtFirDiagnostic() { + override val diagnosticClass get() = PropertyInitializerInInterface::class + abstract override val psi: KtExpression + } + + abstract class PropertyWithNoTypeNoInitializer : KtFirDiagnostic() { + override val diagnosticClass get() = PropertyWithNoTypeNoInitializer::class + abstract override val psi: KtProperty + } + + abstract class AbstractDelegatedProperty : KtFirDiagnostic() { + override val diagnosticClass get() = AbstractDelegatedProperty::class + abstract override val psi: KtPropertyDelegate + } + + abstract class DelegatedPropertyInInterface : KtFirDiagnostic() { + override val diagnosticClass get() = DelegatedPropertyInInterface::class + abstract override val psi: KtPropertyDelegate + } + + abstract class AbstractPropertyWithGetter : KtFirDiagnostic() { + override val diagnosticClass get() = AbstractPropertyWithGetter::class + abstract override val psi: KtPropertyAccessor + } + + abstract class AbstractPropertyWithSetter : KtFirDiagnostic() { + override val diagnosticClass get() = AbstractPropertyWithSetter::class + abstract override val psi: KtPropertyAccessor + } + + abstract class PrivateSetterForAbstractProperty : KtFirDiagnostic() { + override val diagnosticClass get() = PrivateSetterForAbstractProperty::class + } + + abstract class PrivateSetterForOpenProperty : KtFirDiagnostic() { + override val diagnosticClass get() = PrivateSetterForOpenProperty::class + } + + abstract class ExpectedPrivateDeclaration : KtFirDiagnostic() { + override val diagnosticClass get() = ExpectedPrivateDeclaration::class + abstract override val psi: KtModifierListOwner + } + + abstract class ExpectedDeclarationWithBody : KtFirDiagnostic() { + override val diagnosticClass get() = ExpectedDeclarationWithBody::class + abstract override val psi: KtDeclaration + } + + abstract class ExpectedPropertyInitializer : KtFirDiagnostic() { + override val diagnosticClass get() = ExpectedPropertyInitializer::class + abstract override val psi: KtExpression + } + + abstract class ExpectedDelegatedProperty : KtFirDiagnostic() { + override val diagnosticClass get() = ExpectedDelegatedProperty::class + abstract override val psi: KtPropertyDelegate + } + + abstract class InitializerRequiredForDestructuringDeclaration : KtFirDiagnostic() { + override val diagnosticClass get() = InitializerRequiredForDestructuringDeclaration::class + abstract override val psi: KtDestructuringDeclaration + } + + abstract class ComponentFunctionMissing : KtFirDiagnostic() { + override val diagnosticClass get() = ComponentFunctionMissing::class + abstract val missingFunctionName: Name + abstract val destructingType: KtType + } + + abstract class ComponentFunctionAmbiguity : KtFirDiagnostic() { + override val diagnosticClass get() = ComponentFunctionAmbiguity::class + abstract val functionWithAmbiguityName: Name + abstract val candidates: List + } + + abstract class UninitializedVariable : KtFirDiagnostic() { + override val diagnosticClass get() = UninitializedVariable::class + abstract val variable: KtVariableSymbol + } + + abstract class WrongInvocationKind : KtFirDiagnostic() { + override val diagnosticClass get() = WrongInvocationKind::class + abstract val declaration: KtSymbol + abstract val requiredRange: EventOccurrencesRange + abstract val actualRange: EventOccurrencesRange + } + + abstract class LeakedInPlaceLambda : KtFirDiagnostic() { + override val diagnosticClass get() = LeakedInPlaceLambda::class + abstract val lambda: KtSymbol + } + + abstract class WrongImpliesCondition : KtFirDiagnostic() { + override val diagnosticClass get() = WrongImpliesCondition::class + } + + abstract class RedundantVisibilityModifier : KtFirDiagnostic() { + override val diagnosticClass get() = RedundantVisibilityModifier::class + abstract override val psi: KtModifierListOwner + } + + abstract class RedundantModalityModifier : KtFirDiagnostic() { + override val diagnosticClass get() = RedundantModalityModifier::class + abstract override val psi: KtModifierListOwner + } + + abstract class RedundantReturnUnitType : KtFirDiagnostic() { + override val diagnosticClass get() = RedundantReturnUnitType::class + abstract override val psi: PsiTypeElement + } + + abstract class RedundantExplicitType : KtFirDiagnostic() { + override val diagnosticClass get() = RedundantExplicitType::class + } + + abstract class RedundantSingleExpressionStringTemplate : KtFirDiagnostic() { + override val diagnosticClass get() = RedundantSingleExpressionStringTemplate::class + } + + abstract class CanBeVal : KtFirDiagnostic() { + override val diagnosticClass get() = CanBeVal::class + abstract override val psi: KtDeclaration + } + + abstract class CanBeReplacedWithOperatorAssignment : KtFirDiagnostic() { + override val diagnosticClass get() = CanBeReplacedWithOperatorAssignment::class + abstract override val psi: KtExpression + } + + abstract class RedundantCallOfConversionMethod : KtFirDiagnostic() { + override val diagnosticClass get() = RedundantCallOfConversionMethod::class + } + + abstract class ArrayEqualityOperatorCanBeReplacedWithEquals : KtFirDiagnostic() { + override val diagnosticClass get() = ArrayEqualityOperatorCanBeReplacedWithEquals::class + abstract override val psi: KtExpression + } + + abstract class EmptyRange : KtFirDiagnostic() { + override val diagnosticClass get() = EmptyRange::class + } + + abstract class RedundantSetterParameterType : KtFirDiagnostic() { + override val diagnosticClass get() = RedundantSetterParameterType::class + } + + abstract class UnusedVariable : KtFirDiagnostic() { + override val diagnosticClass get() = UnusedVariable::class + abstract override val psi: KtNamedDeclaration + } + + abstract class AssignedValueIsNeverRead : KtFirDiagnostic() { + override val diagnosticClass get() = AssignedValueIsNeverRead::class + } + + abstract class VariableInitializerIsRedundant : KtFirDiagnostic() { + override val diagnosticClass get() = VariableInitializerIsRedundant::class + } + + abstract class VariableNeverRead : KtFirDiagnostic() { + override val diagnosticClass get() = VariableNeverRead::class + abstract override val psi: KtNamedDeclaration + } + + abstract class UselessCallOnNotNull : KtFirDiagnostic() { + override val diagnosticClass get() = UselessCallOnNotNull::class + } + +} diff --git a/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt new file mode 100644 index 00000000000..5271354068b --- /dev/null +++ b/idea/idea-frontend-fir/src/org/jetbrains/kotlin/idea/frontend/api/fir/diagnostics/KtFirDiagnosticsImpl.kt @@ -0,0 +1,1267 @@ +/* + * 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.idea.frontend.api.fir.diagnostics + +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiTypeElement +import org.jetbrains.kotlin.contracts.description.EventOccurrencesRange +import org.jetbrains.kotlin.descriptors.Visibility +import org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic +import org.jetbrains.kotlin.idea.frontend.api.ValidityToken +import org.jetbrains.kotlin.idea.frontend.api.fir.utils.weakRef +import org.jetbrains.kotlin.idea.frontend.api.symbols.KtClassLikeSymbol +import org.jetbrains.kotlin.idea.frontend.api.symbols.KtSymbol +import org.jetbrains.kotlin.idea.frontend.api.symbols.KtTypeParameterSymbol +import org.jetbrains.kotlin.idea.frontend.api.symbols.KtVariableSymbol +import org.jetbrains.kotlin.idea.frontend.api.types.KtType +import org.jetbrains.kotlin.lexer.KtModifierKeywordToken +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.psi.KtClassOrObject +import org.jetbrains.kotlin.psi.KtDeclaration +import org.jetbrains.kotlin.psi.KtDestructuringDeclaration +import org.jetbrains.kotlin.psi.KtExpression +import org.jetbrains.kotlin.psi.KtFunction +import org.jetbrains.kotlin.psi.KtModifierListOwner +import org.jetbrains.kotlin.psi.KtNamedDeclaration +import org.jetbrains.kotlin.psi.KtParameter +import org.jetbrains.kotlin.psi.KtProperty +import org.jetbrains.kotlin.psi.KtPropertyAccessor +import org.jetbrains.kotlin.psi.KtPropertyDelegate +import org.jetbrains.kotlin.psi.KtTypeReference + +/* + * This file was generated automatically + * DO NOT MODIFY IT MANUALLY + */ + +internal class SyntaxImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.Syntax(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class OtherErrorImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.OtherError(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class IllegalConstExpressionImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.IllegalConstExpression(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class IllegalUnderscoreImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.IllegalUnderscore(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class ExpressionRequiredImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ExpressionRequired(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class BreakOrContinueOutsideALoopImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.BreakOrContinueOutsideALoop(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class NotALoopLabelImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.NotALoopLabel(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class VariableExpectedImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.VariableExpected(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class ReturnNotAllowedImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ReturnNotAllowed(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class DelegationInInterfaceImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.DelegationInInterface(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class HiddenImpl( + override val hidden: KtSymbol, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.Hidden(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class UnresolvedReferenceImpl( + override val reference: String, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.UnresolvedReference(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class UnresolvedLabelImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.UnresolvedLabel(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class DeserializationErrorImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.DeserializationError(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class ErrorFromJavaResolutionImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ErrorFromJavaResolution(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class UnknownCallableKindImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.UnknownCallableKind(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class MissingStdlibClassImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.MissingStdlibClass(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class NoThisImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.NoThis(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class SuperIsNotAnExpressionImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.SuperIsNotAnExpression(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class SuperNotAvailableImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.SuperNotAvailable(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class AbstractSuperCallImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.AbstractSuperCall(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class InstanceAccessBeforeSuperCallImpl( + override val target: String, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.InstanceAccessBeforeSuperCall(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class TypeParameterAsSupertypeImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.TypeParameterAsSupertype(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class EnumAsSupertypeImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.EnumAsSupertype(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class RecursionInSupertypesImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.RecursionInSupertypes(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class NotASupertypeImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.NotASupertype(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class SuperclassNotAccessibleFromInterfaceImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.SuperclassNotAccessibleFromInterface(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class QualifiedSupertypeExtendedByOtherSupertypeImpl( + override val otherSuperType: KtClassLikeSymbol, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.QualifiedSupertypeExtendedByOtherSupertype(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class SupertypeInitializedInInterfaceImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.SupertypeInitializedInInterface(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class InterfaceWithSuperclassImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.InterfaceWithSuperclass(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class ClassInSupertypeForEnumImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ClassInSupertypeForEnum(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class SealedSupertypeImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.SealedSupertype(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class SealedSupertypeInLocalClassImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.SealedSupertypeInLocalClass(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class ConstructorInObjectImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ConstructorInObject(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtDeclaration get() = super.psi as KtDeclaration +} + +internal class ConstructorInInterfaceImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ConstructorInInterface(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtDeclaration get() = super.psi as KtDeclaration +} + +internal class NonPrivateConstructorInEnumImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.NonPrivateConstructorInEnum(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class NonPrivateConstructorInSealedImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.NonPrivateConstructorInSealed(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class CyclicConstructorDelegationCallImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.CyclicConstructorDelegationCall(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class PrimaryConstructorDelegationCallExpectedImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.PrimaryConstructorDelegationCallExpected(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class SupertypeInitializedWithoutPrimaryConstructorImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.SupertypeInitializedWithoutPrimaryConstructor(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class DelegationSuperCallInEnumConstructorImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.DelegationSuperCallInEnumConstructor(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class PrimaryConstructorRequiredForDataClassImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.PrimaryConstructorRequiredForDataClass(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class ExplicitDelegationCallRequiredImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ExplicitDelegationCallRequired(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class SealedClassConstructorCallImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.SealedClassConstructorCall(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class AnnotationArgumentKclassLiteralOfTypeParameterErrorImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.AnnotationArgumentKclassLiteralOfTypeParameterError(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtExpression get() = super.psi as KtExpression +} + +internal class AnnotationArgumentMustBeConstImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.AnnotationArgumentMustBeConst(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtExpression get() = super.psi as KtExpression +} + +internal class AnnotationArgumentMustBeEnumConstImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.AnnotationArgumentMustBeEnumConst(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtExpression get() = super.psi as KtExpression +} + +internal class AnnotationArgumentMustBeKclassLiteralImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.AnnotationArgumentMustBeKclassLiteral(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtExpression get() = super.psi as KtExpression +} + +internal class AnnotationClassMemberImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.AnnotationClassMember(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class AnnotationParameterDefaultValueMustBeConstantImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.AnnotationParameterDefaultValueMustBeConstant(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtExpression get() = super.psi as KtExpression +} + +internal class InvalidTypeOfAnnotationMemberImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.InvalidTypeOfAnnotationMember(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtTypeReference get() = super.psi as KtTypeReference +} + +internal class LocalAnnotationClassErrorImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.LocalAnnotationClassError(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtClassOrObject get() = super.psi as KtClassOrObject +} + +internal class MissingValOnAnnotationParameterImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.MissingValOnAnnotationParameter(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtParameter get() = super.psi as KtParameter +} + +internal class NonConstValUsedInConstantExpressionImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.NonConstValUsedInConstantExpression(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtExpression get() = super.psi as KtExpression +} + +internal class NotAnAnnotationClassImpl( + override val annotationName: String, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.NotAnAnnotationClass(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class NullableTypeOfAnnotationMemberImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.NullableTypeOfAnnotationMember(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtTypeReference get() = super.psi as KtTypeReference +} + +internal class VarAnnotationParameterImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.VarAnnotationParameter(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtParameter get() = super.psi as KtParameter +} + +internal class ExposedTypealiasExpandedTypeImpl( + override val elementVisibility: Visibility, + override val restrictingDeclaration: KtSymbol, + override val restrictingVisibility: Visibility, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ExposedTypealiasExpandedType(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtNamedDeclaration get() = super.psi as KtNamedDeclaration +} + +internal class ExposedFunctionReturnTypeImpl( + override val elementVisibility: Visibility, + override val restrictingDeclaration: KtSymbol, + override val restrictingVisibility: Visibility, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ExposedFunctionReturnType(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtNamedDeclaration get() = super.psi as KtNamedDeclaration +} + +internal class ExposedReceiverTypeImpl( + override val elementVisibility: Visibility, + override val restrictingDeclaration: KtSymbol, + override val restrictingVisibility: Visibility, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ExposedReceiverType(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtTypeReference get() = super.psi as KtTypeReference +} + +internal class ExposedPropertyTypeImpl( + override val elementVisibility: Visibility, + override val restrictingDeclaration: KtSymbol, + override val restrictingVisibility: Visibility, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ExposedPropertyType(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtNamedDeclaration get() = super.psi as KtNamedDeclaration +} + +internal class ExposedParameterTypeImpl( + override val elementVisibility: Visibility, + override val restrictingDeclaration: KtSymbol, + override val restrictingVisibility: Visibility, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ExposedParameterType(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtParameter get() = super.psi as KtParameter +} + +internal class ExposedSuperInterfaceImpl( + override val elementVisibility: Visibility, + override val restrictingDeclaration: KtSymbol, + override val restrictingVisibility: Visibility, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ExposedSuperInterface(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtTypeReference get() = super.psi as KtTypeReference +} + +internal class ExposedSuperClassImpl( + override val elementVisibility: Visibility, + override val restrictingDeclaration: KtSymbol, + override val restrictingVisibility: Visibility, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ExposedSuperClass(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtTypeReference get() = super.psi as KtTypeReference +} + +internal class ExposedTypeParameterBoundImpl( + override val elementVisibility: Visibility, + override val restrictingDeclaration: KtSymbol, + override val restrictingVisibility: Visibility, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ExposedTypeParameterBound(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtTypeReference get() = super.psi as KtTypeReference +} + +internal class InapplicableInfixModifierImpl( + override val modifier: String, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.InapplicableInfixModifier(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class RepeatedModifierImpl( + override val modifier: KtModifierKeywordToken, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.RepeatedModifier(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class RedundantModifierImpl( + override val redundantModifier: KtModifierKeywordToken, + override val conflictingModifier: KtModifierKeywordToken, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.RedundantModifier(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class DeprecatedModifierPairImpl( + override val deprecatedModifier: KtModifierKeywordToken, + override val conflictingModifier: KtModifierKeywordToken, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.DeprecatedModifierPair(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class IncompatibleModifiersImpl( + override val modifier1: KtModifierKeywordToken, + override val modifier2: KtModifierKeywordToken, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.IncompatibleModifiers(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class RedundantOpenInInterfaceImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.RedundantOpenInInterface(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtModifierListOwner get() = super.psi as KtModifierListOwner +} + +internal class NoneApplicableImpl( + override val candidates: List, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.NoneApplicable(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class InapplicableCandidateImpl( + override val candidate: KtSymbol, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.InapplicableCandidate(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class InapplicableLateinitModifierImpl( + override val reason: String, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.InapplicableLateinitModifier(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class AmbiguityImpl( + override val candidates: List, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.Ambiguity(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class AssignOperatorAmbiguityImpl( + override val candidates: List, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.AssignOperatorAmbiguity(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class TypeMismatchImpl( + override val expectedType: KtType, + override val actualType: KtType, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.TypeMismatch(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class RecursionInImplicitTypesImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.RecursionInImplicitTypes(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class InferenceErrorImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.InferenceError(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class ProjectionOnNonClassTypeArgumentImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ProjectionOnNonClassTypeArgument(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class UpperBoundViolatedImpl( + override val typeParameter: KtTypeParameterSymbol, + override val violatedType: KtType, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.UpperBoundViolated(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class TypeArgumentsNotAllowedImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.TypeArgumentsNotAllowed(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class WrongNumberOfTypeArgumentsImpl( + override val expectedCount: Int, + override val classifier: KtClassLikeSymbol, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.WrongNumberOfTypeArguments(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class NoTypeForTypeParameterImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.NoTypeForTypeParameter(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class TypeParametersInObjectImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.TypeParametersInObject(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class IllegalProjectionUsageImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.IllegalProjectionUsage(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class TypeParametersInEnumImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.TypeParametersInEnum(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class ConflictingProjectionImpl( + override val type: String, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ConflictingProjection(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class VarianceOnTypeParameterNotAllowedImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.VarianceOnTypeParameterNotAllowed(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class ReturnTypeMismatchOnOverrideImpl( + override val returnType: String, + override val superFunction: KtSymbol, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ReturnTypeMismatchOnOverride(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class PropertyTypeMismatchOnOverrideImpl( + override val propertyType: String, + override val targetProperty: KtSymbol, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.PropertyTypeMismatchOnOverride(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class VarTypeMismatchOnOverrideImpl( + override val variableType: String, + override val targetVariable: KtSymbol, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.VarTypeMismatchOnOverride(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class ManyCompanionObjectsImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ManyCompanionObjects(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class ConflictingOverloadsImpl( + override val conflictingOverloads: String, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ConflictingOverloads(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class RedeclarationImpl( + override val conflictingDeclaration: String, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.Redeclaration(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class AnyMethodImplementedInInterfaceImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.AnyMethodImplementedInInterface(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class LocalObjectNotAllowedImpl( + override val objectName: Name, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.LocalObjectNotAllowed(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtNamedDeclaration get() = super.psi as KtNamedDeclaration +} + +internal class LocalInterfaceNotAllowedImpl( + override val interfaceName: Name, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.LocalInterfaceNotAllowed(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtNamedDeclaration get() = super.psi as KtNamedDeclaration +} + +internal class AbstractFunctionInNonAbstractClassImpl( + override val function: KtSymbol, + override val containingClass: KtSymbol, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.AbstractFunctionInNonAbstractClass(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtFunction get() = super.psi as KtFunction +} + +internal class AbstractFunctionWithBodyImpl( + override val function: KtSymbol, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.AbstractFunctionWithBody(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtFunction get() = super.psi as KtFunction +} + +internal class NonAbstractFunctionWithNoBodyImpl( + override val function: KtSymbol, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.NonAbstractFunctionWithNoBody(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtFunction get() = super.psi as KtFunction +} + +internal class PrivateFunctionWithNoBodyImpl( + override val function: KtSymbol, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.PrivateFunctionWithNoBody(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtFunction get() = super.psi as KtFunction +} + +internal class NonMemberFunctionNoBodyImpl( + override val function: KtSymbol, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.NonMemberFunctionNoBody(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtFunction get() = super.psi as KtFunction +} + +internal class FunctionDeclarationWithNoNameImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.FunctionDeclarationWithNoName(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtFunction get() = super.psi as KtFunction +} + +internal class AnonymousFunctionParameterWithDefaultValueImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.AnonymousFunctionParameterWithDefaultValue(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtParameter get() = super.psi as KtParameter +} + +internal class UselessVarargOnParameterImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.UselessVarargOnParameter(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtParameter get() = super.psi as KtParameter +} + +internal class AbstractPropertyInNonAbstractClassImpl( + override val property: KtSymbol, + override val containingClass: KtSymbol, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.AbstractPropertyInNonAbstractClass(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtModifierListOwner get() = super.psi as KtModifierListOwner +} + +internal class PrivatePropertyInInterfaceImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.PrivatePropertyInInterface(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtProperty get() = super.psi as KtProperty +} + +internal class AbstractPropertyWithInitializerImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.AbstractPropertyWithInitializer(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtExpression get() = super.psi as KtExpression +} + +internal class PropertyInitializerInInterfaceImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.PropertyInitializerInInterface(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtExpression get() = super.psi as KtExpression +} + +internal class PropertyWithNoTypeNoInitializerImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.PropertyWithNoTypeNoInitializer(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtProperty get() = super.psi as KtProperty +} + +internal class AbstractDelegatedPropertyImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.AbstractDelegatedProperty(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtPropertyDelegate get() = super.psi as KtPropertyDelegate +} + +internal class DelegatedPropertyInInterfaceImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.DelegatedPropertyInInterface(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtPropertyDelegate get() = super.psi as KtPropertyDelegate +} + +internal class AbstractPropertyWithGetterImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.AbstractPropertyWithGetter(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtPropertyAccessor get() = super.psi as KtPropertyAccessor +} + +internal class AbstractPropertyWithSetterImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.AbstractPropertyWithSetter(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtPropertyAccessor get() = super.psi as KtPropertyAccessor +} + +internal class PrivateSetterForAbstractPropertyImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.PrivateSetterForAbstractProperty(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class PrivateSetterForOpenPropertyImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.PrivateSetterForOpenProperty(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class ExpectedPrivateDeclarationImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ExpectedPrivateDeclaration(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtModifierListOwner get() = super.psi as KtModifierListOwner +} + +internal class ExpectedDeclarationWithBodyImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ExpectedDeclarationWithBody(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtDeclaration get() = super.psi as KtDeclaration +} + +internal class ExpectedPropertyInitializerImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ExpectedPropertyInitializer(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtExpression get() = super.psi as KtExpression +} + +internal class ExpectedDelegatedPropertyImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ExpectedDelegatedProperty(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtPropertyDelegate get() = super.psi as KtPropertyDelegate +} + +internal class InitializerRequiredForDestructuringDeclarationImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.InitializerRequiredForDestructuringDeclaration(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtDestructuringDeclaration get() = super.psi as KtDestructuringDeclaration +} + +internal class ComponentFunctionMissingImpl( + override val missingFunctionName: Name, + override val destructingType: KtType, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ComponentFunctionMissing(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class ComponentFunctionAmbiguityImpl( + override val functionWithAmbiguityName: Name, + override val candidates: List, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ComponentFunctionAmbiguity(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class UninitializedVariableImpl( + override val variable: KtVariableSymbol, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.UninitializedVariable(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class WrongInvocationKindImpl( + override val declaration: KtSymbol, + override val requiredRange: EventOccurrencesRange, + override val actualRange: EventOccurrencesRange, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.WrongInvocationKind(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class LeakedInPlaceLambdaImpl( + override val lambda: KtSymbol, + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.LeakedInPlaceLambda(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class WrongImpliesConditionImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.WrongImpliesCondition(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class RedundantVisibilityModifierImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.RedundantVisibilityModifier(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtModifierListOwner get() = super.psi as KtModifierListOwner +} + +internal class RedundantModalityModifierImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.RedundantModalityModifier(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtModifierListOwner get() = super.psi as KtModifierListOwner +} + +internal class RedundantReturnUnitTypeImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.RedundantReturnUnitType(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiTypeElement get() = super.psi as PsiTypeElement +} + +internal class RedundantExplicitTypeImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.RedundantExplicitType(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class RedundantSingleExpressionStringTemplateImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.RedundantSingleExpressionStringTemplate(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class CanBeValImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.CanBeVal(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtDeclaration get() = super.psi as KtDeclaration +} + +internal class CanBeReplacedWithOperatorAssignmentImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.CanBeReplacedWithOperatorAssignment(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtExpression get() = super.psi as KtExpression +} + +internal class RedundantCallOfConversionMethodImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.RedundantCallOfConversionMethod(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class ArrayEqualityOperatorCanBeReplacedWithEqualsImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.ArrayEqualityOperatorCanBeReplacedWithEquals(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtExpression get() = super.psi as KtExpression +} + +internal class EmptyRangeImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.EmptyRange(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class RedundantSetterParameterTypeImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.RedundantSetterParameterType(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class UnusedVariableImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.UnusedVariable(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtNamedDeclaration get() = super.psi as KtNamedDeclaration +} + +internal class AssignedValueIsNeverReadImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.AssignedValueIsNeverRead(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class VariableInitializerIsRedundantImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.VariableInitializerIsRedundant(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + +internal class VariableNeverReadImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.VariableNeverRead(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: KtNamedDeclaration get() = super.psi as KtNamedDeclaration +} + +internal class UselessCallOnNotNullImpl( + firDiagnostic: FirPsiDiagnostic<*>, + override val token: ValidityToken, +) : KtFirDiagnostic.UselessCallOnNotNull(), KtAbstractFirDiagnostic { + override val firDiagnostic: FirPsiDiagnostic<*> by weakRef(firDiagnostic) + override val psi: PsiElement get() = super.psi +} + diff --git a/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/frontend/api/fir/AbstractResolveCallTest.kt b/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/frontend/api/fir/AbstractResolveCallTest.kt index 1e85eb52927..e8aca3d6b16 100644 --- a/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/frontend/api/fir/AbstractResolveCallTest.kt +++ b/idea/idea-frontend-fir/tests/org/jetbrains/kotlin/idea/frontend/api/fir/AbstractResolveCallTest.kt @@ -110,7 +110,7 @@ private fun KtCall.stringRepresentation(): String { } is KtParameterSymbol -> "$name: ${annotatedType.type.render()}" is KtSuccessCallTarget -> symbol.stringValue() - is KtErrorCallTarget -> "ERR<${this.diagnostic.message}, [${candidates.joinToString { it.stringValue() }}]>" + is KtErrorCallTarget -> "ERR<${this.diagnostic.defaultMessage}, [${candidates.joinToString { it.stringValue() }}]>" is Boolean -> toString() else -> error("unexpected parameter type ${this::class}") } diff --git a/settings.gradle b/settings.gradle index 5e9da894abf..aea202ba2eb 100644 --- a/settings.gradle +++ b/settings.gradle @@ -333,6 +333,7 @@ include ":compiler:test-infrastructure", ":compiler:tests-common-new" include ":idea:idea-frontend-fir:idea-fir-low-level-api" +include ":idea:idea-frontend-fir:idea-frontend-fir-generator" include ":idea:idea-fir-performance-tests" include ":plugins:parcelize:parcelize-compiler",