Rename Refactoring

Visual COBOL enables you to rename all or selected occurrences in the workspace of variable, section and paragraph names (in native COBOL), of identifiers (in managed COBOL), or of COBOL types that are referenced in Java code and vice versa.

Preferences for rename refactoring

Eclipse supports renaming directly in the editor which renames all occurrences of the identifier, or renaming with a Rename dialog box which enables you to preview and approve the changes before they are applied.

To specify whether you want to rename with or without the Rename dialog box, click Window > Preferences > Micro Focus > COBOL > Editor and either check or uncheck Rename in editor without dialog (enabled by default).

Renaming identifiers in your code

To rename an identifier:

  1. Right-click the item you want to rename in the editor, and click Refactor > Rename.

    Alternatively, click Refactor > Rename from the main menu or right-click the identifier in the Outline or the Program Outline views and click Refactor > Rename.

    If the IDE is configured for quick rename:

    • The IDE prompts you to enter a new name in the editor.

      GUID-D7D6BB8D-FE6C-4D7A-BE03-506B620B5E93-low.png

    • Enter a new name and press Enter to rename all references of the name.

      Optionally, use the commands from the drop-down menu of the rename tooltip to invoke the Rename dialog and preview the suggested changes before they are applied.

    If the IDE is configured to rename with the Rename dialog box:

    1. Specify a new name in the New name field.
    2. Ensure that Update references is checked.
    3. Click Preview to view and approve the changes:

      GUID-BA9EBFB2-125C-459C-9781-1615B61F93D0-low.png

      Ensure the changes are applied as required and click OK.

To revert your changes, click Edit > Undo Rename COBOL Element.

Restrictions

The following restrictions apply to rename refactoring:

  • It is not possible to rename identifiers in a copybook which is referenced using the COBCPY environment variable but is not located in the workspace.
  • It is not possible to rename identifiers in copybooks referenced using a COPY... REPLACING statement.
  • It is not possible to rename typedef members.
  • It is not possible to rename identifiers in any resources that are outside the current workspace.
  • It is not possible to rename identifiers defined using the AS phrase.
  • It is not possible to rename a program name or an entry-point.
  • Rename using a COBOL reserved word is not supported. The IDE does not issue a warning if you use a reserved word to rename an identifier and will rename the instances of the identifier. Trying to build your application, however, will fail.

The following restrictions apply to native COBOL only:

  • It is not possible to rename copybooks from the editor. You can rename copybooks from COBOL Explorer. This, however, does not change any of the references to the copybooks in the code.

The following restrictions apply to managed COBOL only:

  • It is not possible to rename packages.