I'm searching for a refactoring in Android Studio that I loved in the original Refactoring Browser in the Smalltalk world. I'm curious if I'm just holding the IDE wrong, or it's not possible.
Given the following statement:
MaterialTheme.typography.bodyMedium.copy(color = (backgroundColor.luminance() > 0.5).opt(Color._TextDark, Color.White))
I'd like to be able to select the
.copy(...)
half and "extract method" so I ended up with a new function:
fun TextStyle.coloredFor(backgroundColor:Color) = this.copy(color = (backgroundColor.luminance() > 0.5).opt(Color._TextDark, Color.White))
and the original rewritten as:
MaterialTheme.typography.bodyMedium.coloredFor(backgroundColor)
I have tried selecting different parts and tried different refactoring menu options, but none some to have the ability to infer the receiver as the target of the extracted behavior.