[FIR IDE] Extract implicit set parameter name to reuse it in Analysis API

This commit is contained in:
Yan Zhulanow
2021-10-05 19:03:43 +09:00
committed by teamcityserver
parent 2b8963455f
commit 44a1fe668e
3 changed files with 8 additions and 5 deletions
@@ -39,6 +39,7 @@ import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
import org.jetbrains.kotlin.fir.types.impl.* import org.jetbrains.kotlin.fir.types.impl.*
import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.SpecialNames
import org.jetbrains.kotlin.psi.KtAnnotated import org.jetbrains.kotlin.psi.KtAnnotated
import org.jetbrains.kotlin.types.ConstantValueKind import org.jetbrains.kotlin.types.ConstantValueKind
import org.jetbrains.kotlin.types.expressions.OperatorConventions import org.jetbrains.kotlin.types.expressions.OperatorConventions
@@ -490,7 +491,7 @@ fun <T> FirPropertyBuilder.generateAccessorsByDelegate(
this.moduleData = moduleData this.moduleData = moduleData
origin = FirDeclarationOrigin.Source origin = FirDeclarationOrigin.Source
returnTypeRef = buildImplicitTypeRef() returnTypeRef = buildImplicitTypeRef()
name = DELEGATED_SETTER_PARAM name = SpecialNames.IMPLICIT_SET_PARAMETER
symbol = FirValueParameterSymbol(this@generateAccessorsByDelegate.name) symbol = FirValueParameterSymbol(this@generateAccessorsByDelegate.name)
isCrossinline = false isCrossinline = false
isNoinline = false isNoinline = false
@@ -515,7 +516,7 @@ fun <T> FirPropertyBuilder.generateAccessorsByDelegate(
arguments += buildPropertyAccessExpression { arguments += buildPropertyAccessExpression {
calleeReference = buildResolvedNamedReference { calleeReference = buildResolvedNamedReference {
source = fakeSource source = fakeSource
name = DELEGATED_SETTER_PARAM name = SpecialNames.IMPLICIT_SET_PARAMETER
resolvedSymbol = parameter.symbol resolvedSymbol = parameter.symbol
} }
} }
@@ -533,8 +534,6 @@ fun <T> FirPropertyBuilder.generateAccessorsByDelegate(
} }
} }
private val DELEGATED_SETTER_PARAM = Name.special("<set-?>")
fun FirBlock?.extractContractDescriptionIfPossible(): Pair<FirBlock?, FirContractDescription?> { fun FirBlock?.extractContractDescriptionIfPossible(): Pair<FirBlock?, FirContractDescription?> {
if (this == null) return null to null if (this == null) return null to null
if (!isContractPresentFirCheck()) return this to null if (!isContractPresentFirCheck()) return this to null
@@ -58,6 +58,9 @@ object SpecialNames {
@JvmField @JvmField
val UNDERSCORE_FOR_UNUSED_VAR = Name.special("<unused var>") val UNDERSCORE_FOR_UNUSED_VAR = Name.special("<unused var>")
@JvmField
val IMPLICIT_SET_PARAMETER = Name.special("<set-?>")
@JvmStatic @JvmStatic
fun safeIdentifier(name: Name?): Name { fun safeIdentifier(name: Name?): Name {
return if (name != null && !name.isSpecial) name else SAFE_IDENTIFIER_FOR_NO_NAME return if (name != null && !name.isSpecial) name else SAFE_IDENTIFIER_FOR_NO_NAME
@@ -21,6 +21,7 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.descriptors.*; import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.Annotations; import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.name.Name; import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.name.SpecialNames;
import org.jetbrains.kotlin.types.KotlinType; import org.jetbrains.kotlin.types.KotlinType;
import java.util.Collection; import java.util.Collection;
@@ -67,7 +68,7 @@ public class PropertySetterDescriptorImpl extends PropertyAccessorDescriptorImpl
@NotNull Annotations annotations @NotNull Annotations annotations
) { ) {
return new ValueParameterDescriptorImpl( return new ValueParameterDescriptorImpl(
setterDescriptor, null, 0, annotations, Name.special("<set-?>"), type, setterDescriptor, null, 0, annotations, SpecialNames.IMPLICIT_SET_PARAMETER, type,
/* declaresDefaultValue = */ false, /* declaresDefaultValue = */ false,
/* isCrossinline = */ false, /* isCrossinline = */ false,
/* isNoinline = */ false, /* isNoinline = */ false,