[][src]Function ra_ap_completion::completions

pub fn completions(
    db: &RootDatabase,
    config: &CompletionConfig,
    position: FilePosition
) -> Option<Completions>

Main entry point for completion. We run completion as a two-phase process.

First, we look at the position and collect a so-called `CompletionContext. This is a somewhat messy process, because, during completion, syntax tree is incomplete and can look really weird.

Once the context is collected, we run a series of completion routines which look at the context and produce completion items. One subtlety about this phase is that completion engine should not filter by the substring which is already present, it should give all possible variants for the identifier at the caret. In other words, for

fn f() {
    let foo = 92;
    let _ = bar<|>
}

foo should be present among the completion variants. Filtering by identifier prefix/fuzzy match should be done higher in the stack, together with ordering of completions (currently this is done by the client).