Skip to content

Commit f4e64bd

Browse files
committed
naming is hard
1 parent 157fd5d commit f4e64bd

File tree

3 files changed

+33
-33
lines changed

3 files changed

+33
-33
lines changed

crates/ide-completion/src/item.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ pub struct CompletionRelevance {
164164
pub postfix_match: Option<CompletionRelevancePostfixMatch>,
165165
/// This is set for type inference results
166166
pub is_definite: bool,
167-
/// This is set for items that are associated functions
168-
pub associated_fn: Option<CompletionRelevanceAssociatedFn>,
167+
/// This is set for items that are function (associated or method)
168+
pub function: Option<CompletionRelevanceFn>,
169169
}
170170

171171
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
@@ -208,14 +208,14 @@ pub enum CompletionRelevancePostfixMatch {
208208
}
209209

210210
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
211-
pub struct CompletionRelevanceAssociatedFn {
211+
pub struct CompletionRelevanceFn {
212212
pub has_args: bool,
213213
pub has_self_arg: bool,
214-
pub ty: CompletionRelevanceAssociatedFnType,
214+
pub ty: CompletionRelevanceFnType,
215215
}
216216

217217
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
218-
pub enum CompletionRelevanceAssociatedFnType {
218+
pub enum CompletionRelevanceFnType {
219219
Other,
220220
/// Returns a type that is expected in this context
221221
ReturnsExpectedType,
@@ -250,7 +250,7 @@ impl CompletionRelevance {
250250
is_private_editable,
251251
postfix_match,
252252
is_definite,
253-
associated_fn,
253+
function: associated_fn,
254254
} = self;
255255

256256
// lower rank private things
@@ -296,11 +296,11 @@ impl CompletionRelevance {
296296
score += associated_fn
297297
.map(|asf| {
298298
let mut score = match asf.ty {
299-
CompletionRelevanceAssociatedFnType::ReturnsExpectedType => 20,
300-
CompletionRelevanceAssociatedFnType::DirectConstructor => 15,
301-
CompletionRelevanceAssociatedFnType::Builder => 10,
302-
CompletionRelevanceAssociatedFnType::Constructor => 5,
303-
CompletionRelevanceAssociatedFnType::Other => 0,
299+
CompletionRelevanceFnType::ReturnsExpectedType => 20,
300+
CompletionRelevanceFnType::DirectConstructor => 15,
301+
CompletionRelevanceFnType::Builder => 10,
302+
CompletionRelevanceFnType::Constructor => 5,
303+
CompletionRelevanceFnType::Other => 0,
304304
};
305305

306306
// Prefer functions with no arguments, then functions with self arguments

crates/ide-completion/src/render.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,7 +1176,7 @@ fn main() { let _: m::Spam = S$0 }
11761176
is_private_editable: false,
11771177
postfix_match: None,
11781178
is_definite: false,
1179-
associated_fn: None,
1179+
function: None,
11801180
},
11811181
trigger_call_info: true,
11821182
},
@@ -1203,7 +1203,7 @@ fn main() { let _: m::Spam = S$0 }
12031203
is_private_editable: false,
12041204
postfix_match: None,
12051205
is_definite: false,
1206-
associated_fn: None,
1206+
function: None,
12071207
},
12081208
trigger_call_info: true,
12091209
},
@@ -1282,7 +1282,7 @@ fn foo() { A { the$0 } }
12821282
is_private_editable: false,
12831283
postfix_match: None,
12841284
is_definite: false,
1285-
associated_fn: None,
1285+
function: None,
12861286
},
12871287
},
12881288
]
@@ -1327,8 +1327,8 @@ impl S {
13271327
is_private_editable: false,
13281328
postfix_match: None,
13291329
is_definite: false,
1330-
associated_fn: Some(
1331-
CompletionRelevanceAssociatedFn {
1330+
function: Some(
1331+
CompletionRelevanceFn {
13321332
has_args: true,
13331333
has_self_arg: true,
13341334
ty: Other,
@@ -1451,8 +1451,8 @@ fn foo(s: S) { s.$0 }
14511451
is_private_editable: false,
14521452
postfix_match: None,
14531453
is_definite: false,
1454-
associated_fn: Some(
1455-
CompletionRelevanceAssociatedFn {
1454+
function: Some(
1455+
CompletionRelevanceFn {
14561456
has_args: true,
14571457
has_self_arg: true,
14581458
ty: Other,
@@ -2220,8 +2220,8 @@ fn foo(f: Foo) { let _: &u32 = f.b$0 }
22202220
is_private_editable: false,
22212221
postfix_match: None,
22222222
is_definite: false,
2223-
associated_fn: Some(
2224-
CompletionRelevanceAssociatedFn {
2223+
function: Some(
2224+
CompletionRelevanceFn {
22252225
has_args: true,
22262226
has_self_arg: true,
22272227
ty: Other,
@@ -2301,7 +2301,7 @@ fn foo() {
23012301
is_private_editable: false,
23022302
postfix_match: None,
23032303
is_definite: false,
2304-
associated_fn: None,
2304+
function: None,
23052305
},
23062306
},
23072307
]
@@ -2350,8 +2350,8 @@ fn main() {
23502350
is_private_editable: false,
23512351
postfix_match: None,
23522352
is_definite: false,
2353-
associated_fn: Some(
2354-
CompletionRelevanceAssociatedFn {
2353+
function: Some(
2354+
CompletionRelevanceFn {
23552355
has_args: false,
23562356
has_self_arg: false,
23572357
ty: Other,

crates/ide-completion/src/render/function.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use crate::{
1111
CompletionContext, DotAccess, DotAccessKind, PathCompletionCtx, PathKind, Qualified,
1212
},
1313
item::{
14-
Builder, CompletionItem, CompletionItemKind, CompletionRelevance,
15-
CompletionRelevanceAssociatedFn, CompletionRelevanceAssociatedFnType,
14+
Builder, CompletionItem, CompletionItemKind, CompletionRelevance, CompletionRelevanceFn,
15+
CompletionRelevanceFnType,
1616
},
1717
render::{compute_exact_name_match, compute_ref_match, compute_type_match, RenderContext},
1818
CallableSnippets,
@@ -109,7 +109,7 @@ fn render(
109109
compute_type_match(completion, &func.ty(db))
110110
},
111111
exact_name_match: compute_exact_name_match(completion, &call),
112-
associated_fn: compute_associated_fn(&ctx, func, &func_kind, db),
112+
function: compute_associated_fn(&ctx, func, &func_kind, db),
113113
is_op_method,
114114
..ctx.completion_relevance()
115115
});
@@ -164,7 +164,7 @@ fn compute_associated_fn(
164164
func: hir::Function,
165165
func_kind: &FuncKind<'_>,
166166
db: &dyn HirDatabase,
167-
) -> Option<CompletionRelevanceAssociatedFn> {
167+
) -> Option<CompletionRelevanceFn> {
168168
if func.as_assoc_item(ctx.db()).is_none() {
169169
return None;
170170
}
@@ -198,21 +198,21 @@ fn compute_associated_fn(
198198
{
199199
// impl Foo { fn baz(&self) -> u32 { 0 } }
200200
// let _: u32 = foo.$0; // baz is preferred as it returns expected u32
201-
CompletionRelevanceAssociatedFnType::ReturnsExpectedType
201+
CompletionRelevanceFnType::ReturnsExpectedType
202202
} else if ret_type.display(db).to_string().ends_with("Builder") {
203203
// fn([..]) -> [..]Builder
204-
CompletionRelevanceAssociatedFnType::Builder
204+
CompletionRelevanceFnType::Builder
205205
} else if returns_self_wrapped {
206206
// fn([..]) -> Result<A>
207-
CompletionRelevanceAssociatedFnType::Constructor
207+
CompletionRelevanceFnType::Constructor
208208
} else if returns_self {
209209
// fn([..]) -> A
210-
CompletionRelevanceAssociatedFnType::DirectConstructor
210+
CompletionRelevanceFnType::DirectConstructor
211211
} else {
212-
CompletionRelevanceAssociatedFnType::Other
212+
CompletionRelevanceFnType::Other
213213
};
214214

215-
Some(CompletionRelevanceAssociatedFn { ty, has_args, has_self_arg })
215+
Some(CompletionRelevanceFn { ty, has_args, has_self_arg })
216216
}
217217

218218
pub(super) fn add_call_parens<'b>(

0 commit comments

Comments
 (0)