Module Environment

Module Environment 

Source
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 Environment and Requires traits
  • All providers accessed through capability-based lookups
  • Created early in startup and shared via Arc<MountainEnvironment>

§Key Components

  • MountainEnvironment: Main DI container struct
  • ProviderTraitImplMacro: 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§

CommandProvider
CommandProvider (Environment)
ConfigurationProvider
ConfigurationProvider (Environment)
CustomEditorProvider
CustomEditorProvider (Environment)
DebugProvider
DebugProvider (Environment)
DiagnosticProvider
DiagnosticProvider (Environment)
DocumentProvider
DocumentProvider (Environment)
FileSystemProvider
FileSystemProvider (Environment)
IPCProvider
IPCProvider (Environment)
KeybindingProvider
KeybindingProvider (Environment)
LanguageFeatureProvider
LanguageFeatureProvider (Environment)
MountainEnvironment
Main DI container struct.
OutputProvider
OutputProvider (Environment)
ProviderTraitImplMacro
Macro for generating trait implementations.
SearchProvider
SearchProvider (Environment)
SecretProvider
SecretProvider (Environment)
SourceControlManagementProvider
SourceControlManagementProvider (Environment)
StatusBarProvider
StatusBarProvider (Environment)
StorageProvider
StorageProvider (Environment)
SynchronizationProvider
SynchronizationProvider (Environment)
TerminalProvider
File: Mountain/Source/Environment/TerminalProvider.rs Role: Implements the TerminalProvider trait for the MountainEnvironment. Responsibilities:
TestProvider
TestProvider (Environment)
TreeViewProvider
TreeViewProvider (Environment)
UserInterface
UserInterface Service
UserInterfaceProvider
UserInterfaceProvider (Environment)
Utility
Environment Utilities
WebviewProvider
WebviewProvider (Environment)
WorkspaceProvider
WorkspaceProvider (Environment)