Anybody got a good way to convert an extension fun...
# intellij
s
Anybody got a good way to convert an extension function to a member function and automatically remove all the now-unused imports? I can’t see a dedicated refactoring for it. My current idea is to create the member function, have the extension function call through to it, and then use the “Inline” refactoring on the extension function. Not sure how clean the result will be, though.
Seems to have worked okay 🤞. I do find that a lot of my time in Kotlin is spent figuring out how to combine or otherwise cheat the refactorings to get the result I actually want 😄
(And the rest of the time is spent waiting for IntelliJ to finish “finding usages of component1” and wondering if it would have been quicker to just do it all by hand)
w
You can enable
fast component search
in when doing
find usages
btw, and it's much faster then. I'm not sure but maybe it would affect the refactorings as well?
And to your use case, to remove imports you may run
reformat code
on all the changed files from
commit
window maybe? (
cmd + 0
I think)
s
I’m not sure if auto-removing the imports that way will work, since they’re not just unused but actually unresolved. I’ll give it a try though. Thanks for the tip about fast component search, I’ll take a look!
e
our codebase has no star imports, so removing the imports is as simple as a grep/sed
👍 1
same 1