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:
-
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.
-
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:
-
Identify the BASIS plug-in you wish to install in the left-most column.
-
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.
-
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:
-
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].
-
Make sure you have a well configured BBj Installation in your workspace, and at least one valid BRE.
-
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:
-
Open the Eclipse preferences by clicking on Window > Preferences (On Windows)
-
Navigate to BBj Utilities > BBj Code Formatter
-
Set the bbjcpl and the bbjlst paths if they are not filled correctly for you.
-
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
-
Open one of your programs that has line numbers in a BBj CodeEditor as shown here:
-
Click on the BBj Code Formatter plug-in’s DENUM code toolbutton:
-
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.
This Sample code was taken from https://documentation.basis.cloud/BASISHelp/WebHelp/eus/setup_for_examples.htm
Note:
The DENUM code toolbutton is only enabled when the active BBj CodeEditor contains an editable BBj source program (as shown above).
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.
-
Open any BBj program, with or without line numbers, in a BBj CodeEditor.
-
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. -
Notice that the program code open in the current editor was formatted:
-
The inline IF-Statements have been split into multi-line IF-statements.
From:
To:
-
The lines with multiple statements separated by a semicolon were split into multiple lines.
From:
To:
-
Line continuations have been collapsed to single lines:
From:
To:
-
BBj keywords are converted to uppercase.