Simple Custom Refactoring in IntelliJ

前端 未结 1 1806
名媛妹妹
名媛妹妹 2021-02-13 00:50

This question is a follow-up for this.

Say I have some class Foo.

class Foo {
    protected String x = "x";

    public String getX() {
        r         


        
相关标签:
1条回答
  • 2021-02-13 01:31

    After adding the getFooX() method to Bar, I would use Edit > Find > Replace Structurally with the following expressions:

    Search template:

    $instance$.getFoo().getX()
    

    Replacement template:

    $instance$.getFooX()
    

    It does the job perfectly. Maybe you can add some constraints to $instance$ variable to narrow the search but that would only be useful if you had multiple classess with that method name.

    0 讨论(0)
提交回复
热议问题