How can I apply the “move method” refactoring with IntelliJ IDEA?

前端 未结 5 755
感情败类
感情败类 2021-02-01 17:53

I want to be able to move an instance method from one class to another class (\"Move method\" from Fowler\'s \"Refactoring\") in IntelliJ IDEA. Unfortunately, when I try \"Move.

5条回答
  •  深忆病人
    2021-02-01 18:05

    The Move Method refactoring in IDEA only considers moving the method into classes related to it, i.e. used as its parameter or return value, or called from inside the method. Which is kinda logical: if the method has nothing concrete to do with the target class, why should it be there? OTOH I found this limiting in some cases where I still had a valid reason to move the method. So I had to do it by hand.

提交回复
热议问题