New J2K: Add collection classes mapping to TypeMappingConversion

This commit is contained in:
Ilya Kirillov
2018-12-05 17:06:07 +03:00
committed by Ilya Kirillov
parent df5c2f90c1
commit d47543820a
@@ -70,7 +70,10 @@ class TypeMappingConversion(val context: ConversionContext) : RecursiveApplicabl
}
private fun mapClassType(type: JKClassType, element: JKTreeElement): JKClassType {
val newFqName = JavaToKotlinClassMap.mapJavaToKotlin(FqName(type.classReference.fqName ?: return type)) ?: return type
val fqName = type.classReference.fqName ?: return type
val newFqName = JavaToKotlinClassMap.mapJavaToKotlin(FqName(fqName))
?: mapCollectionClass(fqName)?.let { ClassId.fromString(it) }
?: return type
return JKClassTypeImpl(
context.symbolProvider.provideByFqName(newFqName),
type.parameters.map { mapType(it, element) },
@@ -78,6 +81,9 @@ class TypeMappingConversion(val context: ConversionContext) : RecursiveApplicabl
)
}
private fun mapCollectionClass(fqName: String): String? =
mapOf("java.util.Collection" to "kotlin.collections.Collection")[fqName]
private fun mapPrimitiveType(type: JKJavaPrimitiveType): JKClassType {
val fqName = type.jvmPrimitiveType.primitiveType.typeFqName
return JKClassTypeImpl(context.symbolProvider.provideByFqName(ClassId.topLevel(fqName)), nullability = Nullability.NotNull)