Expand description
§Environment Module
§RESPONSIBILITIES
Dependency Injection (DI) container that provides thread-safe access to all Mountain providers through trait-based lookups using the Requires trait.
§ARCHITECTURAL ROLE
The Environment module is the central dependency injection system for Mountain:
Component ──► Requires<T> ──► MountainEnvironment ──► Arc<dyn T>§Position in Mountain
- Implements Common crate’s
EnvironmentandRequirestraits - All providers accessed through capability-based lookups
- Created early in startup and shared via
Arc<MountainEnvironment>
§Key Components
MountainEnvironment: Main DI container structProviderTraitImplMacro: Macro for generating trait implementations- Provider modules: Individual implementations for each provider trait
§Provider Traits Implemented (25+)
- CommandExecutor, ConfigurationProvider, CustomEditorProvider
- DebugService, DiagnosticManager, DocumentProvider
- FileSystemReader/Writer, IPCProvider, KeybindingProvider
- LanguageFeatureProviderRegistry, OutputChannelManager
- SecretProvider, SourceControlManagementProvider
- StatusBarProvider, StorageProvider, SynchronizationProvider
- TerminalProvider, TestController, TreeViewProvider
- UserInterfaceProvider, WebviewProvider
- WorkspaceProvider, WorkspaceEditApplier
- ExtensionManagementService, SearchProvider
§ERROR HANDLING
Providers use CommonError for error reporting. The DI container handles trait resolution at compile time, ensuring type safety.
§PERFORMANCE CONSIDERATIONS
- Thread-safe access via
Arc<T> - Lazy initialization through trait-based lookups
- Zero-cost abstractions - macro-generated code is identical to hand-written
§TODO
- Consider async initialization for providers
- Add provider health checking
- Implement provider dependency validation on initialization
Modules§
- Command
Provider - CommandProvider (Environment)
- Configuration
Provider - ConfigurationProvider (Environment)
- Custom
Editor Provider - CustomEditorProvider (Environment)
- Debug
Provider - DebugProvider (Environment)
- Diagnostic
Provider - DiagnosticProvider (Environment)
- Document
Provider - DocumentProvider (Environment)
- File
System Provider - FileSystemProvider (Environment)
- IPCProvider
- IPCProvider (Environment)
- Keybinding
Provider - KeybindingProvider (Environment)
- Language
Feature Provider - LanguageFeatureProvider (Environment)
- Mountain
Environment - Main DI container struct.
- Output
Provider - OutputProvider (Environment)
- Provider
Trait Impl Macro - Macro for generating trait implementations.
- Search
Provider - SearchProvider (Environment)
- Secret
Provider - SecretProvider (Environment)
- Source
Control Management Provider - SourceControlManagementProvider (Environment)
- Status
BarProvider - StatusBarProvider (Environment)
- Storage
Provider - StorageProvider (Environment)
- Synchronization
Provider - SynchronizationProvider (Environment)
- Terminal
Provider - File: Mountain/Source/Environment/TerminalProvider.rs
Role: Implements the
TerminalProvidertrait for theMountainEnvironment. Responsibilities: - Test
Provider - TestProvider (Environment)
- Tree
View Provider - TreeViewProvider (Environment)
- User
Interface - UserInterface Service
- User
Interface Provider - UserInterfaceProvider (Environment)
- Utility
- Environment Utilities
- Webview
Provider - WebviewProvider (Environment)
- Workspace
Provider - WorkspaceProvider (Environment)