Hi, the IntelliJ button - convert to Kotlin works ...
# java-to-kotlin-refactoring
s
Hi, the IntelliJ button - convert to Kotlin works great, but leaves some things I'd love to automatize. Do You know a tool that uses AST, and can convert following code?
"Hello, %s".formatted(name)
->
"Hello, %s".format(name)
I'm not looking for regexs, I tried Kotlin complier API - with some chatgpt promps, but I keep having troubles converting even such simple code - I can parse it, find the relevent method, but not replace it 😕 Basically I'm looking for something like https://errorprone.info/docs/refaster - a tool that allows automated refactorings OR a piece of code where is the Kotlin compiler setup correctly 🙂 My trouble isn't just
formatted
- I have 500K LOC project, and I want to resolve all problems at once
✅ 1
j
Have you tried structural search and replace in intellij?
s
I'd like to use something that can be automated - I'm planning doing tens of such refactorings But I found solution today - https://github.com/pinterest/ktlint/tree/master - it uses PSI under the hood, but have interface that is easy to run ✅
n
There is also OpenRewrite, a general tool for batch automation of refactoring.
blob think smart 1