Is there any way to automatically rename accessor/mutator when a variable they get/set gets refactored -> renamed (Eclipse 3.4)?
当它们获取/设置的变量被重构 - >重命名(Eclipse 3.4)时,有没有办法自动重命名accessor / mutator?
2 个解决方案
#1
19
1 - When you select Refactor->Rename on a variable, Eclipse prompts you to enter the new name in an "in-line" box. Directly below it, there is a help message and next to it a small icon (an arrow going down).Click on that arrow and then select "Open Rename Dialog". A new pop-up appears with the checkboxes you need.
1 - 当您在变量上选择Refactor-> Rename时,Eclipse会提示您在“内联”框中输入新名称。在它的正下方,有一条帮助信息,旁边有一个小图标(向下箭头)。单击该箭头,然后选择“打开重命名对话框”。将出现一个新弹出窗口,其中包含您需要的复选框。
2 - Alternatively, select the variable you want to change and press twice Alt+Shift+R. Again check the getter/setter checkboxes.
2 - 或者,选择要更改的变量,然后按两次Alt + Shift + R.再次检查getter / setter复选框。
#2
0
By default eclipse will not rename getters and setters when using 'inline' renaming of a variable. However you can change this behaviour by using the 'Rename Field' dialog for a rename once, and selecting 'Rename getter' and 'Rename setter'. (see the answer by idrosid for details only how to open this window).
默认情况下,当使用“内联”重命名变量时,eclipse不会重命名getter和setter。但是,您可以通过使用“重命名字段”对话框重命名一次,然后选择“重命名getter”和“Rename setter”来更改此行为。 (有关如何打开此窗口的详细信息,请参阅idrosid的答案)。
After this the 'inline' renames will also update the getter and setter for that field (but not the parameter in the setter).
在此之后,“内联”重命名还将更新该字段的getter和setter(但不更新setter中的参数)。
Note, I have tested this with Eclipse 4.5
注意,我已经使用Eclipse 4.5进行了测试
#1
19
1 - When you select Refactor->Rename on a variable, Eclipse prompts you to enter the new name in an "in-line" box. Directly below it, there is a help message and next to it a small icon (an arrow going down).Click on that arrow and then select "Open Rename Dialog". A new pop-up appears with the checkboxes you need.
1 - 当您在变量上选择Refactor-> Rename时,Eclipse会提示您在“内联”框中输入新名称。在它的正下方,有一条帮助信息,旁边有一个小图标(向下箭头)。单击该箭头,然后选择“打开重命名对话框”。将出现一个新弹出窗口,其中包含您需要的复选框。
2 - Alternatively, select the variable you want to change and press twice Alt+Shift+R. Again check the getter/setter checkboxes.
2 - 或者,选择要更改的变量,然后按两次Alt + Shift + R.再次检查getter / setter复选框。
#2
0
By default eclipse will not rename getters and setters when using 'inline' renaming of a variable. However you can change this behaviour by using the 'Rename Field' dialog for a rename once, and selecting 'Rename getter' and 'Rename setter'. (see the answer by idrosid for details only how to open this window).
默认情况下,当使用“内联”重命名变量时,eclipse不会重命名getter和setter。但是,您可以通过使用“重命名字段”对话框重命名一次,然后选择“重命名getter”和“Rename setter”来更改此行为。 (有关如何打开此窗口的详细信息,请参阅idrosid的答案)。
After this the 'inline' renames will also update the getter and setter for that field (but not the parameter in the setter).
在此之后,“内联”重命名还将更新该字段的getter和setter(但不更新setter中的参数)。
Note, I have tested this with Eclipse 4.5
注意,我已经使用Eclipse 4.5进行了测试