Completing code with content assist

Content assist is available for ILE RPG, ILE COBOL, and C++ programs. You can use it along with specialized templates to help you complete your code.

About this task

To use content assist:

Procedure

  1. While in the Remote System Explorer, open a file you want to edit.
  2. From the Edit workbench menu, select Content Assist or press Ctrl+Space
  3. Double-click on a possible completion from the list

Results

Example

If you are editing an RPGLE member in the LPEX editor, you can type the partial text for a template alias and press Ctrl+Space to view a list of valid completions. For example, if you type if in ILE COBOL, followed by Ctrl+Space, a list of completions appears in the content assist pop-up. One of the completions is the IF - ELSE - END-IF template. When that template is selected, the actual text will be inserted in the LPEX editor.

Creating a new template

About this task

Template support is available for both ILE RPG, ILE COBOL, and C++ programs. You can use templates to predefine a structured description of coding patterns that reoccur in your source code. The LPEX editor supports the use of templates to fill in commonly used source patterns. For example, if you often use a particular coding pattern, you could avoid typing it each time that you want to use it by starting with a template. Invoking content assist at the point of this pattern in your code gives you a list of possible templates. Selecting a template will insert the code into the LPEX editor.
Restriction: For RPG source, you can only use templates for free-form RPG.

To create a template:

  1. Select Window and click Preferences.
  2. Click Remote Systems > Remote Systems LPEX Editor > i Parsers.
  3. Select from the listed languages.
  4. Select Templates.
  5. Click New.
  6. In the new template dialog box, type the name of the template, and select a language from the Context drop-down list.
  7. In the Content field, type the code that you want content assist to insert.
    Template variables may be used in the template content. Variables are resolved to their concrete values when the template is evaluated in its context. The following variables are available:
    ${cursor}
    Specifies the cursor position when you leave the template edit mode.
    ${date}
    Evaluates to the current date.
    ${file}
    Evaluates to the base name of the file.
    ${time}
    Evaluates to the current time.
    ${user}
    Evaluates to the user name.
    ${year}
    Evaluates to the current year.
  8. Click OK twice.

To insert this new template, type the template name in your code, and press Ctrl+Space.

The new template name that you created appears in a popup window. Double-click on this completion to insert the contents of the template into your code.


Feedback