This topic describes how to generate a plug-in project
for a user-written custom rule using the COBOL Rule Template page
of the New Plug-in Project wizard.
Generating the project
Follow
these steps:
- Open the Plug-in Development perspective.
- Create a new plug-in project:
- On the main menu of the workbench click and click Next. The New Plug-in
Project wizard opens.
- On the first page of the wizard, titled Plug-in
Project:
- Enter a name for the new project in the Project name field.
- Accept the default values in the other fields on this page.
- Click Next.
- On the second page of the wizard, titled Content:
- Enter an ID for the new project in the ID field.
- Accept the default values in the other fields on this page.
- Click Next.
- On the Templates page of the wizard, select the option to create
a user-written custom rule:
- Select Create a plug-in using one of the templates.
- Select Custom COBOL Code Review Rule.
- Click Next.
- On the COBOL Rule Template page of the wizard:
- Enter the following information:
- 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.
Note: 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 displayed in the analysis configuration editor.
Note: This name is translatable.
The default value for this field
is "My custom COBOL rule".
- Category
- You can create a new 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. This is the ID of 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.
Note: 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. This is the category within which
the user-written custom rule is displayed in the analysis configuration
editor. Note: This name is translatable.
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 needs to check for violations.
The default is no elements selected.
- 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.
Note: If you
have not already opened the Plug-in Development perspective, open
it when prompted.
- Close the plug-in manifest editor for now.
Translating a rule label or
category name
The method for translating a string such as
a rule label or a category name is described in the Eclipse documentation,
in the topic "Internalization", in the subtopic "Translate plug-in
manifest". See
http://help.eclipse.org/indigo/topic/org.eclipse.rap.help/help/html/advanced/internationalization.html. The main steps are the following:
- In the rule extension created in the plugin.xml, use a %variable
instead of a character string. For example, for the rule label, you
could substitute the variable %myRuleLabel:
<analysisRule
category="category_id"
class="rule_class"
id="rule_class"
label="%myRuleLabel"
severity="1">
</analysisRule>
- Define the variable in the plugin.properties file. For example:
%myRuleLabel="My Rule Label"
Build the project in the usual way.