aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api')
-rw-r--r--crates/ra_ide_api/src/call_info.rs4
-rw-r--r--crates/ra_ide_api/src/change.rs2
-rw-r--r--crates/ra_ide_api/src/completion/complete_dot.rs3
-rw-r--r--crates/ra_ide_api/src/completion/complete_path.rs6
-rw-r--r--crates/ra_ide_api/src/completion/presentation.rs15
5 files changed, 15 insertions, 15 deletions
diff --git a/crates/ra_ide_api/src/call_info.rs b/crates/ra_ide_api/src/call_info.rs
index 41ee81511..7c367230e 100644
--- a/crates/ra_ide_api/src/call_info.rs
+++ b/crates/ra_ide_api/src/call_info.rs
@@ -30,7 +30,7 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal
30 let (callable_def, _subst) = analyzer.type_of(db, &expr.expr()?)?.as_callable()?; 30 let (callable_def, _subst) = analyzer.type_of(db, &expr.expr()?)?.as_callable()?;
31 match callable_def { 31 match callable_def {
32 hir::CallableDef::Function(it) => { 32 hir::CallableDef::Function(it) => {
33 (CallInfo::with_fn(db, it), it.data(db).has_self_param()) 33 (CallInfo::with_fn(db, it), it.has_self_param(db))
34 } 34 }
35 hir::CallableDef::Struct(it) => (CallInfo::with_struct(db, it)?, false), 35 hir::CallableDef::Struct(it) => (CallInfo::with_struct(db, it)?, false),
36 hir::CallableDef::EnumVariant(it) => (CallInfo::with_enum_variant(db, it)?, false), 36 hir::CallableDef::EnumVariant(it) => (CallInfo::with_enum_variant(db, it)?, false),
@@ -38,7 +38,7 @@ pub(crate) fn call_info(db: &RootDatabase, position: FilePosition) -> Option<Cal
38 } 38 }
39 FnCallNode::MethodCallExpr(expr) => { 39 FnCallNode::MethodCallExpr(expr) => {
40 let function = analyzer.resolve_method_call(&expr)?; 40 let function = analyzer.resolve_method_call(&expr)?;
41 (CallInfo::with_fn(db, function), function.data(db).has_self_param()) 41 (CallInfo::with_fn(db, function), function.has_self_param(db))
42 } 42 }
43 FnCallNode::MacroCallExpr(expr) => { 43 FnCallNode::MacroCallExpr(expr) => {
44 let macro_def = analyzer.resolve_macro_call(db, &expr)?; 44 let macro_def = analyzer.resolve_macro_call(db, &expr)?;
diff --git a/crates/ra_ide_api/src/change.rs b/crates/ra_ide_api/src/change.rs
index 3c607d5b5..8a05b287f 100644
--- a/crates/ra_ide_api/src/change.rs
+++ b/crates/ra_ide_api/src/change.rs
@@ -313,7 +313,7 @@ impl RootDatabase {
313 hir::db::RawItemsQuery 313 hir::db::RawItemsQuery
314 hir::db::CrateDefMapQuery 314 hir::db::CrateDefMapQuery
315 hir::db::GenericParamsQuery 315 hir::db::GenericParamsQuery
316 hir::db::FnDataQuery 316 hir::db::FunctionDataQuery
317 hir::db::TypeAliasDataQuery 317 hir::db::TypeAliasDataQuery
318 hir::db::ConstDataQuery 318 hir::db::ConstDataQuery
319 hir::db::StaticDataQuery 319 hir::db::StaticDataQuery
diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs
index 4e2c497e1..5a3f9b5f6 100644
--- a/crates/ra_ide_api/src/completion/complete_dot.rs
+++ b/crates/ra_ide_api/src/completion/complete_dot.rs
@@ -59,8 +59,7 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty)
59fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) { 59fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) {
60 let mut seen_methods = FxHashSet::default(); 60 let mut seen_methods = FxHashSet::default();
61 ctx.analyzer.iterate_method_candidates(ctx.db, receiver, None, |_ty, func| { 61 ctx.analyzer.iterate_method_candidates(ctx.db, receiver, None, |_ty, func| {
62 let data = func.data(ctx.db); 62 if func.has_self_param(ctx.db) && seen_methods.insert(func.name(ctx.db)) {
63 if data.has_self_param() && seen_methods.insert(data.name().clone()) {
64 acc.add_function(ctx, func); 63 acc.add_function(ctx, func);
65 } 64 }
66 None::<()> 65 None::<()>
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs
index 5d974cf6d..802c7701a 100644
--- a/crates/ra_ide_api/src/completion/complete_path.rs
+++ b/crates/ra_ide_api/src/completion/complete_path.rs
@@ -53,8 +53,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
53 ctx.analyzer.iterate_path_candidates(ctx.db, ty.clone(), None, |_ty, item| { 53 ctx.analyzer.iterate_path_candidates(ctx.db, ty.clone(), None, |_ty, item| {
54 match item { 54 match item {
55 hir::AssocItem::Function(func) => { 55 hir::AssocItem::Function(func) => {
56 let data = func.data(ctx.db); 56 if !func.has_self_param(ctx.db) {
57 if !data.has_self_param() {
58 acc.add_function(ctx, func); 57 acc.add_function(ctx, func);
59 } 58 }
60 } 59 }
@@ -80,8 +79,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
80 for item in t.items(ctx.db) { 79 for item in t.items(ctx.db) {
81 match item { 80 match item {
82 hir::AssocItem::Function(func) => { 81 hir::AssocItem::Function(func) => {
83 let data = func.data(ctx.db); 82 if !func.has_self_param(ctx.db) {
84 if !data.has_self_param() {
85 acc.add_function(ctx, func); 83 acc.add_function(ctx, func);
86 } 84 }
87 } 85 }
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs
index bd464d193..50fdb0043 100644
--- a/crates/ra_ide_api/src/completion/presentation.rs
+++ b/crates/ra_ide_api/src/completion/presentation.rs
@@ -199,14 +199,17 @@ impl Completions {
199 name: Option<String>, 199 name: Option<String>,
200 func: hir::Function, 200 func: hir::Function,
201 ) { 201 ) {
202 let data = func.data(ctx.db); 202 let func_name = func.name(ctx.db);
203 let name = name.unwrap_or_else(|| data.name().to_string()); 203 let has_self_param = func.has_self_param(ctx.db);
204 let params = func.params(ctx.db);
205
206 let name = name.unwrap_or_else(|| func_name.to_string());
204 let ast_node = func.source(ctx.db).value; 207 let ast_node = func.source(ctx.db).value;
205 let detail = function_label(&ast_node); 208 let detail = function_label(&ast_node);
206 209
207 let mut builder = 210 let mut builder =
208 CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.clone()) 211 CompletionItem::new(CompletionKind::Reference, ctx.source_range(), name.clone())
209 .kind(if data.has_self_param() { 212 .kind(if has_self_param {
210 CompletionItemKind::Method 213 CompletionItemKind::Method
211 } else { 214 } else {
212 CompletionItemKind::Function 215 CompletionItemKind::Function
@@ -222,10 +225,10 @@ impl Completions {
222 { 225 {
223 tested_by!(inserts_parens_for_function_calls); 226 tested_by!(inserts_parens_for_function_calls);
224 let (snippet, label) = 227 let (snippet, label) =
225 if data.params().is_empty() || data.has_self_param() && data.params().len() == 1 { 228 if params.is_empty() || has_self_param && params.len() == 1 {
226 (format!("{}()$0", data.name()), format!("{}()", name)) 229 (format!("{}()$0", func_name), format!("{}()", name))
227 } else { 230 } else {
228 (format!("{}($0)", data.name()), format!("{}(…)", name)) 231 (format!("{}($0)", func_name), format!("{}(…)", name))
229 }; 232 };
230 builder = builder.lookup_by(name).label(label).insert_snippet(snippet); 233 builder = builder.lookup_by(name).label(label).insert_snippet(snippet);
231 } 234 }