Rename Refactoring

Enterprise Developer enables you to rename variables, section and paragraph names in native COBOL as well as of identifiers in managed COBOL.

To rename:

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

    This starts the rename dialog box.

  2. Specify a New Name for the identifier you want to rename.
  3. Specify whether to rename only in the current project or across the entire solution - set the Search Scope as follows:
    • Current COBOL program
    • Current project only
    • All COBOL projects in solution
  4. Click Preview to review and approve the suggested changes.

    Optionally, check Skip preview changes if references are all confirmed.

  5. Click Apply to make the suggested changes.

After applying any of the changes, you can click Edit > Undo or Edit > Global Undo *Global Rename to revert them.

To rename class files in managed projects from Solution Explorer:

  1. Right-click a class file in your project in Solution Explorer and click Rename.
  2. Specify a new filename and press Enter.

    This opens the Suggested Rename dialog box offering to also rename all instances of the class name you are changing in the code.

  3. Specify whether you want to rename any references to the class in the current project only or in the entire solution, and click Yes.
    Tip: Micro Focus recommends that you always rename the identifier across the entire solution to help avoid introducing errors.

Renaming to a COBOL reserved word

You can specify a new name which is also a COBOL reserved word. Enterprise Developer inserts such names in the code and escapes them with a # as a prefix. For example, if you want to rename your variable or identifier with the word name, renaming replaces the old name with #name.

An escape character is not needed if the identifier is referenced in the code through the :: notation. The following example shows a class in which two variables have been given new names that are COBOL reserved words. The code references the variables directly and with :::

       class-id SomeClass.
       working-storage section.
       01 #name   binary-long.
       01 #accept binary-long.
       01 var-a   binary-long.

       method-id SomeMethod.
           set #name to 0
           set self::accept to 0
           set var-a to 0
           set self::var-a to 0

           declare x as type SomeClass.
           set x::name to 0
       end method.
       end class.

When you are exposing your COBOL applications to other languages, the escape character, #, is not taken into account. For example, from C# you can access the two variables as name and accept.

Restrictions

The following restrictions apply to rename refactoring:

  • When renaming variables in a copybook, the copybook must be shown inline in the referencing program in the expanded copybook view. It is not possible to rename in copybooks opened as stand-alone files in the editor.
  • It is not possible to rename identifiers in copybooks referenced using a COPY... REPLACING statement.
  • It is not possible to rename data items in JCL or BMS files.
  • It is not possible to rename typedef members.
  • It is not possible to rename identifiers in any resources that are outside the current solution.

The following restrictions apply to native COBOL only:

  • Renaming only works in the current program.
  • It is not possible to rename a program or an entry-point.
  • It is not possible to rename copybooks from the editor. You can rename copybooks from Solution 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 only possible to rename identifiers that are defined in the COBOL projects within the current solution.
  • It is not possible to rename namespaces.
  • It is not possible to rename a COBOL type from another .NET language and vice versa - it is not possible to rename .NET types from a COBOL project.