oo_ide/schema/context.rs
1//! Format-agnostic cursor context types for schema-driven completion.
2
3/// Describes where the cursor is within a structured document.
4#[derive(Debug, Clone, PartialEq, Eq)]
5pub struct CursorContext {
6 /// Table/section path from root to the cursor's containing table.
7 ///
8 /// For example, a cursor inside `[package]` yields `["package"]`.
9 /// A cursor inside a top-level `[dependencies]` yields `["dependencies"]`.
10 /// An empty vec means the cursor is at the root level.
11 pub section_path: Vec<String>,
12
13 /// What kind of completion is expected at the cursor.
14 pub mode: CompletionMode,
15}
16
17/// The type of completion needed at the cursor position.
18#[derive(Debug, Clone, PartialEq, Eq)]
19pub enum CompletionMode {
20 /// Completing a **key name** at the current table level.
21 ///
22 /// Example: cursor is at start of line inside `[package]` → suggest
23 /// `name`, `version`, `edition`, etc.
24 Key,
25
26 /// Completing the **value** for a known key.
27 ///
28 /// Example: cursor is after `publish = ` → suggest `true` / `false`.
29 Value { key: String },
30
31 /// Completing a **key name inside an inline table** (or flow mapping).
32 ///
33 /// Example: cursor is inside `serde = { ` → suggest `version`,
34 /// `features`, `optional`, etc.
35 InlineKey,
36}