aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r--crates/ra_ide_api/src/completion/complete_scope.rs2
-rw-r--r--crates/ra_ide_api/src/goto_definition.rs (renamed from crates/ra_ide_api/src/goto_defenition.rs)22
-rw-r--r--crates/ra_ide_api/src/hover.rs2
-rw-r--r--crates/ra_ide_api/src/lib.rs6
4 files changed, 16 insertions, 16 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_scope.rs b/crates/ra_ide_api/src/completion/complete_scope.rs
index ee9052d3d..770a0fdf2 100644
--- a/crates/ra_ide_api/src/completion/complete_scope.rs
+++ b/crates/ra_ide_api/src/completion/complete_scope.rs
@@ -20,7 +20,7 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) ->
20 } 20 }
21 21
22 let module_scope = module.scope(ctx.db)?; 22 let module_scope = module.scope(ctx.db)?;
23 let (file_id, _) = module.defenition_source(ctx.db)?; 23 let (file_id, _) = module.definition_source(ctx.db)?;
24 module_scope 24 module_scope
25 .entries() 25 .entries()
26 .filter(|(_name, res)| { 26 .filter(|(_name, res)| {
diff --git a/crates/ra_ide_api/src/goto_defenition.rs b/crates/ra_ide_api/src/goto_definition.rs
index fcd8d315e..0d524b6f1 100644
--- a/crates/ra_ide_api/src/goto_defenition.rs
+++ b/crates/ra_ide_api/src/goto_definition.rs
@@ -6,22 +6,22 @@ use ra_syntax::{
6 6
7use crate::{FilePosition, NavigationTarget, db::RootDatabase}; 7use crate::{FilePosition, NavigationTarget, db::RootDatabase};
8 8
9pub(crate) fn goto_defenition( 9pub(crate) fn goto_definition(
10 db: &RootDatabase, 10 db: &RootDatabase,
11 position: FilePosition, 11 position: FilePosition,
12) -> Cancelable<Option<Vec<NavigationTarget>>> { 12) -> Cancelable<Option<Vec<NavigationTarget>>> {
13 let file = db.source_file(position.file_id); 13 let file = db.source_file(position.file_id);
14 let syntax = file.syntax(); 14 let syntax = file.syntax();
15 if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, position.offset) { 15 if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, position.offset) {
16 return Ok(Some(reference_defenition(db, position.file_id, name_ref)?)); 16 return Ok(Some(reference_definition(db, position.file_id, name_ref)?));
17 } 17 }
18 if let Some(name) = find_node_at_offset::<ast::Name>(syntax, position.offset) { 18 if let Some(name) = find_node_at_offset::<ast::Name>(syntax, position.offset) {
19 return name_defenition(db, position.file_id, name); 19 return name_definition(db, position.file_id, name);
20 } 20 }
21 Ok(None) 21 Ok(None)
22} 22}
23 23
24pub(crate) fn reference_defenition( 24pub(crate) fn reference_definition(
25 db: &RootDatabase, 25 db: &RootDatabase,
26 file_id: FileId, 26 file_id: FileId,
27 name_ref: &ast::NameRef, 27 name_ref: &ast::NameRef,
@@ -51,7 +51,7 @@ pub(crate) fn reference_defenition(
51 Ok(navs) 51 Ok(navs)
52} 52}
53 53
54fn name_defenition( 54fn name_definition(
55 db: &RootDatabase, 55 db: &RootDatabase,
56 file_id: FileId, 56 file_id: FileId,
57 name: &ast::Name, 57 name: &ast::Name,
@@ -61,7 +61,7 @@ fn name_defenition(
61 if let Some(child_module) = 61 if let Some(child_module) =
62 hir::source_binder::module_from_declaration(db, file_id, module)? 62 hir::source_binder::module_from_declaration(db, file_id, module)?
63 { 63 {
64 let (file_id, _) = child_module.defenition_source(db)?; 64 let (file_id, _) = child_module.definition_source(db)?;
65 let name = match child_module.name(db)? { 65 let name = match child_module.name(db)? {
66 Some(name) => name.to_string().into(), 66 Some(name) => name.to_string().into(),
67 None => "".into(), 67 None => "".into(),
@@ -86,7 +86,7 @@ mod tests {
86 use crate::mock_analysis::analysis_and_position; 86 use crate::mock_analysis::analysis_and_position;
87 87
88 #[test] 88 #[test]
89 fn goto_defenition_works_in_items() { 89 fn goto_definition_works_in_items() {
90 let (analysis, pos) = analysis_and_position( 90 let (analysis, pos) = analysis_and_position(
91 " 91 "
92 //- /lib.rs 92 //- /lib.rs
@@ -95,7 +95,7 @@ mod tests {
95 ", 95 ",
96 ); 96 );
97 97
98 let symbols = analysis.goto_defenition(pos).unwrap().unwrap(); 98 let symbols = analysis.goto_definition(pos).unwrap().unwrap();
99 assert_eq_dbg( 99 assert_eq_dbg(
100 r#"[NavigationTarget { file_id: FileId(1), name: "Foo", 100 r#"[NavigationTarget { file_id: FileId(1), name: "Foo",
101 kind: STRUCT_DEF, range: [0; 11), 101 kind: STRUCT_DEF, range: [0; 11),
@@ -105,7 +105,7 @@ mod tests {
105 } 105 }
106 106
107 #[test] 107 #[test]
108 fn goto_defenition_works_for_module_declaration() { 108 fn goto_definition_works_for_module_declaration() {
109 let (analysis, pos) = analysis_and_position( 109 let (analysis, pos) = analysis_and_position(
110 " 110 "
111 //- /lib.rs 111 //- /lib.rs
@@ -115,7 +115,7 @@ mod tests {
115 ", 115 ",
116 ); 116 );
117 117
118 let symbols = analysis.goto_defenition(pos).unwrap().unwrap(); 118 let symbols = analysis.goto_definition(pos).unwrap().unwrap();
119 assert_eq_dbg( 119 assert_eq_dbg(
120 r#"[NavigationTarget { file_id: FileId(2), name: "foo", kind: MODULE, range: [0; 0), ptr: None }]"#, 120 r#"[NavigationTarget { file_id: FileId(2), name: "foo", kind: MODULE, range: [0; 0), ptr: None }]"#,
121 &symbols, 121 &symbols,
@@ -130,7 +130,7 @@ mod tests {
130 ", 130 ",
131 ); 131 );
132 132
133 let symbols = analysis.goto_defenition(pos).unwrap().unwrap(); 133 let symbols = analysis.goto_definition(pos).unwrap().unwrap();
134 assert_eq_dbg( 134 assert_eq_dbg(
135 r#"[NavigationTarget { file_id: FileId(2), name: "foo", kind: MODULE, range: [0; 0), ptr: None }]"#, 135 r#"[NavigationTarget { file_id: FileId(2), name: "foo", kind: MODULE, range: [0; 0), ptr: None }]"#,
136 &symbols, 136 &symbols,
diff --git a/crates/ra_ide_api/src/hover.rs b/crates/ra_ide_api/src/hover.rs
index 475524ee1..41309e756 100644
--- a/crates/ra_ide_api/src/hover.rs
+++ b/crates/ra_ide_api/src/hover.rs
@@ -16,7 +16,7 @@ pub(crate) fn hover(
16 16
17 let mut range = None; 17 let mut range = None;
18 if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(file.syntax(), position.offset) { 18 if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(file.syntax(), position.offset) {
19 let navs = crate::goto_defenition::reference_defenition(db, position.file_id, name_ref)?; 19 let navs = crate::goto_definition::reference_definition(db, position.file_id, name_ref)?;
20 for nav in navs { 20 for nav in navs {
21 res.extend(doc_text_for(db, nav)?) 21 res.extend(doc_text_for(db, nav)?)
22 } 22 }
diff --git a/crates/ra_ide_api/src/lib.rs b/crates/ra_ide_api/src/lib.rs
index 7e9ca2034..762731268 100644
--- a/crates/ra_ide_api/src/lib.rs
+++ b/crates/ra_ide_api/src/lib.rs
@@ -20,7 +20,7 @@ macro_rules! ctry {
20 20
21mod completion; 21mod completion;
22mod db; 22mod db;
23mod goto_defenition; 23mod goto_definition;
24mod imp; 24mod imp;
25pub mod mock_analysis; 25pub mod mock_analysis;
26mod runnables; 26mod runnables;
@@ -399,11 +399,11 @@ impl Analysis {
399 .collect(); 399 .collect();
400 Ok(res) 400 Ok(res)
401 } 401 }
402 pub fn goto_defenition( 402 pub fn goto_definition(
403 &self, 403 &self,
404 position: FilePosition, 404 position: FilePosition,
405 ) -> Cancelable<Option<Vec<NavigationTarget>>> { 405 ) -> Cancelable<Option<Vec<NavigationTarget>>> {
406 goto_defenition::goto_defenition(&*self.db, position) 406 goto_definition::goto_definition(&*self.db, position)
407 } 407 }
408 /// Finds all usages of the reference at point. 408 /// Finds all usages of the reference at point.
409 pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> { 409 pub fn find_all_refs(&self, position: FilePosition) -> Cancelable<Vec<(FileId, TextRange)>> {