Code hints
- Navigate through the list of code hints using the Up Arrow and Down Arrow keys.
- Select a code hint and press Enter. The selected tag is added to the editor.
- As you continue to enter code, additional code hints are displayed. You can also press Ctrl+<Space> to display code hints while you enter a line of code.
The Smart Tag Assist feature of the CFML editor identifies if a tag attribute is already entered for a particular tag. If you have already entered a tag attribute, that attribute does not appear in the list of suggested attributes.
Code Assist for CFM pages
- Displays methods and component list when you use the <cfinvoke> tag in a CFM file.
- Displays a drop-down list of predefined attributes and values when you press <cf+Ctrl+<space>.
- Displays a list of components (CFC) that can be loaded using createobject() or the <cfobject> tag.
- Displays methods created in a CFC, which can be called using the component object created in a CFM. Also displays a list of methods of all extended CFC files.
- Displays a drop-down list of all built-in and user-defined functions.
- Provides a list of variables, like, struct, array, query. These variables are declared in a page. The variables also appear as Code Assist for attribute values.
- Displays all the queries created using <cfquery> or queryNew(). To view the recordset, type <cfoutput query="">, and press Enter. or use queryname. (that is, query name followed by dot).
- Includes the functions, variables, tags, and queries from another CFM page once it is included in the current CFM page using the {{<cfinclude> }}tag.
- Allows you to browse and select a file as the input value for an attribute of CFM tags. CFM tags that require a file as the input value include <cfinclude>, <cfimage>, <cfdirectory>, <cfpdf>, <cffile>, <cfzip>, <cfspreadsheet>, and <cfcollection>.
Code Assist for CFC pages
Code Assist for scoped variables using variable mapping
Many ColdFusion frameworks create CFCs during application startup and store these CFCs as scope variables. To provide Code Assist for such CFCs, ColdFusion Builder must determine the content and data type (fully qualified name of the CFC).
To enable Code Assist for CFCs that are stored in scoped variables, define a project-level mapping for the variable name and its corresponding CFC type. ColdFusion Builder uses this mapping information and displays a list of CFC methods for the mapped variable, without creating an object of that data type. For example, you can map mycfc1 to com.adobe.mycfcs.cfc1. When you type mycfc1 and press Ctrl+<space>, all the methods available for com.adobe.mycfcs.cfc1 appear.
To configure a variable mapping, in the Properties dialog box, Specify the variable to map as mycfc1 and the mapped to value as com.adobe.mycfcs.cfc1. For more information, see Configure variable mappings.
Code Assist for ColdFusion ORM
Object Relational Mapping (ORM) is a programming technique that lets you define a mapping strategy using object models. You can use Object Relational Mapping to store and retrieve data from a relational database.
ColdFusion Builder provides Code Assist for the following ColdFusion ORM settings:
- Entity names in entityLoad, entityNew, and entityFindByPK functions.
- Methods and properties returned by entityLoad, entityNew, and entityFindByPK functions.
- Code hyperlinks for entity names and methods.
- Data sources in application.cfc. For example, <cfset this.datasource = >.
- Table attribute of the cfcomponent tag.
For more information about using ColdFusion ORM, see ColdFusion ORM in the ColdFusion Developer Guide.
Code Assist for Application.cfm and Application.cfc files
Code Assist is available for Application.cfm and Application.cfc files.
Application.cfm is considered an included file and Code Assist is available for all variables and functions within the file.
For Application.cfc, Code Assist is available only for scoped variables that are declared in onApplicationStart.
Set CFML Editor Code Assist preferences
- From the Window menu, select Preferences.
- In the tree-view, select ColdFusion > Profiles > Editor > Code Assist.
Code hyperlinks for CFCs and UDFs
Component names and UDFs are hyperlinked on Ctrl+hover. If you click the hyperlink, the corresponding code is opened in ColdFusion Builder. Code hyperlinks are available for:
- UDFs: local, included, and cfc.udfName
- Template in <cfinclude template=””>
- CFCs in createobject(), <cfobject>, <cfinvoke>, new keyword, and extends attribute.
CFC name resolution using server mapping
Use ColdFusion Administrator to define server mapping for CFCs. The server mappings allow you to view these CFCs as part of Code Assist when you use the extend or implement keywords.
ColdFusion server mappings let cfobject and cfinvoke tags, or functions like createObject or new, access pages and find ColdFusion components outside the document root.
If you specify a path in these tags that starts with the mapping's logical path, ColdFusion looks for the CFC using the mapping's directory path. You can define server mapping for the CFCs using the ColdFusion Administrator. After mapping, you can view the CFCs in Code Assist when you use the extend or implement keywords, and component or method attributes. The CFCs suggested in Code Assist are resolved with their fully qualified names.
Once mappings are created for the CFC name resolution from the server, the server settings are cached and available even when the server is not running. The server settings are collected when the server is started or refreshed from ColdFusion Builder.
Specify server settings
- From the Windows menu, select Preferences.
- In the tree view structure, select ColdFusion > Server Settings.
- Select the Build Server Settings check box and the Required check box to indicate the action for collecting server settings. For example, to collect server settings each time you start ColdFusion Builder, select the ColdFusion Builder Started check box.
CFML Dictionaries
ColdFusion Builder provides in-built dictionaries that assist you with CFML code completion. The CFML dictionary is an XML file that contains information about each tag and function contained in the library. For example, the CF9 dictionary file (cf9.xml) contains information about all the available CF9 tags and functions.
ColdFusion Builder provides dictionary support for ColdFusion 11, ColdFusion 10, ColdFusion 9, ColdFusion 8, and ColdFusion MX7 versions.
To select a dictionary version, do the following:
- From the Window menu, select Preferences.
- In the tree-view, select ColdFusion > Profiles > Editor > Code Assist.
- Select the Code Assist Dictionary version drop-down list and select a dictionary version to assist with code completion.
- Click Reload Dictionaries to reload all the dictionaries, including custom dictionaries.
Create custom CFML dictionaries
You can create a custom CFML dictionary (XML file) and make it available to use for Code Assist and Tag Editor within ColdFusion Builder.
- Within the ColdFusion Builder installation, navigate to the following location:\plugins\com.adobe.ide.coldfusion.dictionary_XXX\dictionary
- Create a folder called "Custom" within the Dictionary directory.
Create an XML file to describe the custom tags and functions. For example, in the XML file, you describe each tag within <tag></tag> elements, and enclose all the tag elements within <dictionary></dictionary>elements as follows:
<dictionary>
<tags>
!--
cfabort
showError = "error_message"
-->
<tag endtagrequired="false" name="cfabort" single="true"
xmlstyle="false">
<parameter name="showerror" required="false" type="String">
</parameter>
</tag>
</tags>
</dictionary>
|
See the cf9.xml or cf8.xml files as reference to create the custom CFML dictionary.
Auto-insertion of required attributes
In the Code Assist (Window > Preferences > ColdFusion > Profiles > Editor > Code Assist), select Auto Insert Required Tag Attributes to insert the required attributes of a tag.
Note: This is the default setting.
|
For example, if you select cfpdf "action=write", all the required attributes destination, source, and name are automatically inserted.
If the preference is not selected, the attributes are not inserted but only proposed.
Separate list of required and optional attributes
Code Assist prompts you with a list of tag attributes as follows:
- Shows required tag attributes at the top of the proposal list with check marks to indicate that the attributes are mandatory.
- A line separates the mandatory and optional attributes.
Proposals for createObject
Code Assist proposes all objects (and the corresponding arguments) supported by the function createObject.
Cyclic Code Assist proposals
In the Code Assist (Window > Preferences > ColdFusion > Profiles > Editor > Code Assist), select Cycling Code Assist Proposals for cyclical code assistance.
Note: This is the default setting.
|
Consider the scenario where when you press Ctrl+<Space>:
- Variables, scopes, and UDFs are listed
- On this list, if you further press Ctrl+<Space>, all built-in functions are proposed
- On this list, if you further press Ctrl+<Space>, all proposals are listed.
- The cyclic proposals continue on subsequent use of Ctrl+<Space>.
Note: Cyclic Code Assist does not appear if you manually specify a part of the text for which you want prompt.
|
Filter proposals containing text
In the Code Assist (Window > Preferences > ColdFusion > Profiles > Editor > Code Assist), select Filter Proposals Containing Text to filter proposals based on the text you specify.
Note: This is the default setting.
|
All proposals that contain the filter text you specified are listed with selection set to the proposal that starts with the specified text.
Datatype-aware Code Assist
Shows Code Assist proposals based on expected data types.
For example, when you load Code Assist within the function Abs, it shows functions and variables of type numeric, Any, or complex data types such as array, struct, or component.
Auto-insertion of function arguments
When you insert a function, all required arguments are automatically inserted. By default, the first argument is selected.
Function context assist
Smart Code Assist for connection attributes
Smart Code Assist displays connection variables created for tags such as cfexchangeconnection and cfftp.
Usage-based Code Assist for cfloop
Based on the type of loop, the required attribute is auto-inserted. For example, if you loop over an array, the attribute index is auto-inserted.
Select tag blocks of your choice
Use the shortcut Ctrl+Alt+B (Windows) or Command+Option+B (Mac) to select tag blocks. The enclosing tag block from the caret position is selected.
Retain the selection and repeat the shortcut for cumulative selection of code.
For example, in the following snippet, when you press Ctrl+Alt+B/Command+Option+B, the cfform tag block is selected. If you retain the selection and then press Ctrl+Alt+B/Command+Option+B, code selection is extended to the next level of enclosure. That is, the entire code block is selected.
<cffunction name="test">
<cfform name="form1">
<!--- caret position --->
</cfform>
|
Jump to matching tag
Use the shortcut Ctrl+Alt+M (Windows) or Command+Option+M (Mac) to move the caret position from beginning to end or end to beginning of a tag block.
Note: The caret position can be anywhere within the start or end tag (and not exactly on the tag name).
|
Quick Fix
Quick Fix recognizes the usage of methods, classes, and CFC/CFM files in the code and helps you generate them.
For example, if you type a user-defined function {{test() }}that is not defined in the page or any included page, Quick Fix helps you generate the function. The function call is inserted in the file.
When you open/edit a file, ColdFusion Builder automatically identifies the function calls, CFCs, and CFMs that are not defined. A bulb icon appears in the left margin of the editor which, if clicked, prompts you to perform the appropriate quick fix.
Note: The shortcut CTRL+1 also yields the same result.
|
You can turn off the Quick Fix by unchecking Enable Quick Fix (Window > Preferences > ColdFusion > Profiles > Editor > Syntax Checking).
Quick Fix helps you in the following scenarios:
- Call to local UDF in any language construct, for example cfset or cfscript assignment, function arguments, or any other expression. If you specify any arguments in the UDF, then Quick Fix also creates the arguments. Depending on where the function is called, ColdFusion Builder generates the code.Both tag and script-style syntax are supported, depending on the context. That is, Quick Fix generates a method in script-style if it is called in script-based syntax.
- Method call on a CFC, for example cfc1.function1(). If function1 is not defined in CFC1, then Quick Fix creates it.
- Create CFC from createObject, new, cfobject, and cfinvoke. ColdFusion Builder provides options to create CFC with respect to wwwroot (if the server is associated with the project), project, or in a folder selected by the user.
- Create CFM page from cfinclude and cfmodule
- Create CFCs and CFMs from extends and implement attributes.
Example
<cfset o1 = new component1()>
<cfset st = structNew()>
<cfset result = getResults("abc", 10, st)>
<cfinclude template="test3.cfm" >
<cfscript >
o2 = new component2();
//Assume that component2 exists
o2.someFunction();
</cfscript>
|
In the snippet, Quick Fix finds four unresolved issues and prompts action:
Line of code
|
Issue
|
Prompt
|
---|
<cfset o1 = new component1()>
|
Component is not created
|
Create CFC
|
<cfset result = getResults("abc", 10, st)>
|
Function getResults does not exist
|
Create the function getResults
|
<cfinclude template="test3.cfm" >
|
test3.cfm does not exist
|
Create test3.cfm
|
o2 = new component2();
|
Component does not exist
|
Create someFunction in component2.
|
Additional resources
Code Formatter
You can change the look of your CFML code using Code Formatter. The feature helps you standardize indentation, line length, and the case of tags and attribute names. Code formatter formats both tag and script-based syntax.
You can
- Select a CFML file within a project and format its code.
- Format code of an open CFML file in editor.
- Select a section of code in CFML file and format.
In addition to CFM and CFC files, Code Formatter supports formatting of HTML, XML, CSS, and JavaScript code within a CFM or CFC file.
Formatting your code
- In the editor, open the CFM or CFC file.
- Do either of the following:
- Right-click and then select Format.
- Use the keyboard shortcut Ctrl+Shift+F (Windows) or Command+Shift+F (Mac)
Note: To format a section of the code, select it before step 2.
|
Customizing the preferences
Code Formatter has an off-the-shelf set of preferences defined in a profile. To customize the preferences, create a profile or modify the default profile after giving a new name.
- In ColdFusion Builder, select Window > Preferences.
- In the tree view, select ColdFusion > Profiles > Editor > Formatter.
Click Add to add a new profile or Edit to edit an existing profile after selecting the profile in the Active Profile.
Note: You cannot edit the default profile.
|
In the CFML Formatting Profile, add or modify the profile by setting the rules specified in the following table. The code formatting preferences are based on the rules. Each tab in the dialog box represents a rule.
Rule
|
Options to
|
---|
General
|
• Specify if you want to maintain the case currently used for tags and attributes, or change it to upper or lowercase.
• Append /> at the end of the tag, for example, modify <cfargument …. > as <cfargument …. />. Specify the tag to which you want to append /> and then click Add.
• Place the closing tag for cfoutput (</cfoutput>) on a new line only if the content spans to multiple lines.
|
Indentation
|
• Specify the indentation details and the name of the tags for which you do not want to apply indentation.
|
White space
|
• Add white space based on your selections.
• Add blank lines based on your selections.
• Specify the number of blank lines that you want to retain.
|
Wrapping
|
• Specify the number of attributes in a line within a tag and set the column width.
• Specify various constructs for wrapping.
|
Braces
|
• Specify if the curly braces are placed in the same or new line for component and function declarations and switch, if, else, and try blocks.
|
Sharing the preferences
You can share the formatting preferences in XML format.
Use the appropriate buttons in the Formatter section of the Preferences dialog box (Window > Preferences > ColdFusion > Profiles > Editor > Formatter) to export your preferences or import preferences shared by somebody.
Auto-formatting
ColdFusion Builder automatically indents lines of code and adjusts the ending tag, to improve readability.
Auto-formatting works in the following scenarios:
When you type code
- Indents when you press Enter with the cursor placed after
- > of the start tag
- Opening curly brace ({)
- > for closing tag.
- the closing tag if it is auto-completed while typing </.
- When closing, curly brace (}) is placed in alignment with the opening curly brace ({).
When you use Code Assist
- If you auto-insert closing tag, while typing forward slash (/), it is placed at the correct location with respect to the start tag.
- If you auto-insert closing tag, it is aligned to the start tag.
Code colorization
ColdFusion Builder can highlight the syntax for CFML tag names, attributes, attribute values, keywords, comments, and various other elements in different colors. Code colorization is also supported in script-style coding. You can customize the color preferences and override the default Eclipse editor color preferences.
Set CFML Editor color preferences
- From the Window menu, select Preferences.
- In the tree-view, select ColdFusion > Profiles > Editor > Syntax Coloring.
- You can import and export your color preferences as a COL file.
Set SQL Editor color preferences
- From the Window menu, select Preferences.
- In the tree-view, select ColdFusion > Profiles > Editor > Colors. Under Tokens, scroll down to SQL, and select color preferences for comments, keywords, and text.
SQL Editor
The CFML editor has an integrated SQL editor that lets you edit, write, and execute SQL statements.
To use the SQL editor, you must have a server configured and running in ColdFusion Builder. The SQL editor does not support offline databases.
The SQL Editor supports Code Assist and code colorization for the following types of SQL statements:
- Select
- Insert
- Update
- Delete
Note: For SQL statements within the cfquery tag, Code Assist is available in the CFML Editor itself. You need not open the SQL Editor for code completion hints.
|
Using SQL Editor
- Do one of the following:
- Right-click in the CFML editor, and select SQL Editor.
- Use the keyboard shortcut Ctrl+Alt+S (Windows) or Command_Alt+S (Mac OS).
- In the SQL Editor, select a server from the Server drop-down list and a database from the Datasources drop-down list.
- Enter the SQL statement and do the following:
- Click Execute Query to display the results of the SQL statement in the Query Result tab. You can execute only SELECT statements in the SQL Editor.
- Click OK to insert the SQL statement in the CFML editor at the current caret position. caret is the marker in the CFML editor that indicates where the next character appears.
- You can also copy SQL code blocks from the SQL Editor directly into the CFML editor by selecting the code block and pressing Shift+Enter.
- To edit a SQL code block in the CFML editor, select the code block, right-click, and select SQL Editor. The selected code block appears in the SQL Editor.
For more information about basic SQL syntax and writing SQL statements, see Using SQLin the ColdFusion Developer Guide.
SQL Code Assist
SQL Code Assist is available only for database table names and field names in the SQL statement.
By default, SQL Code Assist is turned on in ColdFusion Builder, and code hints for SQL statements are automatically displayed in the CFML Editor. To turn off the automatic display of SQL Code Assist, do the following:
- From the Window menu, select Preferences.
- In the tree-view, select ColdFusion > Profiles > Editor > Code Assist.
- Deselect Automatically Display SQL Code Assist When Typing.
Even with the automatic display of SQL Code Assist turned off, you can still get code hints within your SQL statements as follows:
- Begin entering the SQL statement in the SQL editor and press Ctrl+<Space> to display the database table names or field names.
- Navigate through the list of table names or field names using the Up Arrow and Down Arrow keys.
- Select a table name or field name and press Enter. The selected table or field is added to the SQL statement.
ColdFusion Builder provides Code Assist for the query attribute of the <cfoutput> tag. For example, when you type, <cfoutput query="">, and press Ctrl+<Space> with the caret position between the double quotes "". A list of queries created in that file or included files appears.
Code Assist is also provided for query names that are used in expressions.
For example, if you create a query like:
<cfquery datasource="dsn1"name="q1">
Select id, firstName, lastName from employee
</cfquery>
|
When you type the expression <cfset name = q1.> and press Ctrl+<Space>, ColdFusion Builder displays the columns selected in that SQL query.
SQL Code colorization
In the CFML editor, SQL code colorization is supported only within the cfquery tag. You can colorize SQL keywords, comments, and text within the cfquery tag. Colorization is supported only for the following types of SQL comments:
To set SQL code colorization preferences, see Set SQL Editor color preferences.