[FIR] Introduce FirSourceElement instead of FirElement as source in fir nodes
This commit is contained in:
+18
-19
@@ -102,7 +102,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
impl(resolvedImport) {
|
||||
delegateFields(listOf("aliasName", "importedFqName", "isAllUnder"), "delegate")
|
||||
|
||||
default("psi") {
|
||||
default("source") {
|
||||
delegate = "delegate"
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
withGetter = true
|
||||
}
|
||||
}
|
||||
default("calleeReference", "FirSimpleNamedReference(psi, Name.identifier(\"component\$componentIndex\"), null)")
|
||||
default("calleeReference", "FirSimpleNamedReference(source, Name.identifier(\"component\$componentIndex\"), null)")
|
||||
useTypes(simpleNamedReferenceType, nameType, noReceiverExpressionType)
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
parents += callWithArgumentList
|
||||
default(
|
||||
"calleeReference",
|
||||
"if (isThis) FirExplicitThisReference(psi, null) else FirExplicitSuperReference(psi, constructedTypeRef)"
|
||||
"if (isThis) FirExplicitThisReference(source, null) else FirExplicitSuperReference(source, constructedTypeRef)"
|
||||
)
|
||||
default("isSuper") {
|
||||
value = "!isThis"
|
||||
@@ -214,22 +214,21 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
}
|
||||
|
||||
impl(expression, "FirElseIfTrueCondition") {
|
||||
default("typeRef", "FirImplicitBooleanTypeRef(psi)")
|
||||
default("typeRef", "FirImplicitBooleanTypeRef(source)")
|
||||
useTypes(implicitBooleanTypeRefType)
|
||||
}
|
||||
|
||||
impl(block)
|
||||
|
||||
val emptyExpressionBlock = impl(block, "FirEmptyExpressionBlock") {
|
||||
// TODO: make statements immutable
|
||||
defaultNull("psi")
|
||||
noSource()
|
||||
}
|
||||
|
||||
impl(errorExpression)
|
||||
|
||||
impl(loop, "FirErrorLoop") {
|
||||
default("block", "FirEmptyExpressionBlock()")
|
||||
default("condition", "FirErrorExpressionImpl(psi, \"error loop\")")
|
||||
default("condition", "FirErrorExpressionImpl(source, \"error loop\")")
|
||||
defaultNull("label")
|
||||
useTypes(emptyExpressionBlock)
|
||||
}
|
||||
@@ -337,18 +336,18 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
|
||||
impl(returnExpression) {
|
||||
lateinit("target")
|
||||
default("typeRef", "FirImplicitNothingTypeRef(psi)")
|
||||
default("typeRef", "FirImplicitNothingTypeRef(source)")
|
||||
useTypes(implicitNothingTypeRefType)
|
||||
}
|
||||
|
||||
impl(stringConcatenationCall) {
|
||||
parents += callWithArgumentList
|
||||
default("typeRef", "FirImplicitStringTypeRef(psi)")
|
||||
default("typeRef", "FirImplicitStringTypeRef(source)")
|
||||
useTypes(implicitStringTypeRefType)
|
||||
}
|
||||
|
||||
impl(throwExpression) {
|
||||
default("typeRef", "FirImplicitNothingTypeRef(psi)")
|
||||
default("typeRef", "FirImplicitNothingTypeRef(source)")
|
||||
useTypes(implicitNothingTypeRefType)
|
||||
}
|
||||
|
||||
@@ -367,7 +366,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
}
|
||||
|
||||
impl(expression, "FirUnitExpression") {
|
||||
default("typeRef", "FirImplicitUnitTypeRef(psi)")
|
||||
default("typeRef", "FirImplicitUnitTypeRef(source)")
|
||||
useTypes(implicitUnitTypeRefType)
|
||||
}
|
||||
|
||||
@@ -465,7 +464,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
}
|
||||
|
||||
impl(thisReference, "FirImplicitThisReference") {
|
||||
defaultNull("psi")
|
||||
noSource()
|
||||
default("labelName") {
|
||||
value = "null"
|
||||
withGetter = true
|
||||
@@ -478,7 +477,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
impl(superReference, "FirExplicitSuperReference")
|
||||
|
||||
impl(controlFlowGraphReference, "FirEmptyControlFlowGraphReference") {
|
||||
noPsi()
|
||||
noSource()
|
||||
}
|
||||
|
||||
impl(resolvedTypeRef)
|
||||
@@ -501,11 +500,11 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
|
||||
impl(implicitTypeRef, "FirComputingImplicitTypeRef") {
|
||||
kind = Object
|
||||
defaultNull("psi", withGetter = true)
|
||||
defaultNull("source", withGetter = true)
|
||||
}
|
||||
|
||||
impl(reference, "FirStubReference") {
|
||||
default("psi") {
|
||||
default("source") {
|
||||
value = "null"
|
||||
withGetter = true
|
||||
}
|
||||
@@ -518,7 +517,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
|
||||
impl(typeProjection, "FirTypePlaceholderProjection") {
|
||||
kind = Object
|
||||
defaultNull("psi")
|
||||
noSource()
|
||||
}
|
||||
|
||||
val abstractLoopJump = impl(loopJump, "FirAbstractLoopJump") {
|
||||
@@ -527,13 +526,13 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
|
||||
impl(breakExpression) {
|
||||
parents += abstractLoopJump
|
||||
default("typeRef", "FirImplicitNothingTypeRef(psi)")
|
||||
default("typeRef", "FirImplicitNothingTypeRef(source)")
|
||||
useTypes(implicitNothingTypeRefType)
|
||||
}
|
||||
|
||||
impl(continueExpression) {
|
||||
parents += abstractLoopJump
|
||||
default("typeRef", "FirImplicitNothingTypeRef(psi)")
|
||||
default("typeRef", "FirImplicitNothingTypeRef(source)")
|
||||
useTypes(implicitNothingTypeRefType)
|
||||
}
|
||||
|
||||
@@ -562,7 +561,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
}
|
||||
|
||||
impl(delegatedTypeRef) {
|
||||
listOf("psi", "annotations").forEach {
|
||||
listOf("source", "annotations").forEach {
|
||||
default(it) {
|
||||
delegate = "typeRef"
|
||||
}
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ import org.jetbrains.kotlin.serialization.deserialization.descriptors.Deserializ
|
||||
object NodeConfigurator : AbstractFieldConfigurator() {
|
||||
fun configureFields() = with(FirTreeBuilder) {
|
||||
AbstractFirTreeBuilder.baseFirElement.configure {
|
||||
+field("psi", psiElementType, nullable = true)
|
||||
+field("source", sourceElementType, nullable = true)
|
||||
}
|
||||
|
||||
annotationContainer.configure {
|
||||
|
||||
+3
-4
@@ -5,24 +5,23 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.tree.generator
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.contracts.description.InvocationKind
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.tree.generator.context.generatedType
|
||||
import org.jetbrains.kotlin.fir.tree.generator.context.type
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstKind
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
|
||||
val psiElementType = type(PsiElement::class)
|
||||
val sourceElementType = type("fir", "FirSourceElement")
|
||||
val jumpTargetType = type("fir", "FirTarget")
|
||||
val constKindType = type(IrConstKind::class)
|
||||
val operationType = type("fir.expressions", "FirOperation")
|
||||
|
||||
+2
-2
@@ -150,8 +150,8 @@ abstract class AbstractFirTreeImplementationConfigurator {
|
||||
}
|
||||
}
|
||||
|
||||
fun noPsi() {
|
||||
defaultNull("psi")
|
||||
fun noSource() {
|
||||
defaultNull("source")
|
||||
}
|
||||
|
||||
fun defaultEmptyList(field: String) {
|
||||
|
||||
Reference in New Issue
Block a user