Hi everyone! I’m new to the Kotlin slack and would...
# getting-started
t
Hi everyone! I’m new to the Kotlin slack and would like to create an OpenRewrite AST for Kotlin. I want to use the Kotlin compiler to collect the type attribution of Kotlin and Java sources. The goal is primarily to have a Kotlin AST that will allow us to migrate APIs. I’m having trouble creating a
FirSessionFactory.INSTANCE
using
createLibrarySession
and am getting an error (will be linked in thread). Could someone point me to an example of how to instantiate the Kotlin compiler?
♥️ 2
I’m not sure what I’m doing wrong. Error:
Copy code
java.lang.IllegalStateException: Module data is not registered in Libraries session
	at org.jetbrains.kotlin.fir.FirModuleDataKt.getModuleData(FirModuleData.kt)
	at org.jetbrains.kotlin.fir.builder.BaseFirBuilder.<init>(BaseFirBuilder.kt:50)
	at org.jetbrains.kotlin.fir.builder.BaseFirBuilder.<init>(BaseFirBuilder.kt:49)
	at org.jetbrains.kotlin.fir.builder.RawFirBuilder.<init>(RawFirBuilder.kt:55)
...
Code snippet.java
Thanks in advance!
d
You can check how FIR compiler is set up in tests, for example (just creating of empty library session is not enough)
Also it's better to ask questions about compiler internals in #compiler channel
t
Thank you @dmitriy.novozhilov!
👌 1