https://kotlinlang.org logo
Title
h

hdarritchon

03/22/2019, 3:45 PM
And do you know if it will be available one day or it’s a limitation of Kotlin ?
s

streetsofboston

03/22/2019, 3:53 PM
I don’t know how any tool can safely refactor moving a method from one class to another class (or to a top-level function). The code that calls this function would not know how to resolve this refactor.
E.g. the calling code has an instance of EditoOffersService and calls getCataglogEditoOffers on it. If you move getCataglogEditoOffers to the top or to another class, what should the calling code do, how should the calling code be refactored?
h

hdarritchon

03/22/2019, 3:59 PM
For myself, nothing change for the calling code. It’s only a way to simplify a copy/paste in fact to a new file/class (that could be created). And you have to fix your code following this refacto.
s

streetsofboston

03/22/2019, 4:05 PM
Ah… then, yes, you’d need to cut/paste it yourself. Refactoring is more involved and refactoring must be done safely, ie the functionality of your app shouldn’t change and the IDE must be able to change both ends of the code (declaration/implementation on one side, the calling code on the other side) if necessary.
a

Alexey Belkov [JB]

03/25/2019, 8:04 AM
If Move refactoring works for instance methods in the Java plugin, it can probably work for Kotlin too. Please submit a feature request at http://kotl.in/issue with sample code. Thanks.
Actually these issues are probably what you are asking for, feel free to vote: https://youtrack.jetbrains.com/issue/KT-14272 https://youtrack.jetbrains.com/issue/KT-23708
h

hdarritchon

03/25/2019, 8:41 AM
@Alexey Belkov [JB] Hi Alexey, yes, it is exactly that ! I will add some code example both in Java and Kotlin to describe what I’d like to have 😉
:tnx: 1
@Alexey Belkov [JB] I have added a comment to the issue https://youtrack.jetbrains.com/issue/KT-23708 with link to my github repo with a sample of code and an animated gif of my IDE to show how it works currently.