Analyze Project Dependencies - MATLAB & Simulink (original) (raw)

Use the Dependency Analyzer to perform a dependency analysis on your project. You can run a dependency analysis at any point in your workflow. In a collaborative environment, you typically check dependencies:

To explore a project and visualize its structure using different views, see Explore the Dependency Graph, Views, and Filters.

To find and fix problems in your project, see Investigate and Resolve Problems.

To assess how a change will affect other project files, see Find File Dependencies.

To find add-ons and products required by your project to run properly, see Find Required Products and Add-Ons.

Run a Dependency Analysis

Before running a dependency analysis on a project, make sure that you have added all your files to the project. For more information, see Add Files to Project.

To start analyzing your project, on the Project tab, in the Tools gallery, click Dependency Analyzer. Alternatively, in the projectViews pane, select Dependency Analyzer and click Analyze.

To analyze the dependencies of specific files, in the dependency graph, select the files. In the Impact Analysis section, click All Dependencies or use the context menu and select Find All Dependencies.

To analyze the dependencies inside add-ons, select > . For more details about available options, see Analysis Scope (Simulink).

You can also check dependencies directly in Project. In the Project Files view, right-click the project files you want to analyze and select .

Default view of the Dependency Analyzer. The toolstrip is at the top. The Legend and Overview panels are on the left. The dependency graph is in the middle, and the Properties panel is on the right.

The dependency graph shows:

You can examine project dependencies and problem files using the File List. In the toolstrip, click .

After you run the first dependency analysis of your project, subsequent analyses incrementally update the results. The Dependency Analyzer determines which files changed since the last analysis and updates the dependency data for those files. However, if you update add-ons or installed products and want to discover dependency changes in them, you must perform a complete analysis. To perform a complete analysis, in the Dependency Analyzer, click > .

For more information about running a dependency analysis on Simulink® models and libraries, see Perform an Impact Analysis (Simulink).

Explore the Dependency Graph, Views, and Filters

The dependency graph displays your project structure, dependencies, and how files relate to each other. Each item in the graph represents a file and each arrow represents a dependency. For more details, see Investigate Dependency Between Two Files.

By default, the dependency graph shows all files required by your project. To help you investigate dependencies or a specific problem, you can simplify the graph using one of the following filters:

Select, Pan, and Zoom

Investigate Dependency Between Two Files

To see more information about how two files are related, select their dependency arrow. In the Properties pane, in theDetails section, you can see the full paths of the files you are examining, the dependency type (such as function call, inheritance, and property type), and where the dependency is introduced.

Click the dependency arrow between two files in the dependency graph. Examine the Details section in the Properties panel on the right.

To open the file and highlight where the dependency is introduced, in theDetails section, click the link underImpacted.

Click the dependency arrow between two files in the dependency graph. In the Properties panel on the right, click the link listed in the Impacted column of the table.

Color Files by Type, Status, or Label

Explore the different views in the Views section of the Dependency Analyzer toolstrip to explore your project files dependencies.

Apply and Clear Filters

In large projects, when investigating problems or dependencies, use the different filters to show only the files you want to investigate:

Investigate and Resolve Problems

When you run a dependency analysis, the Dependency Analyzer identifies problems, such as missing files, files not in the project, unsaved changes, and out-of-date derived files. You can examine problem files using the dependency graph or the file list. When no file is selected, the Properties pane on the right shows the add-ons dependencies and a list of problems for the entire project.

In the Properties panel on the right, in the Problems section, click the magnifying glass. The dependency graph displays a node highlighted in bright yellow. The node also displays a warning sign.

Use the graph to investigate problem files graphically.

  1. In the Properties pane, in theProblems section, point to a problem, such as_File not in project_, and click the magnifying glass icon . The graph highlights the files with this specific problem.
    To go through these files, use the arrows in the search box (e.g.,Problem: File not in project).

    To undo the highlighting, close the search box.
  2. To see more information about a specific problem file, select the file in the graph. In the Properties pane, in theProblems section, you can see details including the path, type, and the problems for this file.
    For example, if a file is File not in project, right-click the problem file in the graph and select .
  3. Investigate the next problem listed in theProblems section. Repeat the steps until you resolve all problems. For more details on how to fix problems, see Resolve Problems.
    To update the graph and the Problems list, clickAnalyze.

Tip

For large projects, viewing the results in a list can make navigation easier.

For large projects, use theFile List to investigate your project problem files.

  1. In the Dependency Analyzer toolstrip, click File List.
  2. In the Properties pane, in theProblems section, point to a problem, such as_File not in project_, and click the magnifying glass icon .
    The File List shows only files with the specific problem. Select all the files in the list and use the context menu to .
  3. Investigate the next problem listed in theProblems section, for example_Missing file_. Repeat the steps until you resolve all problems.
    To update the graph and the Problems list, clickAnalyze.

Resolve Problems

For each problem file, take actions to resolve the problem. This table lists common problems and describes how to fix them. To resolve Simulink-specific problems, see Investigate and Resolve Problems.

