Tracey Yoshima
02/07/2023, 11:49 PMimport java.util.Random
fun method(min: Int, max: Int) : Int {
return Random().nextInt((max - min) + 1)
}
The PSI for the nextInt function call is BINARY_EXPRESSION
=> on the Left-hand side: PARENTHESIZED
=> BINARY_EXPRESSION
.
Parenthesized expressions in source code may be unnecessarily wrapped at times, like (((max)) - ((min)))
. And I’d like to preserve the source code formatting, but the FIR removes the parentheses and only represents the function calls.dmitriy.novozhilov
02/08/2023, 10:06 AMTracey Yoshima
02/08/2023, 6:24 PM(((max)))
, excluding the parentheses does not cause any changes to the code, but something like (max - min) * 2
without the parens max - min * 2
would. So, I’ve handled the parenthesis surrounding binary expressions in code, but I was hoping for a means to use the existing FIR or PSI.
If a new version of Kotlin
or a Kotlin plugin is released that includes API changes, a declarative recipe
will enable users to adopt the new version quickly.