Renaming elements in capsule-based models

You can change the name of a element in a capsule-based model, and have the source code reflect that change.

About this task

To change the name of a model element, you must have a valid capsule-based C++ model, a transformation configuration, and the generated C++ source. You can rename supported model elements, such as ports, capsule parts, events, operations, attributes, classes, capsules and protocols to update the source code.

Changing the name of elements, such as operations, attributes, ports, and in and out events, changes the source and its full redefinition tree. Attributes and operations that use the passive class as a type change their declarations to ensure that the native types are still valid.

To rename a model element:

Procedure

  1. Right-click a model element; then click Refactor > Rename.
  2. In the Rename wizard, type the new name.
  3. Select or clear the applicable check boxes. If you select the Refactor closed resources with code bodies check box, the system searches for all redefinitions of the given element, including closed models. If you clear this check box, the changes occur in open models only.
  4. Click Preview. The active transformations are queried to see if they support the given element, and any supporting transformations are used to search for the code changes that must occur.

    You must have at least one active transformation for code snippets to be considered during the renaming; if no transformations are active, a warning is displayed.

  5. To preview the changes, click Continue.
  6. To accept the changes, click OK.
  7. To preview the proposed changes to the C++ code, look under Update referencing C++ code. If an attribute's type or an operation’s parameter type is affected by the renaming, their declarations are shown so that you can validate that the native types are still correct.
  8. Click Finish. Only the selected entries are committed to the model.

Results

If you selected to run the transformation after committing the changes, the active transformations run automatically after you apply the changes to the model to synchronize the generated source with the model.

Feedback