Problem Message Description Fix
File not in project The file is not in the project. Right-click the problem file in the graph and select .To remove a file from the problem list without adding it to the project, right-click the file and select .
Missing file The file is in the project but does not exist on disk. Create the file or recover it using source control.
The file or variable cannot be found. If this status is acceptable, right-click the file and select .Depending on the way you call an object method, the Dependency Analyzer might confuse a method with a function and report a missing dependency. See Analysis Limitations (Simulink).
In unreferenced project The file is within a project that is not referenced by the current project. Add the project containing the file as a project reference.
Outside project root The file is outside the project root folder. If this status is acceptable, right-click the file and select . Otherwise, move it under the project root.If required files are outside your project root, you cannot add these files to your project. This dependency might not indicate a problem if the file is on your path and is a utility or resource that is not part of your project. Use dependency analysis to ensure that you understand the design dependencies.
Unsaved changes The file has unsaved changes in the MATLAB and Simulink editors. Save the file.
Derived file out of date The derived file is older than the source file it was derived from. Regenerate the derived file. If it is a.p file, you can regenerate it automatically by running the project checks. In MATLAB, on the Project tab, click the down arrow to expand theTools gallery. UnderProject Checks, clickCheck Project.If you rename a source file, the project detects the impact to the derived file and prompts you to update it.
File with syntax error The file contains a syntax error or the Dependency Analyzer cannot parse the file. For example, the file is an.m file that contains a syntax error. The Dependency Analyzer warns and does not analyze the file. If this status is acceptable, right-click the file and select . Otherwise, fix the syntax error and save the file.
Product not installed The project or folder has a dependency on a missing product. Install the missing product.NoteIf you use parfor orspmd but do not have the Parallel Computing Toolbox™ installed, the corresponding code runs sequentially. The Dependency Analyzer reports a problem in the Problems section.
Missing package dependency The project does not declare a dependency on a required package. Declare a dependency on the required package. For more information, see addDependency.
Circular dependency on_ProjectName_ The project hierarchy contains a circular dependency. Break the circular dependency. For example, if the reference to ProjectName is not needed, remove ProjectName from the list of the top-level project references.If the reference to_ProjectName_ is needed, refactor your project hierarchy to eliminate the circular dependency.This warning is specific to theProject Hierarchy view and is available only in MATLAB Online.

Find Required Products and Add-Ons

After running a dependency analysis on a project, the graph shows the required products and add-ons for the whole project or for selected files. You can see which products are required to use the project or find which file is introducing a product dependency.

In the Dependency Analyzer, in the Properties pane, the Products andAdd-Ons sections display the required products and add-ons and packages for the whole project. To view products or add-ons required by a specific file, select a file by clicking the graph.

To find which file is introducing a product dependency, point to the product or add-on name and click the magnifying glass icon . The graph highlights the files that use the selected product.

Product section of the Properties panel on the right. Point and click the magnifying glass next to the product name to highlight files that use a product.

To go through these files, use the arrows in the search box (e.g., Files using "productName").

Advanced search for the dependency graph. From left to right, the search displays the type of search, up and down arrows for navigation, table view button and x button to close the search.

To undo the highlighting, close the search box.

To investigate further, you can list the files that use a product and examine where in these files the dependency is introduced. In theProducts and Add-Ons sections, point to product or add-on name and click the search folder icon.

If a required product is missing, the products list labels it as missing. The product is also listed in theProblems section as**_productName_ not installed**. To resolve a missing product, install the product and rerun the dependency analysis.

Find File Dependencies

To investigate the dependencies of a file after running a dependency analysis, in the dependency graph, select a file.

Finding these dependencies can help you identify the impact of a change and identify the tests you need to run to validate your design before committing the changes.

To investigate the dependencies of multiple files, click files while holding theShift key. The Impact Analysis section displays how many files are selected.

Impact Analysis section of the Dependency Analyzer toolstrip. The section name shows the number of selected files in the graph.

To reset the graph, click the filter at the top of the graph. For example, if you had filtered by files impacted by timestable.mlapp, click.

Investigate Impact of Modified Files

To examine the impact of the changes you made on the rest of the project files, perform an impact analysis on the modified files in your project.

  1. In the Views section, select theSource Control view. The graph colors the files by their source control status. The modified files are in light blue.
  2. Select all the modified files in the graph.
    Alternatively, add all modified files to selection by clicking theAdd to selection icon of an item in theLegend pane.
    Tip
    If you changed a large number of files, you can also use the file list.
    In the Dependency Analyzer toolstrip, click File List. Point to Status and click the arrow to sort the list by the source control status. Select all the modified files.
    Dependency table view that lists from left to right the filenames, the legend colors and text, and the file paths.
  3. In the Impact Analysis section, clickImpacted. Alternatively, use the context menu and select Find Impacted.

Identify Tests to Run

To identify the tests you need to run to validate your design before committing the changes, use the Classification view when you perform an impact analysis on the file you changed.

Dependency graph with Classification and Impacted filters applied. On the left, the Legend panel displays the number of tests in the dependency graph.

  1. In the Views section, select theClassification view. The graph colors the files by their project label.
  2. Select the file you changed, for exampletimesTableGame.m.
  3. In the Impact Analysis section, clickImpacted. Alternatively, use the context menu and select Find Impacted.
    The example graph shows three tests you need to run to qualify the change made to timesTableGame.m.

Export Dependency Analysis Results

To export all the files displayed in the dependency graph, click the graph background to clear the selection on all files. In the Dependency Analyzer toolstrip, in the Export section, clickExport. Select from the available options:

To export a subset of files in the graph, select the files, then clickExport.

The menu displays how many files are selected. The Dependency Analyzer exports only the selected files.

Export menu options. Examine the title of the section to determine the number of selected files.

Note

When you use , the Dependency Analyzer includes the selected files and all their dependencies in the archive.

Send Files to Project Tools

You can send files to other Project tools using theProject menu. The Dependency Analyzer exports only the selected files in the current filtered view.

Select the desired files. In the Dependency Analyzer toolstrip, in theExport section, click Project. Select from the available options: