openrewrite / rewrite-kotlin

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

Deprecate the `prefix` field of `IsNullSafe` marker since it's uncessery #491

Closed kunli2 closed 11 months ago

kunli2 commented 11 months ago

There are total 3 usage scenarios of IsNullSafe marker.

  1. J.FieldAccess, example: test ?. property, the space before ?. is handled by leftPadded

  2. J.MethodInvocation, example:

              val filter = null   ?. let { _ ->
                  { false
                  }
              }

    the space before ?. is handled by suffix of the select (RightPadded)

  3. J.TypeCast, example val map = mapOf(Pair("one", 1)) as? Map<*, *>, the space before ?. is handled by the prefix of J.TypeCast.clazz

so the prefix in this marker is not necessary, we can just deprecate the prefix field and keep the marker there.

this PR is related to https://github.com/openrewrite/rewrite-kotlin/issues/477