Miscellaneous refactoring of JBuilder2005 realization refactoring

Source: Internet
Author: User

1. Optimize Import

In short, by optimizing the settings for import, you can achieve the following objectives:

Remove unwanted import Statements: If a class in any package is not used in the class, the import statement of the package can be deleted.

Set thresholds for packages: when the current class references the number of classes in the package greater than this threshold, the entire package (such as import java.io.*) is introduced, otherwise an import statement (such as import Java.io.File) that is specified separately for each referenced class in the package.

To set the order of the packages: according to the general habit, according to the common degree of the package from high to low, the commonly used packages are put in front of the introduction. Under normal circumstances, JDK classic packages are placed at the front (in Java.), the JDK expansion pack immediately follows (javax.), followed by a Third-party class library package (such as org.apache.*), a common class library of its own development, and finally the other classes in the project.

Switch to threshold on the Imports Settings page via Project->project Properties...->java formating->

Figure 25 Setting the Package Threshold dialog box

The package import threshold specifies the threshold of the package by default, which is introduced by the wildcard character as an entire package after the import is optimized by 0.

You can also check the Always import classes entry and introduce each class with a separate import statement, which is equivalent to setting the package import threshold to infinity.

Switch to the Sort Order tab page in the Imports Settings page, where you specify the sequence and format of the import code snippet's package introduction. Assuming that there is a myrefactor.sub1 in the MYREFACTOR.JPX project, we use the following steps to import it to the end of the code snippet and add a blank line earlier:

1) Click Add blank line to add a to the list, which means adding a blank row to the import code snippet.

2) Click Add Prefix ... Select the MYREFACTOR.SUB1 package in the Add Prefix dialog box that pops up.

3) Click OK to save settings.

Figure Import Code Snippet Style Setup dialog box

In addition, you can adjust the placement of the package in the introduction code snippet through move up and move down. There is an <*> item in the list that represents all other mismatched packages, such as one with COM. The open package is placed in the location of <*>.

When you are finished, right-click on the node in the Engineering pane and select Format Package ... In the Pop-up Fomcat Code dialog box to confirm the selection of optimize imports, click OK, JBuilder to the engineering of all classes in the Import Code section to optimize refactoring.

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.