|
Code refactoring is the process of improving the source
code of a program without changing the overall result. Generally,
code refactoring improves code readability and maintainability.
ColdFusion Builder supports various refactoring techniques like
renaming, searching, and previewing of CFCs, CFMs, and UDFs at the
project and workspace levels.
Refactor CFC or CFM filenamesWhen you rename a CFC or CFM, you can refactor all valid
instances of the CFM or CFC, including all references to the CFM
or CFC.
Right-click the file in the Navigator pane.
Select Refactor > Rename.
Enter the new name and preview the changes. When you preview
the changes, you can review the selected instances and deselect
any instance that you do not want to rename.
To rename CFCs or CFMs across all projects in the workspace,
select Update All Projects In The Workspaces.
Note: You cannot rename a CFC or CFM in HTTP or Web server URLs
unless the server is registered and running.
To undo refactoring, use the keyboard shortcut Ctrl+Z (Windows)
or Command+Z (Mac).
Refactor UDFs in CFC or CFM filesOpen the CFM or CFC file in the editor.
Point to the function name, right-click, and select Refactor
> Rename
Specify the UDF name and click OK.
Note: Currently, function
renaming is supported only through the main function declaration
and not from function calls.
Notes and considerationsThe location
of a CFM or CFC file cannot be changed although the inherent Eclipse
editor provides the capability to move files using the Move option.
The CFML Editor does not support renaming a folder although
Eclipse provides this option.
Refactoring methodsYou can refactor methods created for application variables
by creating variable mappings.
For example, consider a scenario where an application variable
is defined for a CFC object as follows:
<cfset Application.appVar = createObject("component","abc.AppCFM.a")>
Say, you have a CFC function, Method(), that
you call as follows:
<cfset Application.appVar.Method()>
To refactor the Method() function, create a
variable mapping for the application variable Application.appVar as
follows: In the Navigator view, right-click the project
and select Properties.
In the Properties dialog box, select ColdFusion Variable
Mappings.
Click New, enter the following details in the Add Mappings
dialog box:
Reference searchYou can search for a CFC, CFM, or UDF in a project or workspace.
Right-click the project in the Navigator pane.
Click References and select Project or Workspace. The results
are displayed in the Search window in ColdFusion Builder.
Other than searching for references at the project or workspace
level, you can search for references while working in the CFML code
editor. Right-click in the CFML editor and select References >
File to search for file references. You can also search for references
at the project and workspace level from within the CFML editor.
|
|
|