openrewrite / rewrite-kotlin

Work-in-progress implementation of Kotlin language support for OpenRewrite.
Apache License 2.0
38 stars 11 forks source link

Fix Semi-colon on inline methods after property declaration disappears #585

Closed kunli2 closed 5 months ago

kunli2 commented 5 months ago

fixes https://github.com/openrewrite/rewrite-kotlin/issues/560

An code example:

class Test {
    var n: Int = 0 /*C1*/ ;   protected set
}
  1. var n: Int = 0 /*C1*/ ; protected set is a K.Property.

  2. protected set is a setter accessor in the K.Property, it can be in a new line and then no semi-colon is required, but it can be in the same line and then a semi-colon is required as a delimiter. For the latter case with a semi-colon inside a K.Property, However, there is not a space room for /*C1*/ in K.Property.

This PR proposed to change variable declarations in K.Property from type J.VariableDeclarations to JRightPadded<J.VariableDeclarations>, plus SemiColon marker, then this case can be handled.