Working with the BBj Code Formatter Eclipse Plug-in

This topic contains the following sections:

Overview of the BBj Code Formatter Plug-in

The BBj Code Formatter plug-in helps developers quickly format source code according to some predefined formatting rules. At the time of writing (version 18.00), it can:

  • DENUM your programs

  • Remove line continuations in your programs

  • Convert single line IF-Statements to multi-line IF-Statements

  • Split multiple statements separated by a semicolon into multiple lines

  • Convert the BBj Keywords in your program to uppercase

Note:

Although the BBj Code Formatter plug-in has been tested with a significant amount of source code already, it might still encounter conditions where it needs further rules or where it is unable to resolve all formatting issues. For that reason, you should perform a backup of your source code before formatting it so that you can restore the original code if you are not satisfied with the formatting the BBj Code Formatter plug-in applies.

Installing the BBj Code Formatter Plug-in

In order to use the BBj Code Formatter plug-in, you must first install Eclipse and then install the desired plug-in. Follow the steps below to get your Eclipse plug-in environment configured:

  1. Install the version of Eclipse following the instructions provided at https://www.basis.cloud/eclipseplug-ins.

    Note:

    The BBj Code Formatter plug-in is part of the BBj Utilities since BBj 18.00. Therefore, you must install Eclipse for BBj 18.00 or higher to use it.

  2. Install the BDT plug-in, then install the BBj Code Formatter plug-in (in that order). For both installations, follow the instructions provided on https://www.basis.cloud/eclipseplug-ins (see the “BASIS PLUG-INS” section near the top of the page). Select the URL from which to install the plug-in in that table:

    1. Identify the BASIS plug-in you wish to install in the left-most column.

    2. Select a URL that has the same major revision number as the BBj installation on your development computer. For example, if you will be running BBj 18.00, 18.10, or any version starting with 18, then choose a URL that has “18” in it.

    3. If you are unsure which URL to use, select the URL in the “Official Release” column (usually right next to the plug-in name). This will be the most recent public release. Simply upgrade the BBj on the development computer to the most recent version with the same major revision identifier (17.xx, 18.xx, etc.).

Accessing the BBj Code Formatter Plug-in

Now that you have Eclipse and the BBj Code Formatter Plug-in installed, start Eclipse and perform the following steps to begin using it:

  1. Open the BDT perspective from the main menu: Window > Perspective > Open Perspective. If ‘BDT’ is available, select it; otherwise, select ‘Other’, then choose ‘BDT’ and click [OK].

  2. Make sure you have a well configured BBj Installation in your workspace, and at least one valid BRE.

  3. Before formatting code, ensure that the bbjcpl and the bbjlst paths are properly configured in the BBj Code Formatter Plug-in’s preferences. Follow these steps to configure the BBj Code Formatter:

    1. Open the Eclipse preferences by clicking on Window > Preferences (On Windows)

    2. Navigate to BBj Utilities > BBj Code Formatter

    3. Set the bbjcpl and the bbjlst paths if they are not filled correctly for you.

  4. Make sure the BBj Code Formatter toolbar buttons are visible, either in the enabled or disabled state:

    Enabled:

    Disabled:

    Note:

    The Format BBj Code toolbutton is only enabled when the active BBj CodeEditor contains an editable BBj source program (as shown above).

Using the BBj Code Formatter Plug-in

Now that you have configured Eclipse for the new BBj Code Formatter Plug-in, you are ready to use it. The plug-in can DENUM your code, or it can format your code, depending on the preferences you’ve set.

DENUM a BBj Program

  1. Open one of your programs that has line numbers in a BBj CodeEditor as shown here:

  2. This Sample code was taken from https://documentation.basis.cloud/BASISHelp/WebHelp/eus/setup_for_examples.htm

  3. Click on the BBj Code Formatter plug-in’s DENUM code toolbutton:

  4. Note:

    The DENUM code toolbutton is only enabled when the active BBj CodeEditor contains an editable BBj source program (as shown above).

  5. See that the BBj program line numbers are now gone:

    Note that the open BBj CodeEditor is now “dirty” (it has unsaved changes). If you do not wish to save your DENUM changes, simply close the editor without saving or select Edit > Undo Typing. Otherwise, save your changes.

Format a BBj Program

The BBj Code Formatter plug-in formats your code according to the formatting preferences you set. The following steps describe the result of the formatting with all the formatting preferences enabled: Keywords to uppercase, split single line IF-Statements, etc.

  1. Open any BBj program, with or without line numbers, in a BBj CodeEditor.

  2. Click on the BBj Code Formatter plug-in’s 'Format BBj Code' toolbar button to format the code.
    If the program has line numbers, you will be prompted to remove them.

  3. Notice that the program code open in the current editor was formatted:

    1. The inline IF-Statements have been split into multi-line IF-statements.

      From:

      To:

    2. The lines with multiple statements separated by a semicolon were split into multiple lines.

      From:

      To:

    3. Line continuations have been collapsed to single lines:

      From:

      To:

    4. BBj keywords are converted to uppercase.