You can customize the rules that are used to generate the
code for a simplified model.
Procedure
- Open RulesComposer from IBM® Rational® Rhapsody®.
Choose .
- If the project is not already open, choose in
RulesComposer and selecting the <Rational Rhapsody
installation path>\Share\CodeGenerator\GenerationRules\LangC\RuleSet\RiCWriter folder.
When you choose this directory, Eclipse automatically loads the RiCWriter project
that it contains.
Note: The project is
read-only by default. In order to modify the rules, you need to change
the relevant files to read-write.
- Once the project is open, make your changes
to the rules and script files (.java, .tgs).
The files are located in the src subfolder. Notice
the Placeholders package. It contains hooks provided in the
default rules for user customization. These hooks are empty scripts
where you can enter code. These scripts are run from the existing
rules at the appropriate time during code generation.
- Save your changes.
- After saving your changes, you can test
them by selecting Run in Eclipse. Eclipse applies
the rules to the current model. You can then look at the generated
code to verify that the new rules had the intended effect.
Results
Note: The updated rules can only be used to
generate code if there is an existing simplified model to which they
can be applied. You must generated code with Rational Rhapsody at
least once for the model with the CodeGeneratorTool property
set to Customizable and the ShowCGSimplifiedModel property
set to Checked. (When the ShowCGSimplifiedModel property
is set to Cleared, the simplified model is deleted
after code generation has been completed. So in such a case, you would
not have a simplified model to which the updated rules could be applied.)\