A Visual Studio Code extension that performs lightweight static analysis for Miranda programs.
Miranda Dependency Inspector helps developers understand the structure of their code by identifying dependencies between functions, detecting recursive functions, and highlighting functions that appear to be unused.
Features
Function Dependency Analysis
Detects user-defined functions and identifies which functions call other functions.
Example:
main = procesar [1,2,3]
procesar xs = sumar xs
sumar [] = 0
sumar (x:xs) = x + sumar xs
Detected dependencies:
main
└─ procesar
procesar
└─ sumar
Recursive Function Detection
Identifies simple recursive functions.
Example:
sumar [] = 0
sumar (x:xs) = x + sumar xs
Result:
↺ sumar (recursive)
Unused Function Detection
Highlights functions that are defined but never called by other functions.
Example:
duplicar x = x * 2
Result:
⚠ duplicar (unused)
Sidebar View
Displays analysis results in a dedicated VS Code sidebar.
The sidebar provides a quick overview of:
- Function dependencies
- Recursive functions
- Unused functions
Usage
- Open a Miranda source file.
- Open the Miranda view from the Activity Bar.
- Run the command:
Refresh Miranda Dependency Analysis
- Review the generated dependency tree.
Example
Input:
main = procesar [1,2,3]
procesar xs = sumar xs
sumar [] = 0
sumar (x:xs) = x + sumar xs
duplicar x = x * 2
Output:
main
└─ procesar
procesar
└─ sumar
↺ sumar (recursive)
⚠ duplicar (unused)
Installation
From Marketplace
Search for:
Miranda Dependency Inspector
and click Install.
From VSIX
code --install-extension miranda-dependency-inspector-x.x.x.vsix
Project Structure
src/
├─ extension.ts
├─ mirandaParser.ts
├─ dependencyAnalyzer.ts
└─ DependencyTreeProvider.ts
Main Components
mirandaParser.ts
Responsible for extracting Miranda function definitions.
dependencyAnalyzer.ts
Responsible for:
- Dependency detection
- Recursive function detection
- Unused function detection
DependencyTreeProvider.ts
Responsible for rendering the VS Code sidebar tree.
extension.ts
Registers commands and activates the extension.
Limitations
This extension uses lightweight static analysis.
Current limitations:
- Does not implement a full Miranda parser.
- Does not perform type checking.
- Does not analyze multiple files.
- Does not implement Language Server Protocol (LSP).
Future Improvements
Possible future enhancements:
- Cross-file dependency analysis
- Dependency graph visualization
- Diagnostics inside the editor
- Code actions and quick fixes
- Miranda language support improvements
Contributing
See CONTRIBUTING.md for contribution guidelines.
License
MIT License