Repository: astral-sh/ruff
File: crates/ty_ide/src/completion.rs (Rust)

Code before:
                    (model.attribute_completions(expr), None)
                }
                CompletionTargetAst::Scoped(scoped) => {
                    (model.scoped_completions(scoped.node), Some(scoped))
                }
            };

            completions.extend(semantic_completions);
            if scoped.is_some() {
                add_keyword_completions(db, &mut completions);
            }
            if settings.auto_import {
                if let Some(scoped) = scoped {
                    add_unimported_completions(
                        db,
                        file,
                        &parsed,
                        scoped,
                        |module_name: &ModuleName, symbol: &str| {
                            ImportRequest::import_from(module_name.as_str(), symbol)
                        },
                        &mut completions,
                    );
                }
            }
            add_argument_completions(db, file, &model, &context.cursor, &mut completions);
        }
    }

    completions.into_completions()
}

/// A collection of completions built up from various sources.
struct Completions<'db> {
    db: &'db dyn Db,
    context: CollectionContext<'db>,
    items: Vec<Completion<'db>>,
    query: QueryPattern,
}

impl<'db> Completions<'db> {
    /// Create a new empty collection of completions.
    ///
    /// The given typed text should correspond to what we believe
    /// the user has typed as part of the next symbol they are writing.
    /// This collection will treat it as a query when present, and only
    /// add completions that match it.
    fn new(
        db: &'db dyn Db,
        context: CollectionContext<'db>,
        query: QueryPattern,

Review comment (suggestion):
I don't think it really makes sense here to pass `db`, `file` and `model` because `model` is just a thin wrapper around `db` + `file`. If we need model, then I suggest removing `db` and `file`.

Code after:
                CompletionTargetAst::ObjectDot { expr } => {
                    (model.attribute_completions(expr), None)
                }
                CompletionTargetAst::Scoped(scoped) => {
                    (model.scoped_completions(scoped.node), Some(scoped))
                }
            };

            completions.extend(semantic_completions);
            if scoped.is_some() {
                add_keyword_completions(db, &mut completions);
                add_argument_completions(db, &model, &context.cursor, &mut completions);
            }
            if settings.auto_import {
                if let Some(scoped) = scoped {
                    add_unimported_completions(
                        db,
                        file,
                        &parsed,
                        scoped,
                        |module_name: &ModuleName, symbol: &str| {
                            ImportRequest::import_from(module_name.as_str(), symbol)
                        },
                        &mut completions,
                    );
                }
            }
        }
    }

    completions.into_completions()
}

/// A collection of completions built up from various sources.
struct Completions<'db> {
    db: &'db dyn Db,
    context: CollectionContext<'db>,
    items: Vec<Completion<'db>>,
    query: QueryPattern,
}

impl<'db> Completions<'db> {
    /// Create a new empty collection of completions.
    ///
    /// The given typed text should correspond to what we believe
    /// the user has typed as part of the next symbol they are writing.
    /// This collection will treat it as a query when present, and only
    /// add completions that match it.
    fn new(
        db: &'db dyn Db,
        context: CollectionContext<'db>,