Code Assist

Note: Code Assist is also called Content Assist. These terms are used interchangeably.

Code Assist is designed to assist you with code completion. Depending on the code that you enter, hints relevant to complete the code appear. As you type the code in the CFML editor, Code Assist prompts you with a list of valid CFML tags, parameters, and attributes. These suggestions appear in a pop-up menu. If you have HTML, JavaScript, or CSS content within the CFML code, Code Assist displays code completion hints for this code as well. Double-click or press Enter, to insert the code completion hint in the CFML Editor.

Code Assist is also available for script-based syntax; for example, code hints appear for functions and components in the script syntax. When you import Ajax libraries into ColdFusion projects, Code Assist is available even for the JavaScript code.

Using Code Assist

Code hints appear whenever the framework or language (CFML, HTML, JavaScript, and CSS) provides options for you to complete the current expression. For example, if you type within a CFML tag, you are prompted with a list of all the attributes of that tag.

  1. In a CFML page, begin entering a CFML tag by typing:

    <cf

    Relevant code hints are displayed as follows:

    Code hints
  2. Navigate through the list of code hints using the Up Arrow and Down Arrow keys.

  3. Select a code hint and press Enter. The selected tag is added to the editor.

  4. 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

  • Displays a list of components (CFC) that can be loaded using createobject().

  • Displays a list of components (CFC) that can be loaded using the <cfobject> tag.

  • Displays methods created in a CFC, which can be called using the component object created in a CFM.

    Examples:

    • <cfset obj1 = createobject("component", "c1")>

      <cfset x = obj1.method1()>

    • <cfset obj2 = createobject("component", "c2").init()>

    • <cfset obj3 = new "c3"().method3()>

    • <cfinvoke component="c4" method="method4">

  • Displays a list of methods of all extended CFC files. The "extends" and "implements" keyword/attribute lists the available components and interfaces.

  • Displays a list of components that can be extended in the current CFC file.

    Note: Code Assist is not supported for comments that are added to component properties. For example, Code Assist is not supported for a comment that you add to the numeric accountID property as follows:/** @ -- code assist is not supported here --*/
  • Displays a list of interfaces that can be used in a CFC with the implement keyword.

  • Allows you to browse and select a file as the input value for an attribute of CFM tags or functions like <cfif fileexists()>.

    CFM tags that require a file as the input value include <cfinclude>, <cfimage>, <cfdirectory>, <cfpdf>, <cffile>, <cfzip>, <cfspreadsheet>, and <cfcollection>.

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

  1. From the Window menu, select Preferences.

  2. In the tree-view, select ColdFusion > Editor profiles > Editor > Code Assist.

    • You can select the Code Assist Dictionary version to assist with code completion. ColdFusion 9, ColdFusion 8, and ColdFusion MX7 dictionary versions are supported.

    • Select the Automatically Display Code Assist When Typing check box to automatically display Code Assist when typing.
      Note: When editing large-sized files, you can deselect the Automatically Display Code Assist When Typing check box to improve performance of the editor. You can, however, display code hints while you enter a line of code by pressing Ctrl+<Space> or any other keyboard shortcut that is set.
    • You can choose to automatically quote attributes and select closing tags.

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

  1. From the Windows menu, select Preferences.

  2. In the tree view structure, select ColdFusion > Server Settings.

  3. 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 9, ColdFusion 8, and ColdFusion MX7 versions.

To select a dictionary version, do the following:

  1. From the Window menu, select Preferences.

  2. In the tree-view, select ColdFusion > Editor profiles > Editor > Code Assist.

  3. Select the Code Assist Dictionary version drop-down list and select a dictionary version to assist with code completion.

  4. 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 wizard within ColdFusion Builder.

  1. Within the ColdFusion Builder installation, navigate to the following location:

    \plugins\com.adobe.ide.coldfusion.dictionary_XXX\dictionary

  2. Create a folder called "Custom" within the Dictionary directory.

  3. 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.