Module DocumentProvider

Module DocumentProvider 

Source
Expand description

Β§DocumentProvider (Environment)

Implements the DocumentProvider trait, managing the complete lifecycle of document operations including opening, saving, editing, and closing. It maintains document state, coordinates between the frontend (Sky), extension host (Cocoon), and filesystem, and handles both native file URIs and custom scheme URIs.

Β§Implementation Strategy

The trait implementation is split across multiple helper modules for maintainability:

  • OpenDocument: Document opening and content resolution (file:// and custom schemes)
  • SaveOperations: SaveDocument, SaveDocumentAs, SaveAllDocuments
  • ApplyChanges: ApplyDocumentChanges (incremental text edits)
  • Notifications: NotifyModelAdded, NotifyModelChanged, NotifyModelSaved, NotifyModelRemoved

The single impl DocumentProvider for MountainEnvironment block in this file delegates to those helper functions. This satisfies Rust’s orphan rules while keeping code organized and atomic.

ModulesΒ§

ApplyChanges πŸ”’
Document change application logic.
Notifications πŸ”’
Notification helpers for sending document lifecycle events to Cocoon.
OpenDocument πŸ”’
Document opening and content resolution logic.
SaveOperations πŸ”’
Document save operations.