Java source refactoring of 7000 references

前端 未结 12 1130
醉梦人生
醉梦人生 2020-12-25 13:05

I need to change the signature of a method used all over the codebase.

Specifically, the method void log(String) will take two additional arguments (

12条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-25 13:26

    IntelliJ IDEA shouldn't have any trouble with this.

    I'm not a Java expert, but something like this could work. It's not a perfect solution (it may even be a very bad solution), but it could get you started:

    Change the method signature with IntelliJ's refactoring tools, and specify default values for the 2 new parameters:

    c: self.getClass()
    methodName: Thread.currentThread().getStackTrace()[1].getMethodName()
    

    or better yet, simply specify null as the default values.

提交回复
热议问题