detect_completion_context

Function detect_completion_context 

Source
pub fn detect_completion_context(
    parse_result: &dyn ParseResult,
    position: Position,
    content: &str,
) -> CompletionContext
Expand description

Detects the completion context based on cursor position.

This function analyzes the cursor position relative to parsed dependencies to determine what type of completion should be offered.

§Arguments

  • parse_result - Parsed manifest with dependency information
  • position - Cursor position in the document (LSP Position, 0-based line, 0-based character)
  • content - Full document content for prefix extraction

§Returns

A CompletionContext indicating what type of completion is appropriate, or CompletionContext::None if the cursor is not in a valid position.

§Examples

use deps_core::completion::detect_completion_context;
use tower_lsp_server::ls_types::Position;

// Cursor at position after "ser" in "serde"
let position = Position { line: 5, character: 3 };
let context = detect_completion_context(parse_result, position, content);