How microsoft/vscode-mock-debug works
Main Components
• VS Code Extension Framework: The core of the project is a VS Code extension (files like extension.ts, web-extension.ts) that integrates the debug adapter.
• Debug Adapter Subsystem: This includes the core files (debugAdapter.ts, mockDebug.ts, mockRuntime.ts, activateMockDebug.ts) that simulate debugger behavior (stepping, breakpoints, exceptions, variable access).
• Testing and Sample Workspace: The project includes a test suite (under src/tests) and a sampleWorkspace directory, which provides a sample environment in VS Code.
• Configuration and Build Infrastructure: There are build scripts (in the build folder) and CI/CD workflows (.github/workflows/ci.yml), along with TypeScript configuration (tsconfig.json) that indicate the build and deployment aspects.
Relationships and Data Flow
• The extension entry point (extension.ts) registers the debug adapter with VS Code.
• When a user initiates a debug session in VS Code, the extension interacts with the debug adapter (debugAdapter.ts and associated modules) which then simulates debugging functionalities such as stepping and handling exceptions.
• The mock runtime (mockRuntime.ts) and supporting modules (mockDebug.ts, activateMockDebug.ts) provide the actual logic for simulating these debugging actions.
• Testing modules under src/tests validate the behavior of the debug adapter and runtime, ensuring reliability.
• The sampleWorkspace demonstrates the extension's usage in a live VS Code environment.
• Build and CI configurations ensure every update to these components is properly built, tested, and deployed.
Architectural Patterns and Design Principles
• Separation of Concerns: The project is modularized into clear layers—extension activation, debug adapter logic, runtime simulation, and testing.
• Integration with External Systems: It leverages the VS Code Debug Adapter Protocol and VS Code Extension API to interact seamlessly with the host IDE.
• CI/CD and Automated Build: The existence of GitHub workflows and build scripts emphasizes automated testing and deployment processes.
Important Technologies, Frameworks, and Libraries
• Visual Studio Code API / Debug Adapter Protocol for integration with VS Code.
• TypeScript as the language for implementing the extension.
• Standard project configuration files (package.json, tsconfig.json) for dependency management and build configuration.
• GitHub Actions for CI/CD as seen in the .github/workflows directory.
Conclusion
• Offer a high-level view as well as a zoomed-in look into the core debug adapter logic (from extension activation through runtime simulation).