CompletionRanker

Trait CompletionRanker 

Source
pub trait CompletionRanker: Send + Sync {
    // Required methods
    fn rank_completions(
        &self,
        items: Vec<CompletionItem>,
        context: &CompletionContext,
    ) -> Vec<CompletionItem>;
    fn score_relevance(
        &self,
        item: &CompletionItem,
        context: &CompletionContext,
    ) -> f32;
    fn score_frequency(&self, item: &CompletionItem) -> f32;
}
Expand description

Completion ranker trait

Implementations rank completion suggestions by relevance, frequency, and recency. The ranker is responsible for sorting completions so the most relevant appear first.

§Scoring

Rankers typically combine multiple scoring factors:

  • Relevance: How well the completion matches the context
  • Frequency: How often the completion is used
  • Recency: How recently the completion was used

§Implementations

  • BasicCompletionRanker: Prefix matching and fuzzy matching
  • AdvancedCompletionRanker: Advanced scoring with frequency and recency

Required Methods§

Source

fn rank_completions( &self, items: Vec<CompletionItem>, context: &CompletionContext, ) -> Vec<CompletionItem>

Rank completions by relevance and frequency

§Arguments
  • items - Unranked completion items
  • context - The analyzed code context
§Returns

The same completion items, sorted by relevance (highest first).

Source

fn score_relevance( &self, item: &CompletionItem, context: &CompletionContext, ) -> f32

Score relevance of a completion item

§Arguments
  • item - The completion item to score
  • context - The analyzed code context
§Returns

A relevance score (typically 0.0 to 1.0, where 1.0 is most relevant).

Source

fn score_frequency(&self, item: &CompletionItem) -> f32

Score frequency of a completion item

§Arguments
  • item - The completion item to score
§Returns

A frequency score (typically 0.0 to 1.0, where 1.0 is most frequently used).

Implementors§