CompletionProvider

Trait CompletionProvider 

Source
pub trait CompletionProvider: Send + Sync {
    // Required methods
    fn language(&self) -> &str;
    fn generate_completions<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        code: &'life1 str,
        position: Position,
        context: &'life2 CompletionContext,
    ) -> Pin<Box<dyn Future<Output = CompletionResult<Vec<CompletionItem>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

Pluggable completion provider for language-specific behavior

Implementations provide language-specific completion suggestions. Providers are registered in the ProviderRegistry and selected based on the language identifier.

§Language Support

Each provider supports a single language. The engine queries the registry to find the appropriate provider for the current language.

§Implementations

  • RustCompletionProvider: Rust-specific completions
  • TypeScriptCompletionProvider: TypeScript-specific completions
  • PythonCompletionProvider: Python-specific completions
  • GenericTextProvider: Generic text-based completions

§Example

use ricecoder_completion::providers::RustCompletionProvider;
use ricecoder_completion::engine::CompletionProvider;

let provider = RustCompletionProvider;
assert_eq!(provider.language(), "rust");

Required Methods§

Source

fn language(&self) -> &str

Get the language this provider supports

§Returns

A language identifier string (e.g., “rust”, “typescript”, “python”).

Source

fn generate_completions<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, code: &'life1 str, position: Position, context: &'life2 CompletionContext, ) -> Pin<Box<dyn Future<Output = CompletionResult<Vec<CompletionItem>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Generate completions for this language

§Arguments
  • code - The source code to analyze
  • position - The cursor position where completions are requested
  • context - The analyzed code context
§Returns

A vector of language-specific completion items (not yet ranked), or an error if generation fails.

Implementors§