FIR IDE: implement generators for IDE diagnostics
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
+9
-12
@@ -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() {
|
||||
|
||||
+2
-1
@@ -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<KtDiagnostic> = diagnosticProvider.getDiagnosticsForElement(this)
|
||||
|
||||
fun KtFile.collectDiagnosticsForFile(): Collection<KtDiagnostic> = diagnosticProvider.collectDiagnosticsForFile(this)
|
||||
fun KtFile.collectDiagnosticsForFile(): Collection<KtDiagnosticWithPsi> = diagnosticProvider.collectDiagnosticsForFile(this)
|
||||
|
||||
fun KtSymbolWithKind.getContainingSymbol(): KtSymbolWithKind? = containingDeclarationProvider.getContainingDeclaration(this)
|
||||
|
||||
|
||||
+3
-3
@@ -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<KtDiagnostic>
|
||||
abstract fun collectDiagnosticsForFile(ktFile: KtFile): Collection<KtDiagnostic>
|
||||
abstract fun getDiagnosticsForElement(element: KtElement): Collection<KtDiagnosticWithPsi>
|
||||
abstract fun collectDiagnosticsForFile(ktFile: KtFile): Collection<KtDiagnosticWithPsi>
|
||||
}
|
||||
|
||||
+19
-11
@@ -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<TextRange>
|
||||
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<TextRange>
|
||||
val diagnosticClass: KClass<out KtDiagnosticWithPsi>
|
||||
}
|
||||
|
||||
data class KtSimpleDiagnostic(
|
||||
class KtSimpleDiagnostic(
|
||||
override val factoryName: String?,
|
||||
override val message: String,
|
||||
override val textRanges: Collection<TextRange>,
|
||||
) : KtDiagnostic
|
||||
override val defaultMessage: String,
|
||||
override val token: ValidityToken,
|
||||
) : KtDiagnostic
|
||||
|
||||
fun KtDiagnostic.getDefaultMessageWithFactoryName(): String =
|
||||
if (factoryName == null) defaultMessage
|
||||
else "[$factoryName] $defaultMessage"
|
||||
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -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<tasks.WriteCopyrightToFile> {
|
||||
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" {}
|
||||
}
|
||||
+22
@@ -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)
|
||||
}
|
||||
}
|
||||
+28
@@ -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<HLDiagnosticParameter>,
|
||||
)
|
||||
|
||||
data class HLDiagnosticList(val diagnostics: List<HLDiagnostic>)
|
||||
|
||||
data class HLDiagnosticParameter(
|
||||
val original: DiagnosticParameter,
|
||||
val name: String,
|
||||
val type: KType,
|
||||
val originalParameterName: String,
|
||||
val conversion: HLParameterConversion,
|
||||
val importsToAdd: List<String>
|
||||
)
|
||||
+161
@@ -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<KClass<*>, 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<*>
|
||||
}
|
||||
+68
@@ -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<String> 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<String> = 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)
|
||||
}
|
||||
+15
@@ -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)
|
||||
}
|
||||
+32
@@ -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<String>) {
|
||||
(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(">")
|
||||
}
|
||||
}
|
||||
+57
@@ -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<String> = 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<String>
|
||||
|
||||
protected abstract fun SmartPrinter.render(diagnosticList: HLDiagnosticList, packageName: String)
|
||||
|
||||
protected abstract val defaultImports: Collection<String>
|
||||
}
|
||||
+67
@@ -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<String> =
|
||||
diagnosticParameter.importsToAdd
|
||||
|
||||
override val defaultImports = listOf(
|
||||
"org.jetbrains.kotlin.fir.analysis.diagnostics.FirPsiDiagnostic",
|
||||
"org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors",
|
||||
)
|
||||
}
|
||||
+77
@@ -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<String> = 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",
|
||||
)
|
||||
}
|
||||
+62
@@ -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<String> = buildSet {
|
||||
diagnosticParameter.type.collectClassNamesTo(this)
|
||||
}
|
||||
|
||||
override val defaultImports = listOf(
|
||||
"org.jetbrains.kotlin.idea.frontend.api.diagnostics.KtDiagnosticWithPsi",
|
||||
)
|
||||
}
|
||||
+2
-1
@@ -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? =
|
||||
|
||||
+2
-2
@@ -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? =
|
||||
|
||||
+8
-8
@@ -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<KtDiagnostic> = withValidityAssertion {
|
||||
override fun getDiagnosticsForElement(element: KtElement): Collection<KtDiagnosticWithPsi> = withValidityAssertion {
|
||||
element.getDiagnostics(firResolveState).map { it.asKtDiagnostic() }
|
||||
}
|
||||
|
||||
override fun collectDiagnosticsForFile(ktFile: KtFile): Collection<KtDiagnostic> =
|
||||
override fun collectDiagnosticsForFile(ktFile: KtFile): Collection<KtDiagnosticWithPsi> =
|
||||
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)
|
||||
|
||||
+81
@@ -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<A : Any> : KtFirDiagnosticCreator {
|
||||
fun KtFirAnalysisSession.create(diagnostic: FirDiagnosticWithParameters1<*, A>): KtFirDiagnostic
|
||||
}
|
||||
|
||||
internal fun interface KtFirDiagnostic2Creator<A : Any, B : Any> : KtFirDiagnosticCreator {
|
||||
fun KtFirAnalysisSession.create(diagnostic: FirDiagnosticWithParameters2<*, A, B>): KtFirDiagnostic
|
||||
}
|
||||
|
||||
internal fun interface KtFirDiagnostic3Creator<A : Any, B : Any, C : Any> : KtFirDiagnosticCreator {
|
||||
fun KtFirAnalysisSession.create(diagnostic: FirDiagnosticWithParameters3<*, A, B, C>): KtFirDiagnostic
|
||||
}
|
||||
|
||||
internal class KtDiagnosticConverter(private val conversions: Map<AbstractFirDiagnosticFactory<*, *, *>, 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<Any>) {
|
||||
create(diagnostic as FirDiagnosticWithParameters1<FirSourceElement, Any>)
|
||||
}
|
||||
is KtFirDiagnostic2Creator<*, *> -> with(creator as KtFirDiagnostic2Creator<Any, Any>) {
|
||||
create(diagnostic as FirDiagnosticWithParameters2<FirSourceElement, Any, Any>)
|
||||
}
|
||||
is KtFirDiagnostic3Creator<*, *, *> -> with(creator as KtFirDiagnostic3Creator<Any, Any, Any>) {
|
||||
create(diagnostic as FirDiagnosticWithParameters3<FirSourceElement, Any, Any, Any>)
|
||||
}
|
||||
else -> error("Invalid KtFirDiagnosticCreator ${creator::class.simpleName}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class KtDiagnosticConverterBuilder private constructor() {
|
||||
private val conversions = mutableMapOf<AbstractFirDiagnosticFactory<*, *, *>, KtFirDiagnosticCreator>()
|
||||
|
||||
fun add(diagnostic: FirDiagnosticFactory0<*, *>, creator: KtFirDiagnostic0Creator) {
|
||||
conversions[diagnostic] = creator
|
||||
}
|
||||
|
||||
fun <A : Any> add(diagnostic: FirDiagnosticFactory1<*, *, A>, creator: KtFirDiagnostic1Creator<A>) {
|
||||
conversions[diagnostic] = creator
|
||||
}
|
||||
|
||||
fun <A : Any, B : Any> add(diagnostic: FirDiagnosticFactory2<*, *, A, B>, creator: KtFirDiagnostic2Creator<A, B>) {
|
||||
conversions[diagnostic] = creator
|
||||
}
|
||||
|
||||
fun <A : Any, B : Any, C : Any> add(diagnostic: FirDiagnosticFactory3<*, *, A, B, C>, creator: KtFirDiagnostic3Creator<A, B, C>) {
|
||||
conversions[diagnostic] = creator
|
||||
}
|
||||
|
||||
private fun build() = KtDiagnosticConverter(conversions)
|
||||
|
||||
companion object {
|
||||
inline fun buildConverter(init: KtDiagnosticConverterBuilder.() -> Unit) =
|
||||
KtDiagnosticConverterBuilder().apply(init).build()
|
||||
}
|
||||
}
|
||||
+38
@@ -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<FirDiagnostic<*>>
|
||||
return firDiagnosticRenderer.render(diagnostic)
|
||||
}
|
||||
|
||||
override val textRanges: Collection<TextRange>
|
||||
get() = firDiagnostic.textRanges
|
||||
|
||||
override val psi: PsiElement
|
||||
get() = firDiagnostic.psiElement
|
||||
}
|
||||
+983
@@ -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,
|
||||
)
|
||||
}
|
||||
}
|
||||
+745
@@ -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<KtSymbol>
|
||||
}
|
||||
|
||||
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<KtSymbol>
|
||||
}
|
||||
|
||||
abstract class AssignOperatorAmbiguity : KtFirDiagnostic() {
|
||||
override val diagnosticClass get() = AssignOperatorAmbiguity::class
|
||||
abstract val candidates: List<KtSymbol>
|
||||
}
|
||||
|
||||
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<KtSymbol>
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
+1267
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -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}")
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user