1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//! Completion system for mongosh REPL
//!
//! This module provides an intelligent completion system that works with both
//! MongoDB shell syntax and SQL syntax. The system is built on a finite state
//! machine (FSM) approach that is error-tolerant and works with incomplete input.
//!
//! # Architecture
//!
//! The completion system consists of several components:
//!
//! - **TokenStream**: Wraps SQL and Mongo tokens with cursor awareness
//! - **FSM**: Determines the completion context based on token sequence
//! - **Context**: Standardized representation of what to complete
//! - **Provider**: Fetches completion candidates (collections, operations, etc.)
//! - **Engine**: Orchestrates the entire completion flow
//!
//! # Examples
//!
//! ```no_run
//! use mongosh::repl::completion::{CompletionEngine, MongoCandidateProvider};
//! use mongosh::repl::SharedState;
//! use std::sync::Arc;
//!
//! let shared_state = SharedState::new("test".to_string());
//! let provider = Arc::new(MongoCandidateProvider::new(shared_state, None));
//! let engine = CompletionEngine::new(provider);
//!
//! // Complete "db.us" with cursor at position 5
//! let (start, candidates) = engine.complete("db.us", 5);
//! // Returns collection names starting with "us"
//! ```
pub use CompletionEngine;
pub use MongoCandidateProvider;