aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide
diff options
context:
space:
mode:
authorPaul Daniel Faria <[email protected]>2020-06-28 21:04:00 +0100
committerPaul Daniel Faria <[email protected]>2020-08-10 13:44:54 +0100
commitc5cc24cb312c70159e63315ea49769b575e8cb65 (patch)
treefc2f5fe712e5776e0356c8e4f09135692a5ccc20 /crates/ra_ide
parentaca3d6c57ec2c668cdb51eca34d6f7bc8fa7412b (diff)
Revert function structs back to using bool to track self param, use first param for self information in syntax highlighting instead
Diffstat (limited to 'crates/ra_ide')
-rw-r--r--crates/ra_ide/src/completion/complete_dot.rs2
-rw-r--r--crates/ra_ide/src/completion/complete_trait_impl.rs2
-rw-r--r--crates/ra_ide/src/completion/presentation.rs2
-rw-r--r--crates/ra_ide/src/syntax_highlighting.rs11
4 files changed, 11 insertions, 6 deletions
diff --git a/crates/ra_ide/src/completion/complete_dot.rs b/crates/ra_ide/src/completion/complete_dot.rs
index 5488db43f..532665285 100644
--- a/crates/ra_ide/src/completion/complete_dot.rs
+++ b/crates/ra_ide/src/completion/complete_dot.rs
@@ -48,7 +48,7 @@ fn complete_methods(acc: &mut Completions, ctx: &CompletionContext, receiver: &T
48 let mut seen_methods = FxHashSet::default(); 48 let mut seen_methods = FxHashSet::default();
49 let traits_in_scope = ctx.scope.traits_in_scope(); 49 let traits_in_scope = ctx.scope.traits_in_scope();
50 receiver.iterate_method_candidates(ctx.db, krate, &traits_in_scope, None, |_ty, func| { 50 receiver.iterate_method_candidates(ctx.db, krate, &traits_in_scope, None, |_ty, func| {
51 if func.self_param(ctx.db).is_some() 51 if func.has_self_param(ctx.db)
52 && ctx.scope.module().map_or(true, |m| func.is_visible_from(ctx.db, m)) 52 && ctx.scope.module().map_or(true, |m| func.is_visible_from(ctx.db, m))
53 && seen_methods.insert(func.name(ctx.db)) 53 && seen_methods.insert(func.name(ctx.db))
54 { 54 {
diff --git a/crates/ra_ide/src/completion/complete_trait_impl.rs b/crates/ra_ide/src/completion/complete_trait_impl.rs
index e3ba7ebc4..d9a0ef167 100644
--- a/crates/ra_ide/src/completion/complete_trait_impl.rs
+++ b/crates/ra_ide/src/completion/complete_trait_impl.rs
@@ -136,7 +136,7 @@ fn add_function_impl(
136 .lookup_by(fn_name) 136 .lookup_by(fn_name)
137 .set_documentation(func.docs(ctx.db)); 137 .set_documentation(func.docs(ctx.db));
138 138
139 let completion_kind = if func.self_param(ctx.db).is_some() { 139 let completion_kind = if func.has_self_param(ctx.db) {
140 CompletionItemKind::Method 140 CompletionItemKind::Method
141 } else { 141 } else {
142 CompletionItemKind::Function 142 CompletionItemKind::Function
diff --git a/crates/ra_ide/src/completion/presentation.rs b/crates/ra_ide/src/completion/presentation.rs
index fc3d1a4bd..9a94ff476 100644
--- a/crates/ra_ide/src/completion/presentation.rs
+++ b/crates/ra_ide/src/completion/presentation.rs
@@ -191,7 +191,7 @@ impl Completions {
191 func: hir::Function, 191 func: hir::Function,
192 local_name: Option<String>, 192 local_name: Option<String>,
193 ) { 193 ) {
194 let has_self_param = func.self_param(ctx.db).is_some(); 194 let has_self_param = func.has_self_param(ctx.db);
195 195
196 let name = local_name.unwrap_or_else(|| func.name(ctx.db).to_string()); 196 let name = local_name.unwrap_or_else(|| func.name(ctx.db).to_string());
197 let ast_node = func.source(ctx.db).value; 197 let ast_node = func.source(ctx.db).value;
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs
index 02b16b13c..d5a5f69cc 100644
--- a/crates/ra_ide/src/syntax_highlighting.rs
+++ b/crates/ra_ide/src/syntax_highlighting.rs
@@ -4,7 +4,7 @@ mod injection;
4#[cfg(test)] 4#[cfg(test)]
5mod tests; 5mod tests;
6 6
7use hir::{Name, Semantics, VariantDef}; 7use hir::{Name, Semantics, TypeRef, VariantDef};
8use ra_ide_db::{ 8use ra_ide_db::{
9 defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, 9 defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass},
10 RootDatabase, 10 RootDatabase,
@@ -756,8 +756,13 @@ fn is_method_call_unsafe(
756 } 756 }
757 757
758 let func = sema.resolve_method_call(&method_call_expr)?; 758 let func = sema.resolve_method_call(&method_call_expr)?;
759 if func.self_param(sema.db)?.is_ref { 759 if func.has_self_param(sema.db) {
760 Some(()) 760 let params = func.params(sema.db);
761 if matches!(params.into_iter().next(), Some(TypeRef::Reference(..))) {
762 Some(())
763 } else {
764 None
765 }
761 } else { 766 } else {
762 None 767 None
763 } 768 }