Generating a plug-in project for a user-written custom rule
To generate a plug-in project for a user-written custom
rule, use the COBOL Rule Template page of the New
Plug-in Project wizard.
Generated files: Rule and category extensions
The COBOL Rule Template wizard adds
rule and category extensions to the plugin.xml file
that is generated for the custom rule plug-in project.
On the main menu of the workbench, click File > New > Project > Plug-in Development > Plug-in Project and click Next. The New
Plug-in Project wizard opens.
In the Project name field of the Plug-in
Project page, enter a name for the new project and click Next.
In the ID field of the Content page,
enter an ID for the new project and click Next.
On the Templates page, select Create
a plug-in using one of the templates, then select Custom
COBOL Code Review Rule, and click Next.
On the COBOL Rule Template page, complete
the following fields:
Rule class
Enter a fully qualified Java class
name. The wizard assigns this name to the class that it creates to
implement the new rule. The default value for this field is the Project
ID followed by the character string CobolRule.
Tip: The Project ID is the character string that you specified
in the ID field on the Content page
of the wizard.
Rule label
Enter a name for the new rule. This name is added to the list
of available rules that are displayed in the analysis configuration
editor. The default value for this field is "My custom COBOL
rule".
You can create a rule category for the new rule,
or you can add the new rule to an existing built-in or custom rule
category.
To place the new rule into a new rule category, click Create
a new category and enter a category ID and category name
for the new category.
To add the rule to an existing category, click Select
an existing category, then expand the list and select
the category to which you want to add the new rule.
Category ID
Enter a valid Eclipse ID for the category within which the user-written
custom rule is displayed in the analysis configuration editor. The
default value is the Project ID followed by the word custom.
Tip: The Project ID is the character string that
you specified in the ID field on the Content page
of the wizard.
Category name
Enter a name for the category within which the user-written custom
rule is displayed in the analysis configuration editor. The default
value is Custom.
Expand the Program tree and select
the COBOL language element or elements that the implementation code
for the new rule must check for violations.
The default is no elements selected. For an example
of the Java code that is generated
for selected elements, see Generated files: Implementation code.
Click Finish. The
wizard creates a plug-in project for the new user-written custom rule,
adds the project to the Package Explorer view,
and opens the manifest file in the plug-in manifest editor.
If you did not already open the Plug-in Development perspective,
open it when prompted.
Close the plug-in manifest editor.
Results
The COBOL Rule Template wizard adds rule
and category extensions to the plugin.xml file
that is generated for the custom rule plug-in project. For more information
about these extensions, see Generated files: Rule and category extensions.
The
wizard also generates a Java class
for implementing a user-written custom rule. For more information
about this class, see Generated files: Implementation code.
Internationalizing a rule label or category name
About this task
If
you must make your plug-in translatable into different languages,
you can internationalize the translatable strings. The method for
internationalizing a string such as a rule label or a category name
is described in Internationalize plug-in manifest. The following
procedure describes the main steps.
Procedure
In the rule extension that is created in the plugin.xml,
use a %variable instead of a character string. For example, for the rule label, you can substitute the variable %myRuleLabel: