pub trait CompletionEngine: Send + Sync {
// Required methods
fn generate_completions<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
code: &'life1 str,
position: Position,
language: &'life2 str,
) -> Pin<Box<dyn Future<Output = CompletionResult<Vec<CompletionItem>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn resolve_completion<'life0, 'life1, 'async_trait>(
&'life0 self,
item: &'life1 CompletionItem,
) -> Pin<Box<dyn Future<Output = CompletionResult<CompletionItem>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Main completion engine trait
Implementations of this trait orchestrate the completion process by coordinating context analysis, completion generation, and ranking.
§Async Behavior
All methods are async to support non-blocking I/O and streaming responses. Implementations should handle cancellation gracefully.
Required Methods§
Sourcefn generate_completions<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
code: &'life1 str,
position: Position,
language: &'life2 str,
) -> Pin<Box<dyn Future<Output = CompletionResult<Vec<CompletionItem>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn generate_completions<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
code: &'life1 str,
position: Position,
language: &'life2 str,
) -> 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 completion suggestions for the given code at the specified position
§Arguments
code- The source code to analyzeposition- The cursor position where completions are requestedlanguage- The programming language identifier (e.g., “rust”, “typescript”, “python”)
§Returns
A vector of completion items ranked by relevance, or an error if generation fails.
§Errors
Returns CompletionError if:
- Context analysis fails
- Completion generation fails
- Ranking fails
- The language is not supported
Sourcefn resolve_completion<'life0, 'life1, 'async_trait>(
&'life0 self,
item: &'life1 CompletionItem,
) -> Pin<Box<dyn Future<Output = CompletionResult<CompletionItem>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn resolve_completion<'life0, 'life1, 'async_trait>(
&'life0 self,
item: &'life1 CompletionItem,
) -> Pin<Box<dyn Future<Output = CompletionResult<CompletionItem>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Resolve additional details for a completion item
This method is called when the user selects a completion item to resolve additional details like documentation, type information, or additional edits.
§Arguments
item- The completion item to resolve
§Returns
The resolved completion item with additional details, or an error if resolution fails.