Allow generating Kotlin code instead of Java
With Kotlin becoming a major language with the JetBrains platform, it would only make sense if language plugins would be entirely in Kotlin as well.
As a first step, it should be possible to (optionally) use the Kotlins J2K to convert the generated Java code to Kotlin. Converting the code to Kotlin will directly help with certain issues in the Kotlin compiler when it comes to Kotlin/Java compatibility, allowing for more developers to use Kotlin for language plugins.
At some point one would probably prefer to directly generate Kotlin code, so it becomes easy to make use of Kotlins language features...
One big advantage would be using sealed classes/interfaces in an or rule: foo ::= bar | baz | a
At the moment, you have to use this:
if (foo.bar != null) {
foo.bar!!
} else if (foo.baz != null) {
foo.baz!!
} else {
foo.a!!
}
This would be nice:
when (foo) {
is Foo.Bar -> foo.bar
is Foo.Baz -> foo.baz
is Foo.A -> foo.a
}
@hfhbd That would be great indeed, luckily this isn't unique to Kotlin. I'd love your input on my proposal to add this to Java, so it can be utilized in all JVM languages. https://github.com/JetBrains/Grammar-Kit/issues/305