aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/display/function_signature.rs8
-rw-r--r--crates/ra_ide/src/lib.rs8
-rw-r--r--crates/ra_ide/src/references/rename.rs62
3 files changed, 73 insertions, 5 deletions
diff --git a/crates/ra_ide/src/display/function_signature.rs b/crates/ra_ide/src/display/function_signature.rs
index db3907fe6..f16d42276 100644
--- a/crates/ra_ide/src/display/function_signature.rs
+++ b/crates/ra_ide/src/display/function_signature.rs
@@ -1,5 +1,7 @@
1//! FIXME: write short doc here 1//! FIXME: write short doc here
2 2
3// FIXME: this modules relies on strings and AST way too much, and it should be
4// rewritten (matklad 2020-05-07)
3use std::{ 5use std::{
4 convert::From, 6 convert::From,
5 fmt::{self, Display}, 7 fmt::{self, Display},
@@ -202,7 +204,11 @@ impl From<&'_ ast::FnDef> for FunctionSignature {
202 204
203 res.extend(param_list.params().map(|param| param.syntax().text().to_string())); 205 res.extend(param_list.params().map(|param| param.syntax().text().to_string()));
204 res_types.extend(param_list.params().map(|param| { 206 res_types.extend(param_list.params().map(|param| {
205 param.syntax().text().to_string().split(':').nth(1).unwrap()[1..].to_string() 207 let param_text = param.syntax().text().to_string();
208 match param_text.split(':').nth(1) {
209 Some(it) => it[1..].to_string(),
210 None => param_text,
211 }
206 })); 212 }));
207 } 213 }
208 (has_self_param, res, res_types) 214 (has_self_param, res, res_types)
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs
index 737f87109..915199bd8 100644
--- a/crates/ra_ide/src/lib.rs
+++ b/crates/ra_ide/src/lib.rs
@@ -472,12 +472,12 @@ impl Analysis {
472 /// position. 472 /// position.
473 pub fn assists(&self, frange: FileRange) -> Cancelable<Vec<Assist>> { 473 pub fn assists(&self, frange: FileRange) -> Cancelable<Vec<Assist>> {
474 self.with_db(|db| { 474 self.with_db(|db| {
475 ra_assists::resolved_assists(db, frange) 475 ra_assists::Assist::resolved(db, frange)
476 .into_iter() 476 .into_iter()
477 .map(|assist| Assist { 477 .map(|assist| Assist {
478 id: assist.label.id, 478 id: assist.assist.id,
479 label: assist.label.label, 479 label: assist.assist.label,
480 group_label: assist.label.group.map(|it| it.0), 480 group_label: assist.assist.group.map(|it| it.0),
481 source_change: assist.source_change, 481 source_change: assist.source_change,
482 }) 482 })
483 .collect() 483 .collect()
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs
index 0398d53bc..2cbb82c1a 100644
--- a/crates/ra_ide/src/references/rename.rs
+++ b/crates/ra_ide/src/references/rename.rs
@@ -712,6 +712,68 @@ mod tests {
712 "###); 712 "###);
713 } 713 }
714 714
715 #[test]
716 fn test_enum_variant_from_module_1() {
717 test_rename(
718 r#"
719 mod foo {
720 pub enum Foo {
721 Bar<|>,
722 }
723 }
724
725 fn func(f: foo::Foo) {
726 match f {
727 foo::Foo::Bar => {}
728 }
729 }
730 "#,
731 "Baz",
732 r#"
733 mod foo {
734 pub enum Foo {
735 Baz,
736 }
737 }
738
739 fn func(f: foo::Foo) {
740 match f {
741 foo::Foo::Baz => {}
742 }
743 }
744 "#,
745 );
746 }
747
748 #[test]
749 fn test_enum_variant_from_module_2() {
750 test_rename(
751 r#"
752 mod foo {
753 pub struct Foo {
754 pub bar<|>: uint,
755 }
756 }
757
758 fn foo(f: foo::Foo) {
759 let _ = f.bar;
760 }
761 "#,
762 "baz",
763 r#"
764 mod foo {
765 pub struct Foo {
766 pub baz: uint,
767 }
768 }
769
770 fn foo(f: foo::Foo) {
771 let _ = f.baz;
772 }
773 "#,
774 );
775 }
776
715 fn test_rename(text: &str, new_name: &str, expected: &str) { 777 fn test_rename(text: &str, new_name: &str, expected: &str) {
716 let (analysis, position) = single_file_with_position(text); 778 let (analysis, position) = single_file_with_position(text);
717 let source_change = analysis.rename(position, new_name).unwrap(); 779 let source_change = analysis.rename(position, new_name).unwrap();