Previous Topic Next topic Print topic


Editing Assistance in the COBOL Editor

Content Assist is an Eclipse feature that provides context-sensitive proposals for typing COBOL code in the editor. In Visual COBOL, Content Assist is available for both native and managed COBOL.

You can change your preferences for Content Assist from within the IDE in Window > Preferences > Micro Focus > COBOL > Editor > Content Assist and specify options such as the case of the inserted words, whether to show the proposal lists or insert single proposals automatically, or whether proposals should be added in overwrite mode or as insertions. See Configuring Content Assist for COBOL for more details.

Content Assist in native COBOL

The following describes the writing assistance that Content Assist provides in native COBOL.

Content Assist enables you to write syntactically correct code, to complete words quickly and to look up available elements.

Content Assist only offers assistance for the data items that are in scope based on the current position of the cursor.

Features include:

Proposal lists
By default, Content Assist does not display a proposal list (a pop-up with suggestions) immediately after you start typing - press Ctrl+Space to display the proposal list.
Note: You can enable auto-activation from the IDE preferences - see Window > Preferences > COBOL > Editor > Content Assist. Ctrl+Space is the default key combination for invoking Content Assist and you change it also from the IDE preferences.

The following list summarizes how proposal lists work:

  • Proposals are context sensitive - the proposal lists only include suggestions that are relevant to the position of the cursor in the code and the type of project.

    For example, proposal lists only show COBOL verbs in the Procedure Division section and not in the Working-Storage section, and the verbs are only relevant to native code. For files with FIXED or VARIABLE source format, proposals are only available in the writing area.

  • Proposals start with the letters you entered with the best match highlighted in the Content Assist pop-up. The list auto-updates as you type.
  • Proposals might include COBOL keywords (keyword), copybooks (Copybook) in the proposal lists for the COPY statement, code templates (code snippet), data items (variable), 78 level items (78 level item), or sections and paragraphs (section)

    By default, Content Assist opens a proposal list that only shows the relevant COBOL keywords and identifiers. To view if there are any code templates that could be inserted at the current position of the cursor, you need to press Ctrl+Space once more.

  • Proposal lists include the COPY statement.
  • Proposal lists are available in copybooks.

    If a copybook is opened in the editor in the context of a program, the proposal lists in the copybook include the variables as defined in the program.

Completing statements
Content Assist provides intelligent assistance for completing COBOL statements. When you are entering a statement, Content Assist shows proposals for the relevant clauses and the identifiers that you can use to complete the statement. The proposals take into account the syntax rules that apply to the statement in the selected COBOL dialect and the identifiers in scope.

To complete a statement:

  1. Start typing the first verb of a COBOL statement.
  2. Press Ctrl+Space to display the proposal list that includes the clauses and identifiers that you can use.
  3. Choose a proposal from the list and press either Enter or Space to insert it in the code.
  4. Press Ctrl+Space to see further proposals.
Completing COPY statements
After entering a COPY statement and pressing Space, the first proposals list that appears includes any copybooks.

You need to choose a copybook from the list for Content Assist to insert after the COPY statement. After the copybook is inserted, the proposals list that appears gives you the option of terminating the statement with a period (.) or continuing it with one of the clauses IN, OF, REPLACING or SUPPRESS.

By default, proposals for COPY statements only include the copybooks that are found in the directories specified on the Dependency Paths tab on the Micro Focus > Build Path page in the project's properties and also includes copybooks from the active dependency paths of any projects referenced by your project, but you can change this so that the proposals also include system copybooks. System copybooks are ones that are not included in the project but are included using the COBCPY environment variable before starting Eclipse. To include the system copybooks, change the Content Assist preferences from Tools > Options > Text Editor > Micro Focus COBOL > Content Assist.

Automatic completion
If a proposal list includes a single proposal, pressing Ctrl+Space automatically inserts that proposal in the code. You can turn off this option from the IDE preferences (go to Window > Preferences > Micro Focus > COBOL > Editor > Content Assist).
Qualifying non-unique names
If variable names are not unique, Content Assist qualifies the names.

Consider the example of a program that defines two group items - StudentRecord and TeacherRecord. Both group items include a number of PIC X elementary items with the same names - for example, FirstName, Surname, Phone and so on. In such a case, Content Assist qualifies the elementary items as follows:

  1. In the Procedure Division, type move and press Space.

    The proposals list that pops-up includes COBOL keywords, the group items defined in your program, and the elementary items that are present in both group items.

  2. Select one of the elementary items, for example Surname of StudentRecord, and insert it in your code.
  3. Press Space which offers to insert the TO clause.

    Content Assist has helped you specify the exact elementary item to use in your code:

    move Surname of StudentRecord to...

Content Assist in JVM COBOL

Note: The following applies to JVM COBOL only.

In JVM COBOL, Content Assist shows proposals that include any methods, fields, properties, types and so on that are available when you declare items or type an object name followed by a double colon or an opening bracket in the Procedure Division.

You can choose an item from the list to complete the code rather than typing it yourself.

The following are examples of where Content Assist pops up:

  • Type Listings - When you start declaring a type, such as 01 my-string type, Content Assist pops up a list of the namespaces and types available to your program, as soon as you press Ctel+Space after the word type. These namespaces are obtained from each of the references to packages you’ve added to your project using the ILUSING directive or using the project's properties (on the Micro Focus > JVM Build Path page).

    As you type a package name, Content Assist shows all the types within that package name. For example, when you type:

    • 01 my-string type - all the available prefixes of the higher-level packages are listed, for example - com, java, javafx.
    • 01 my-string type java. - all the intermediate packages that are children of the java package.
    • 01 my-string type java.lang. - all the types and subpackages within the java.lang package are listed.
  • Member Listings - when you invoke an object, Content Assist pops up a list of methods, fields, properties and events that are available for that object. This happens when you use inline style of invoke statements (with the double colon ::), such as:
    invoke exception-object::
Previous Topic Next topic Print topic