Skip to content

Commit 301711e

Browse files
committed
internal: Remove ide_completion::render::build_ext module
1 parent d65f9a2 commit 301711e

File tree

5 files changed

+166
-170
lines changed

5 files changed

+166
-170
lines changed

crates/hir/src/lib.rs

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,7 @@ impl Function {
13251325
/// Get this function's return type
13261326
pub fn ret_type(self, db: &dyn HirDatabase) -> Type {
13271327
let resolver = self.id.resolver(db.upcast());
1328-
let krate = self.id.lookup(db.upcast()).container.module(db.upcast()).krate();
1328+
let krate = self.krate_id(db);
13291329
let ret_type = &db.function_data(self.id).ret_type;
13301330
let ctx = hir_ty::TyLoweringContext::new(db, &resolver);
13311331
let ty = ctx.lower_ty(ret_type);
@@ -1341,7 +1341,7 @@ impl Function {
13411341

13421342
pub fn assoc_fn_params(self, db: &dyn HirDatabase) -> Vec<Param> {
13431343
let resolver = self.id.resolver(db.upcast());
1344-
let krate = self.id.lookup(db.upcast()).container.module(db.upcast()).krate();
1344+
let krate = self.krate_id(db);
13451345
let ctx = hir_ty::TyLoweringContext::new(db, &resolver);
13461346
let environment = db.trait_environment(self.id.into());
13471347
db.function_data(self.id)
@@ -1359,9 +1359,25 @@ impl Function {
13591359
if self.self_param(db).is_none() {
13601360
return None;
13611361
}
1362-
let mut res = self.assoc_fn_params(db);
1363-
res.remove(0);
1364-
Some(res)
1362+
Some(self.params_without_self(db))
1363+
}
1364+
1365+
pub fn params_without_self(self, db: &dyn HirDatabase) -> Vec<Param> {
1366+
let resolver = self.id.resolver(db.upcast());
1367+
let krate = self.krate_id(db);
1368+
let ctx = hir_ty::TyLoweringContext::new(db, &resolver);
1369+
let environment = db.trait_environment(self.id.into());
1370+
let skip = if db.function_data(self.id).has_self_param() { 1 } else { 0 };
1371+
db.function_data(self.id)
1372+
.params
1373+
.iter()
1374+
.enumerate()
1375+
.skip(skip)
1376+
.map(|(idx, (_, type_ref))| {
1377+
let ty = Type { krate, env: environment.clone(), ty: ctx.lower_ty(type_ref) };
1378+
Param { func: self, ty, idx }
1379+
})
1380+
.collect()
13651381
}
13661382

13671383
pub fn is_unsafe(self, db: &dyn HirDatabase) -> bool {
@@ -1410,6 +1426,10 @@ impl Function {
14101426

14111427
result
14121428
}
1429+
1430+
fn krate_id(self, db: &dyn HirDatabase) -> CrateId {
1431+
self.id.lookup(db.upcast()).module(db.upcast()).krate()
1432+
}
14131433
}
14141434

14151435
// Note: logically, this belongs to `hir_ty`, but we are not using it there yet.

crates/ide_completion/src/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub(super) enum PathKind {
5959
#[derive(Debug)]
6060
pub(crate) struct PathCompletionCtx {
6161
/// If this is a call with () already there
62-
has_call_parens: bool,
62+
pub(super) has_call_parens: bool,
6363
/// Whether this path stars with a `::`.
6464
pub(super) is_absolute_path: bool,
6565
/// The qualifier of the current path if it exists.

crates/ide_completion/src/render.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ pub(crate) mod type_alias;
1010
pub(crate) mod struct_literal;
1111
pub(crate) mod compound;
1212

13-
mod builder_ext;
14-
1513
use hir::{AsAssocItem, HasAttrs, HirDisplay, ScopeDef};
1614
use ide_db::{helpers::item_name, RootDatabase, SnippetCap, SymbolKind};
1715
use syntax::{SmolStr, SyntaxKind, TextRange};

crates/ide_completion/src/render/builder_ext.rs

Lines changed: 0 additions & 129 deletions
This file was deleted.

0 commit comments

Comments
 (0)