JBuilder2005 Renaming of refactoring

Source: Internet
Author: User
Tags range

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.