[FIR] Extract FirPluginKey into :core:compiler.common and rename it to GeneratedDeclarationKey

This is needed to avoid dependency on :compiler:fir:fir2ir module in
  backend parts of compiler plugins. It will allow to publish those
  parts into jars for IDE, where they are needed for working of debugger
  and bytecode toolwindow
This commit is contained in:
Dmitriy Novozhilov
2022-06-01 18:02:26 +03:00
committed by teamcity
parent a84ece7233
commit 83d0a3e7a3
23 changed files with 92 additions and 75 deletions
@@ -5,6 +5,8 @@
package org.jetbrains.kotlin.ir.declarations
import org.jetbrains.kotlin.GeneratedDeclarationKey
interface IrDeclarationOrigin {
object DEFINED : IrDeclarationOriginImpl("DEFINED")
object FAKE_OVERRIDE : IrDeclarationOriginImpl("FAKE_OVERRIDE")
@@ -78,6 +80,22 @@ interface IrDeclarationOrigin {
object SHARED_VARIABLE_IN_EVALUATOR_FRAGMENT : IrDeclarationOriginImpl("SHARED_VARIABLE_IN_EVALUATOR_FRAGMENT", isSynthetic = true)
class GeneratedByPlugin(val pluginKey: GeneratedDeclarationKey) : IrDeclarationOrigin {
override fun toString(): String {
return "GENERATED[${pluginKey}]"
}
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (other !is GeneratedByPlugin) return false
return pluginKey == other.pluginKey
}
override fun hashCode(): Int {
return pluginKey.hashCode()
}
}
val isSynthetic: Boolean get() = false
}
@@ -771,7 +771,7 @@ class IrDeclarationDeserializer(
companion object {
private val allKnownDeclarationOrigins = IrDeclarationOrigin::class.nestedClasses.toList()
private val declarationOriginIndex =
allKnownDeclarationOrigins.map { it.objectInstance as IrDeclarationOriginImpl }.associateBy { it.name }
allKnownDeclarationOrigins.mapNotNull { it.objectInstance as? IrDeclarationOriginImpl }.associateBy { it.name }
}
private fun deserializeIrDeclarationOrigin(protoName: Int): IrDeclarationOriginImpl {
@@ -821,4 +821,4 @@ class IrDeclarationDeserializer(
else -> false
}
}
}
}