https://kotlinlang.org logo
f

Federico Tomassetti

06/14/2023, 8:58 AM
I am trying to parse Kotlin code using the kotlin-compiler-embeddable. I tried following the advice presented in this article https://jitinsharma.com/posts/parsing-kotlin-using-code-kotlin/ but it seems outdated
I can parse code and I can get KtClass, but then when I try to resolve types I get an exception about the KotlinCacheService not being available
KotlinCoreEnvironment seems to be deprecated, so maybe this is the issue. I was wondering if you have any suggestions on how to use the Kotlin compiler with version 1.8.20
d

Didier Villevalois

06/19/2023, 4:20 PM
Hi @Federico Tomassetti! I did not try to run it yet but maybe this code from OpenRewrite can help you: https://github.com/openrewrite/rewrite-kotlin/blob/main/src/main/java/org/openrewrite/kotlin/KotlinParser.java
f

Federico Tomassetti

06/20/2023, 6:02 AM
Thank you Didier, I will look into it
4 Views