When you need to rename the package, class, method, range, local variables, and so on, please do not pass the search->replace ... or Search->replace in path ... menu, but should be done with refactoring. As mentioned earlier, because elements may already have many callers in one project, replacing the renaming will make it difficult to guarantee synchronous changes to definitions and invocations, while refactoring provides simultaneous adjustment from semantic correlation. It should be said that with the refactoring, the replacement function will be greatly weakened in the JBuilder.
1, domain name and variable renaming
Open the Java file, place the cursor at the code identifier of a range or local variable, and ctrl+shift+r->rename the refactoring dialog box by using the field:
Figure 4 Dialog for renaming a domain or local variable
· Class: Classes with domain or local variables
· Old name: Formerly known
· New name: Newly named
Press OK, then click on the application refactoring of the preview window to synchronize the changes with all referenced locations JBuilder.
Property Renaming Table 3
The difference between a property and a range is that the former has a get/set access method, and the corresponding Get/set method must be changed synchronously when changing the name of the property variable. Unfortunately, refactoring in the editor, you can't do this, fortunately, in the UML browser JBuilder allows you to do this refactoring.
Assuming that the cat class has two properties, one for age and one for name, you now want to refactor the property name to nickname. Switch to the UML view page of the Cat class, right-click the Name property, and select rename for name in the pop-up menu ..., as shown in the following illustration:
Figure 5 Property Rename Refactoring
Eject the Property Rename Refactoring dialog box, as shown in the following illustration:
Figure 6 Property Rename Refactoring dialog box
Type nickname in New name and click the OK button to complete the refactoring. JBuilder completes the refactoring of property access method names in addition to the renaming of property definitions and references: GetName ()->getnickname (), SetName (string name)->setnickname (string Name) and changes all calls that refer to both methods.