Generating a plug-in project for a user-written rule
To generate a plug-in project for a user-written rule,
run the New Plug-in Project wizard and select
the Custom COBOL or PL/I Code
Review Rule template.
Generating the project
Procedure
Open the Plug-in Development perspective.
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 or Custom
PL/I Code Review Rule and click Next.
On the COBOL Rule Template page or the PL/I 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 or PLIRule.
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 software analysis configuration window. The default value for
this field is "My custom COBOL rule" for COBOL or "My custom
PL/I rule" for PL/I.
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 software analysis configuration window. 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 rule
is displayed in the software analysis configuration window.
The default value is Custom.
Expand the Program tree for COBOL , or the ProgramSourceFile tree
for PL/I, and select the language element or elements that the
implementation code for the new rule must check for violations.
The default is that no elements are selected. For an
example of the Java code that
is generated for selected elements, see the link
at the end of the topic.
Click Finish. The
wizard creates a plug-in project for the new user-written 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 or PL/I Rule
Template page of the wizard adds rule and category extensions
to the plugin.xml file that is generated for
the custom rule plug-in project. See Generated files: Rule and category extensions.
The
wizard also generates a Java class
for implementing a user-written rule. See the related
links at the end of the topic.
You
can internationalize the rule names and category labels to make your
plug-in translatable. The method is described in the Eclipse documentation.
See the link at the end of the topic. The following steps provide
an overview:
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: