FIR: Rename FirSourceElement::withKind to fakeElement
And reinforce its contract
This commit is contained in:
+3
-4
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.builder.*
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||
import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl
|
||||
import org.jetbrains.kotlin.lexer.KtTokens.CLOSING_QUOTE
|
||||
import org.jetbrains.kotlin.lexer.KtTokens.OPEN_QUOTE
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -341,7 +340,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
SHORT_STRING_TEMPLATE_ENTRY, LONG_STRING_TEMPLATE_ENTRY -> {
|
||||
hasExpressions = true
|
||||
val firExpression = entry.convertTemplateEntry("Incorrect template argument")
|
||||
val source = firExpression.source?.withKind(FirFakeSourceElementKind.GeneratedToStringCallOnTemplateEntry)
|
||||
val source = firExpression.source?.fakeElement(FirFakeSourceElementKind.GeneratedToStringCallOnTemplateEntry)
|
||||
buildFunctionCall {
|
||||
this.source = source
|
||||
explicitReceiver = firExpression
|
||||
@@ -408,7 +407,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
}
|
||||
return buildBlock {
|
||||
val baseSource = baseExpression?.toFirSourceElement()
|
||||
val desugaredSource = baseSource?.withKind(FirFakeSourceElementKind.DesugaredIncrementOrDecrement)
|
||||
val desugaredSource = baseSource?.fakeElement(FirFakeSourceElementKind.DesugaredIncrementOrDecrement)
|
||||
source = desugaredSource
|
||||
val tempName = Name.special("<unary>")
|
||||
val temporaryVariable = generateTemporaryVariable(
|
||||
@@ -744,7 +743,7 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
componentIndex++
|
||||
val parameterSource = sourceNode?.toFirSourceElement()
|
||||
val componentFunction = buildSimpleFunction {
|
||||
source = parameterSource?.withKind(FirFakeSourceElementKind.DataClassGeneratedMembers)
|
||||
source = parameterSource?.fakeElement(FirFakeSourceElementKind.DataClassGeneratedMembers)
|
||||
session = this@DataClassMembersGenerator.session
|
||||
origin = FirDeclarationOrigin.Source
|
||||
returnTypeRef = firProperty.returnTypeRef
|
||||
|
||||
+5
-5
@@ -170,9 +170,9 @@ fun FirExpression.generateContainsOperation(
|
||||
if (!inverted) return containsCall
|
||||
|
||||
return buildFunctionCall {
|
||||
source = baseSource?.withKind(FirFakeSourceElementKind.DesugaredInvertedContains)
|
||||
source = baseSource?.fakeElement(FirFakeSourceElementKind.DesugaredInvertedContains)
|
||||
calleeReference = buildSimpleNamedReference {
|
||||
source = operationReferenceSource?.withKind(FirFakeSourceElementKind.DesugaredInvertedContains)
|
||||
source = operationReferenceSource?.fakeElement(FirFakeSourceElementKind.DesugaredInvertedContains)
|
||||
name = OperatorNameConventions.NOT
|
||||
}
|
||||
explicitReceiver = containsCall
|
||||
@@ -191,7 +191,7 @@ fun FirExpression.generateComparisonExpression(
|
||||
|
||||
val compareToCall = createConventionCall(
|
||||
operationReferenceSource,
|
||||
baseSource?.withKind(FirFakeSourceElementKind.GeneratedCompararisonExpression),
|
||||
baseSource?.fakeElement(FirFakeSourceElementKind.GeneratedCompararisonExpression),
|
||||
argument,
|
||||
OperatorNameConventions.COMPARE_TO
|
||||
)
|
||||
@@ -483,6 +483,6 @@ fun FirModifiableQualifiedAccess.wrapWithSafeCall(receiver: FirExpression): FirS
|
||||
bind(checkedSafeCallSubject)
|
||||
}
|
||||
this.regularQualifiedAccess = this@wrapWithSafeCall
|
||||
this.source = this@wrapWithSafeCall.source?.withKind(FirFakeSourceElementKind.DesugaredSafeCallExpression)
|
||||
this.source = this@wrapWithSafeCall.source?.fakeElement(FirFakeSourceElementKind.DesugaredSafeCallExpression)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ internal fun generateDestructuringBlock(
|
||||
returnTypeRef = entry.typeReference.toFirOrImplicitTypeRef()
|
||||
this.name = name
|
||||
initializer = buildComponentCall {
|
||||
val componentCallSource = entrySource.withKind(FirFakeSourceElementKind.DesugaredComponentFunctionCall)
|
||||
val componentCallSource = entrySource.fakeElement(FirFakeSourceElementKind.DesugaredComponentFunctionCall)
|
||||
source = componentCallSource
|
||||
explicitReceiver = generateResolvedAccessExpression(componentCallSource, container)
|
||||
componentIndex = index + 1
|
||||
|
||||
@@ -311,7 +311,7 @@ class RawFirBuilder(
|
||||
extractValueParametersTo(this, propertyTypeRef)
|
||||
if (!isGetter && valueParameters.isEmpty()) {
|
||||
valueParameters += buildDefaultSetterValueParameter {
|
||||
this.source = source.withKind(FirFakeSourceElementKind.DefaultAccessor)
|
||||
this.source = source.fakeElement(FirFakeSourceElementKind.DefaultAccessor)
|
||||
session = baseSession
|
||||
origin = FirDeclarationOrigin.Source
|
||||
returnTypeRef = propertyTypeRef
|
||||
@@ -384,7 +384,7 @@ class RawFirBuilder(
|
||||
symbol = FirPropertySymbol(callableIdForName(propertyName))
|
||||
isLocal = false
|
||||
this.status = status
|
||||
val defaultAccessorSource = propertySource.withKind(FirFakeSourceElementKind.DefaultAccessor)
|
||||
val defaultAccessorSource = propertySource.fakeElement(FirFakeSourceElementKind.DefaultAccessor)
|
||||
getter = FirDefaultPropertyGetter(defaultAccessorSource, baseSession, FirDeclarationOrigin.Source, type, visibility)
|
||||
setter = if (isMutable) FirDefaultPropertySetter(
|
||||
defaultAccessorSource,
|
||||
@@ -574,7 +574,7 @@ class RawFirBuilder(
|
||||
val constructorSource = this?.toFirSourceElement()
|
||||
?: owner.toFirPsiSourceElement(FirFakeSourceElementKind.ImplicitConstructor)
|
||||
val firDelegatedCall = buildDelegatedConstructorCall {
|
||||
source = constructorCallee ?: constructorSource.withKind(FirFakeSourceElementKind.DelegatingConstructorCall)
|
||||
source = constructorCallee ?: constructorSource.fakeElement(FirFakeSourceElementKind.DelegatingConstructorCall)
|
||||
constructedTypeRef = delegatedSuperTypeRef
|
||||
isThis = false
|
||||
if (!stubMode) {
|
||||
@@ -995,7 +995,7 @@ class RawFirBuilder(
|
||||
val expressionSource = expression.toFirSourceElement()
|
||||
label = context.firLabels.pop() ?: context.calleeNamesForLambda.lastOrNull()?.let {
|
||||
buildLabel {
|
||||
source = expressionSource.withKind(FirFakeSourceElementKind.GeneratedLambdaLabel)
|
||||
source = expressionSource.fakeElement(FirFakeSourceElementKind.GeneratedLambdaLabel)
|
||||
name = it.asString()
|
||||
}
|
||||
}
|
||||
@@ -1011,10 +1011,10 @@ class RawFirBuilder(
|
||||
if (statements.isEmpty()) {
|
||||
statements.add(
|
||||
buildReturnExpression {
|
||||
source = expressionSource.withKind(FirFakeSourceElementKind.ImplicitReturn)
|
||||
source = expressionSource.fakeElement(FirFakeSourceElementKind.ImplicitReturn)
|
||||
this.target = target
|
||||
result = buildUnitExpression {
|
||||
source = expressionSource.withKind(FirFakeSourceElementKind.ImplicitUnit)
|
||||
source = expressionSource.fakeElement(FirFakeSourceElementKind.ImplicitUnit)
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -1706,7 +1706,7 @@ class RawFirBuilder(
|
||||
|
||||
else -> {
|
||||
buildSimpleNamedReference {
|
||||
source = defaultSource.withKind(FirFakeSourceElementKind.ImplicitInvokeCall)
|
||||
source = defaultSource.fakeElement(FirFakeSourceElementKind.ImplicitInvokeCall)
|
||||
name = OperatorNameConventions.INVOKE
|
||||
} to calleeExpression.toFirExpression("Incorrect invoke receiver")
|
||||
}
|
||||
@@ -1793,7 +1793,7 @@ class RawFirBuilder(
|
||||
val sourceElement = expression.toFirSourceElement()
|
||||
source = sourceElement
|
||||
calleeReference = buildExplicitThisReference {
|
||||
source = sourceElement.withKind(FirFakeSourceElementKind.ExplicitThisOrSuperReference)
|
||||
source = sourceElement.fakeElement(FirFakeSourceElementKind.ExplicitThisOrSuperReference)
|
||||
labelName = expression.getLabelName()
|
||||
}
|
||||
}
|
||||
@@ -1805,7 +1805,7 @@ class RawFirBuilder(
|
||||
return buildQualifiedAccessExpression {
|
||||
this.source = source
|
||||
calleeReference = buildExplicitSuperReference {
|
||||
source.withKind(FirFakeSourceElementKind.ExplicitThisOrSuperReference)
|
||||
source.fakeElement(FirFakeSourceElementKind.ExplicitThisOrSuperReference)
|
||||
labelName = expression.getLabelName()
|
||||
superTypeRef = superType.toFirOrImplicitType()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user