Automatic Updates When Renaming, Deleting, or Removing Project Files - MATLAB & Simulink (original) (raw)

Main Content

Project refactoring tools help you use automatic updates to find and fix files impacted by renaming, deleting, or moving files and folders.

When you rename, delete, or remove files or folders in a project or project reference, a dependency analysis checks for other impacted files and proposes updates. By default, the analysis runs on project files only. You can choose to run the analysis on all files or disable all automatic updates.

To disable all automatic updates when renaming, deleting, or removing files in a project or a project reference, on the MATLABĀ® Home tab, in the Environment section, clickSettings. In the Settings dialog box, in > , in the File Management section, set Detect file uses upon renaming, moving, or deletion in project hierarchy toNever.

You can find and fix impacts to files such as changed library links, model references, and model callbacks. Automatic renaming helps to prevent errors that result from changing names or paths manually and overlooking or mistyping one or more instances of the name.

To use automatic updates, follow these steps:

  1. Rename a model, library, or MATLAB file in a project. The project then runs a dependency analysis to look for impacts in other files.
  2. In the Rename Files dialog box, you can examine impacted files, choose to rename and update, just rename, or cancel renaming the file.
  3. If you choose automatic updates, you can examine the results in updated files.

To move or add project files, you can drag them to the project or use clipboard operations.

For more information, see Manage Project Files.

Automatic Renaming in Project

In this example, you rename a file in the project. A dependency analysis then runs and flags several files that uses the file.

Open Example Project

Open the Airframe example project using openExample('simulink/AirframeProjectExample').

Rename File and Update Dependencies

In the Project panel, in the models folder, you rename thef14_airframe.slx model file tof14.slx. The project runs a dependency analysis to look for impacts in other files. The refactoring tool lists the files that require updates and proposes automatic updates when possible. If it is possible to automatically update the file dependencies, the tool selects the corresponding check boxes.

In this example, the tool detects two files that require updates.

Rename Files dialog box flags two files that require updates and shows Rename and Update, Rename, and Cancel buttons at the bottom of the dialog box.

To update all dependencies, follow these steps:

  1. In the Rename Files dialog box, expand the rows to view the dependency details. In this example, the first dependency is due to a function call and the second is due to a model reference.
    Rename Files dialog box with the rows expanded to show the details of every dependency.
  2. To view the dependency highlighted in the MATLAB and Simulink editors, double-click the line in the Rename Files dialog box. For example, double-click the last line. Observe the model name on the highlighted block, F14 Aircraft Dynamic Model.
    The Simulink Editor shows the model file with the model reference highlighted in blue.
  3. To update the impacted files, in the Rename Files dialog box, click Rename and Update.
    The project updates the impacted files to use the new model name. When the project can automatically rename items, it reports success with a green icon. The tool reports the item that requires manual updates with a blue information icon.
    Rename Files dialog box shows an information icon to flag one item that requires manual updates. The dialog box shows a Close button at the bottom.
  4. To manually update the remaining dependencies, double-click every line listed under the information icon. The tool opens the files that require an update and highlights the dependency.
    In this example, in the f14_airframe_test.m file, you must update the arguments of the function calls on line 30 and 31 from f14_airframe tof14.
  5. In the Rename Files dialog box, clickClose.

See Also

Dependency Analyzer

Topics