Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Convert Java File to Kotlin File work?

I'm exploring Kotlin through Kotlin for Android Developers. One of the first steps is to use Convert Java File to Kotlin File to see how the Java and Kotlin files compare.

I'm curious how this feature works.

Is the tool creating an abstract syntax tree from the Java input then transpiling to Kotlin? Or is doing something much simpler?

like image 567
Brad Avatar asked Jun 21 '16 11:06

Brad


1 Answers

The tool uses the IntelliJ IDEA PSI interface to parse and analyze the Java source code and then converts the resulting tree into Kotlin text. It's open-source just like everything else related to Kotlin; you can find the implementation here.

like image 111
yole Avatar answered Sep 19 '22 18:09

yole