Previous Topic Next topic Print topic


Refactoring Using Quick Actions

You can use Visual Studio's Quick Actions (Light Bulb) feature to refactor your code. The following refactoring techniques are available:

Creating or finding a missing copybook

If your code references copybooks that are not located in any of the paths defined in the copybook paths of the project, the editor provides a quick action for you to either locate the copybook manually or to create the file and add it to the project.

To use a quick action to resolve a missing copybook:

  1. Hover the COPY statement in the editor until the light bulb appears then click the light bulb icon (light bulb) to see the suggested fixes:

  2. Choose one of the suggested actions.

    If you choose to create the copybook, the IDE adds the file to your project and adds its location to the copybook paths of the project.

    If you choose to find the missing copybooks, you can browse and select the file from your file system. The path to the location of the file is then added to the copybook paths of the project.

Converting .NET types to portable COBOL syntax

When writing managed COBOL code that should be used on any platform, a light bulb quick action enables you to convert .NET types with a corresponding predefined managed COBOL type to COBOL predefined types - this helps write platform independent applications which you can easily export from Visual Studio and edit with Enterprise Developer for Eclipse.

To help with this, use the light bulb quick action, Convert to COBOL Syntax. The quick action is available for .NET types and enables you to quickly perform conversions such as System.UInt64 to binary-double unsigned.

The editor provides a light bulb quick action, Convert to portable COBOL syntax, to automatically replace the .NET type with a COBOL predefined type:

Rename refactoring

You can use the Rename quick action to rename a variable, a section or paragraph name or an identifier in a file or in the entire solution:

  1. In the editor, rename one occurrence of the variable or the identifier in the code.

    The light bulb icon (light bulb) appears in the margin by the line which you have edited.

  2. Select a quick action from the list to rename all instances of the name in the current program or across the entire solution.

Simplifying the names of types

When referencing .NET types in your code, you can either use the fully-qualified namespace or only use the simplified name and omit the namespace if the simplified name can be resolved without ambiguity. For example, instead of typing System.String, you can simply type String provided that String is not used by any other class.

The editor provides a light bulb quick action, Simplify name Type, to automatically replace the fully-qualified name with the simplified name:

You can choose to simplify the current occurrence of a fully-qualified name, all occurrences of that name in the current file (click Document), or all occurrences in the current file and any copybooks displayed in the expanded copybook view in it (click Program).

Previous Topic Next topic Print topic