Editing Code

In Eclipse, you can edit user-defined operations, choice point, state (entry and exit), and transition code. To edit method code in Eclipse, the method must contain the // {{{USR and // }}}USR tags. This means that the typical rules for a codesync apply; that is, changes in the code must be between // {{{USR and // }}}USR tags for the code associated with the element.

Note: You cannot edit a non-user operation generated by Rational Rose RealTime, or methods that do not contain USR tags. Additionally, you cannot modify attributes. Modifications are only supported for those elements in a .cpp or .c file.

From Eclipse, you can edit the following code from Rational Rose RealTime:

After editing code in Eclipse, you can synchronize those changes into a Rational Rose RealTime model. When you save code in Eclipse, Rational Rose RealTime automatically performs a codesync.

Note: In Eclipse, if you select Save > Save All, a codesync will not be performed if more than one file was saved; codesync occurs only when you save one file at a time.

Synchronizing Code Between Rational Rose RealTime and Eclipse

By default, when you save your code in Eclipse, a codesync is automatically performed. You can disable the Do a codesync on save feature on the Features tab in the Preferences dialog box in Eclipse.

Note: In Eclipse, the Do a codesync on save option is successful only when saving one file at a time. This means that if you make changes to two or more source files, selecting File > Save All in Eclipse does not perform a codesync on all files. We strongly recommend that you save files individually.

The code synchronization process in Eclipse is silent. This means that no confirmation dialog displays in Rational Rose RealTime. The changes are unconditionally synchronized into the model.

Note: Because Eclipse and Rational Rose RealTime share a common file system, you must use caution when modifying code and building. For example, you can modify code for a model element in Rational Rose RealTime, and then modify the same method in Eclipse for that corresponding model element. Saving the changes in Eclipse (which will cause a codesync to be performed in Rational Rose RealTime) will overwrite the initial changes you made to the model element in Rational Rose RealTime. In addition, if you modify a method in Eclipse without saving, generating the component in Rational Rose RealTime overwrites the modifications you made in Eclipse. We strongly recommend that you save and build your changes as often as possible.

Before You Edit

You can only edit code after Eclipse has created a project containing the generated files from the initial Rational Rose RealTime build.

Note: If the CodeSyncEnabled option on the C++ Generation tab is disabled in Rational Rose RealTime, USR tags are not created when the component is generated. Although there are no USR tags, you can navigate to that corresponding element in Eclipse. Instead of positioning the cursor after the // {{{USR tag and before the // }}}USR tag, the cursor is positioned at the top of the file.

When you open a model in Rational Rose RealTime, and that model has been used previously with an established connection to Eclipse, a connection will automatically be established. Rational Rose RealTime will send the model name and the component name to Eclipse after the following items occur:

Upon receiving the model name and the component name, Eclipse creates a C/C++ project with the same name as the component.

Note: If generated files exist from a previous build, in Rational Rose RealTime, click Build > Clean before performing a build. Cleaning the generated files removes all generated files in the common files system excluding the file Makefile.eri.

Editing Choice Point, State (Entry and Exit), and Transition, Code in Eclipse

To edit choice point, state (entry and exit), and transition code:

  1. In Rational Rose RealTime, open a State Diagram for a capsule that has a state with choice point, state entry, state exit, or transition code.
  2. Right-click on the state and do one of the following:

If not currently open, an editor shows the source code for the capsule associated with the selected choice point, state (entry and exit), or transition method, and the cursor moves to the beginning of the first line of code in the method following the // {{{USR tag.

  1. Edit the code after the // {{{USR tag and before the // }}}USR tag.

Editing Operation Code in Eclipse

To edit operation code:

  1. In Rational Rose RealTime:

Or,

  1. Select Edit Operation code in Eclipse.

If not currently open, an editor shows the source code for the operation, and the cursor moves to the beginning of the first line of code in the method following the // {{{USR tag.

  1. Edit the code after the // {{{USR tag and before the // }}}USR tag.


Note: Overloaded operations (same name, different signatures), are supported, and the cursor will be positioned in the correct version of the operation.

Editing Capsule and Class Code in Eclipse

To edit code for a capsule or class, from the Model View tab in the global browser, right-click on a capsule and select Edit Capsule code in Eclipse, or right-click on a class and select Edit Class code in Eclipse. If not currently open, an editor shows the source code for the selected capsule or class, and the cursor moves to the top of the file.

While it is possible to navigate from a classifier (capsule or class) to its source, implementation, or body file by right-clicking on the classifier and selecting Edit Capsule code in Eclipse or Edit Class code in Eclipse, it is not possible to navigate to its corresponding header file. This includes all the HeaderPreface, HeaderEnding, PublicDeclarations, ProtectedDeclarations and PrivateDeclarations items. For a classifier, it is not possible to navigate directly to its ImplementationPreface or ImplementationEnding code segments; however, you can navigate to the top of the file.