Rational Developer for System z

Generating a plug-in project for a user-written custom rule

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:

  1. Open the Plug-in Development perspective.
  2. Create a new plug-in project:
    1. 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.
    2. On the first page of the wizard, titled Plug-in Project:
      1. Enter a name for the new project in the Project name field.
      2. Accept the default values in the other fields on this page.
      3. Click Next.
    3. On the second page of the wizard, titled Content:
      1. Enter an ID for the new project in the ID field.
      2. Accept the default values in the other fields on this page.
      3. Click Next.
    4. On the Templates page of the wizard, select the option to create a user-written custom rule:
      1. Select Create a plug-in using one of the templates.
      2. Select Custom COBOL Code Review Rule.
      3. Click Next.
    5. On the COBOL Rule Template page of the wizard:
      1. 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.

      2. 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.
      3. 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.
  3. 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:
  1. 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>
  2. Define the variable in the plugin.properties file. For example:
    %myRuleLabel="My Rule Label"
Build the project in the usual way.

Feedback