Kotlin-Java type conversion

Hi! Is there any instrument to get Kotlin types from Java PsiType? For example, I have java type:

java.util.Set<entitypack.Entity>

it kotlin it should be

kotlin.collections.Set<entitypack.Entity<*>>

How could I automatically get the second from the first?

0
4 comments

I found org.jetbrains.kotlin.j2k.TypeConverter, but it erases package name of the Entity class.

0

What exactly are you doing with org.jetbrains.kotlin.j2k.TypeConverter?

0

Hi!

val converter = Converter.create(ktClass, ConverterSettings.defaultSettings, IdeaJavaToKotlinServices, { true }, {})
val resultType = TypeConverter(converter).convertType(psiType)
resultType.canonicalCode()

ktClass is not a java psi element, but as I understand, it does not matter for TypeConverter.

0

Also, there is any analog of PsiSubstitutor for kotlin?

0

Please sign in to leave a comment.