Visual Studio Code Extension Create a graph of the include dependencies in a C-based project
Overview
The CPP-Link-Graph extension for Visual Studio Code analyzes your C++ project's header file dependencies and generates a visual graph to help you understand the relationships between your files.
This tool is particularly useful for identifying unnecessary dependencies and optimizing your project's structure.
Features
C++ Header Analysis: Utilizes a native C++ parser to analyze .cpp and .hpp files.
Graph Generation: Outputs a Mermaid-compatible graph representing file dependencies.
Customizable Output: Supports SVG and PNG formats for the generated graph.
Automatic Opening: Optionally opens the generated graph in VS Code upon completion.
Workspace Integration: Operates within the context of your VS Code workspace.
Installation
Open Visual Studio Code.
Press Ctrl+P (or Cmd+P on macOS) to open the Quick Open dialog.
Paste the following command and press Enter: ext install Kaiwinta.cpp-link-graph
Alternatively, search for CPP-Link-Graph in the Extensions view (Ctrl+Shift+X or Cmd+Shift+X) and click Install.
Usage
Open your C++ project in VS Code.
Press Ctrl+Shift+P (or Cmd+Shift+P on macOS) to open the Command Palette.
Type Cpp Link Graph: Run Parser and select it.
Choose the desired analysis option:
Analyze C++ Includes (hpp only): Generates the dependency graph for .hpp files only.
Analyze C++ Includes: Generates the dependency graph for both .cpp and .hpp files.
Cancel: Aborts the operation.
The extension will analyze your project's header files and generate a dependency graph.
The graph will be saved in the cpp-link-graph folder within your workspace.
If configured, the graph will automatically open in VS Code.
Configuration
You can customize the extension's behavior through the VS Code settings:
cpp-link-graph.outputFormat: Set the default output format for generated graphs. Options: svg, png. Default: png.
cpp-link-graph.scale: Adjust the scale factor for Mermaid diagrams. Default: 20.
cpp-link-graph.autoOpen: Automatically open the generated graph after creation. Default: true.
To modify these settings, go to File > Preferences > Settings and search for cpp-link-graph.
License
This extension is licensed under the MIT License. See the LICENSE