[FIR] Reformat FirElementSerializer
This commit is contained in:
committed by
Space Team
parent
fb43e53ca3
commit
d204d65174
+30
-27
@@ -188,7 +188,8 @@ class FirElementSerializer private constructor(
|
||||
}
|
||||
|
||||
fun FirClass.nestedClassifiers(): List<FirClassifierSymbol<*>> {
|
||||
val scope = defaultType().scope(session, scopeSession, FakeOverrideTypeCalculator.DoNothing, requiredPhase = null) ?: return emptyList()
|
||||
val scope =
|
||||
defaultType().scope(session, scopeSession, FakeOverrideTypeCalculator.DoNothing, requiredPhase = null) ?: return emptyList()
|
||||
return buildList {
|
||||
scope.getClassifierNames().mapNotNullTo(this) { scope.getSingleClassifier(it) }
|
||||
addAll(providedNestedClassifiers)
|
||||
@@ -636,36 +637,37 @@ class FirElementSerializer private constructor(
|
||||
return builder
|
||||
}
|
||||
|
||||
private fun typeParameterProto(typeParameter: FirTypeParameter): ProtoBuf.TypeParameter.Builder = whileAnalysing(session, typeParameter) {
|
||||
val builder = ProtoBuf.TypeParameter.newBuilder()
|
||||
private fun typeParameterProto(typeParameter: FirTypeParameter): ProtoBuf.TypeParameter.Builder =
|
||||
whileAnalysing(session, typeParameter) {
|
||||
val builder = ProtoBuf.TypeParameter.newBuilder()
|
||||
|
||||
builder.id = getTypeParameterId(typeParameter)
|
||||
builder.id = getTypeParameterId(typeParameter)
|
||||
|
||||
builder.name = getSimpleNameIndex(typeParameter.name)
|
||||
builder.name = getSimpleNameIndex(typeParameter.name)
|
||||
|
||||
if (typeParameter.isReified != builder.reified) {
|
||||
builder.reified = typeParameter.isReified
|
||||
}
|
||||
|
||||
val variance = ProtoEnumFlags.variance(typeParameter.variance)
|
||||
if (variance != builder.variance) {
|
||||
builder.variance = variance
|
||||
}
|
||||
extension.serializeTypeParameter(typeParameter, builder)
|
||||
|
||||
val upperBounds = typeParameter.bounds
|
||||
if (upperBounds.size == 1 && upperBounds.single() is FirImplicitNullableAnyTypeRef) return builder
|
||||
|
||||
for (upperBound in upperBounds) {
|
||||
if (useTypeTable()) {
|
||||
builder.addUpperBoundId(typeId(upperBound))
|
||||
} else {
|
||||
builder.addUpperBound(typeProto(upperBound))
|
||||
if (typeParameter.isReified != builder.reified) {
|
||||
builder.reified = typeParameter.isReified
|
||||
}
|
||||
}
|
||||
|
||||
return builder
|
||||
}
|
||||
val variance = ProtoEnumFlags.variance(typeParameter.variance)
|
||||
if (variance != builder.variance) {
|
||||
builder.variance = variance
|
||||
}
|
||||
extension.serializeTypeParameter(typeParameter, builder)
|
||||
|
||||
val upperBounds = typeParameter.bounds
|
||||
if (upperBounds.size == 1 && upperBounds.single() is FirImplicitNullableAnyTypeRef) return builder
|
||||
|
||||
for (upperBound in upperBounds) {
|
||||
if (useTypeTable()) {
|
||||
builder.addUpperBoundId(typeId(upperBound))
|
||||
} else {
|
||||
builder.addUpperBound(typeProto(upperBound))
|
||||
}
|
||||
}
|
||||
|
||||
return builder
|
||||
}
|
||||
|
||||
fun typeId(typeRef: FirTypeRef): Int {
|
||||
if (typeRef !is FirResolvedTypeRef) {
|
||||
@@ -978,7 +980,8 @@ class FirElementSerializer private constructor(
|
||||
private fun serializeVersionRequirementFromRequireKotlin(annotation: FirAnnotation): ProtoBuf.VersionRequirement.Builder? {
|
||||
val argumentMapping = annotation.argumentMapping.mapping
|
||||
|
||||
val versionString = (argumentMapping[RequireKotlinConstants.VERSION]?.toConstantValue(session) as? StringValue)?.value ?: return null
|
||||
val versionString =
|
||||
(argumentMapping[RequireKotlinConstants.VERSION]?.toConstantValue(session) as? StringValue)?.value ?: return null
|
||||
val matchResult = RequireKotlinConstants.VERSION_REGEX.matchEntire(versionString) ?: return null
|
||||
|
||||
val major = matchResult.groupValues.getOrNull(1)?.toIntOrNull() ?: return null
|
||||
|
||||
Reference in New Issue
Block a user