diff options
author | Aleksey Kladov <[email protected]> | 2019-01-05 16:30:42 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-05 16:30:42 +0000 |
commit | ad2a5da259aba485150cb3c3a8395c18be12cba7 (patch) | |
tree | 742acb6076ad46b574db7140a1a54ba4259ddc89 /crates | |
parent | 2a19d699eb594c4929215a24df333f87fd41881a (diff) |
kill accidentally added file
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_analysis/src/goto_defenition.rs | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/crates/ra_analysis/src/goto_defenition.rs b/crates/ra_analysis/src/goto_defenition.rs deleted file mode 100644 index 607a25115..000000000 --- a/crates/ra_analysis/src/goto_defenition.rs +++ /dev/null | |||
@@ -1,73 +0,0 @@ | |||
1 | use ra_db::FileId; | ||
2 | use ra_syntax::ast; | ||
3 | |||
4 | use crate::db::RootDatabase; | ||
5 | |||
6 | pub fn goto_defenition(db: &RootDatabase, position: FilePosition, | ||
7 | ) -> Cancelable<Option<Vec<NavigationTarget>>> { | ||
8 | let file = db.source_file(position.file_id); | ||
9 | let syntax = file.syntax(); | ||
10 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, position.offset) { | ||
11 | return Ok(Some(reference_defenition(db, position.file_id, name_ref))); | ||
12 | } | ||
13 | if let Some(name) = find_node_at_offset::<ast::Name>(syntax, position.offset) { | ||
14 | return Ok(Some(name_defenition(db, position.file_idname))); | ||
15 | } | ||
16 | Ok(None) | ||
17 | } | ||
18 | |||
19 | fn reference_defenition(db: &RootDatabase, file_id: FileId, name_ref: ast::NameRef) -> Cancelable<Vec<Nav>> { | ||
20 | if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(syntax, position.offset) { | ||
21 | let mut rr = ReferenceResolution::new(name_ref.syntax().range()); | ||
22 | if let Some(fn_descr) = | ||
23 | source_binder::function_from_child_node(self, position.file_id, name_ref.syntax())? | ||
24 | { | ||
25 | let scope = fn_descr.scopes(self); | ||
26 | // First try to resolve the symbol locally | ||
27 | if let Some(entry) = scope.resolve_local_name(name_ref) { | ||
28 | rr.resolves_to.push(NavigationTarget { | ||
29 | file_id: position.file_id, | ||
30 | name: entry.name().to_string().into(), | ||
31 | range: entry.ptr().range(), | ||
32 | kind: NAME, | ||
33 | ptr: None, | ||
34 | }); | ||
35 | return Ok(Some(rr)); | ||
36 | }; | ||
37 | } | ||
38 | // If that fails try the index based approach. | ||
39 | rr.resolves_to.extend( | ||
40 | self.index_resolve(name_ref)? | ||
41 | .into_iter() | ||
42 | .map(NavigationTarget::from_symbol), | ||
43 | ); | ||
44 | return Ok(Some(rr)); | ||
45 | } | ||
46 | if let Some(name) = find_node_at_offset::<ast::Name>(syntax, position.offset) { | ||
47 | let mut rr = ReferenceResolution::new(name.syntax().range()); | ||
48 | if let Some(module) = name.syntax().parent().and_then(ast::Module::cast) { | ||
49 | if module.has_semi() { | ||
50 | if let Some(child_module) = | ||
51 | source_binder::module_from_declaration(self, position.file_id, module)? | ||
52 | { | ||
53 | let file_id = child_module.file_id(); | ||
54 | let name = match child_module.name() { | ||
55 | Some(name) => name.to_string().into(), | ||
56 | None => "".into(), | ||
57 | }; | ||
58 | let symbol = NavigationTarget { | ||
59 | file_id, | ||
60 | name, | ||
61 | range: TextRange::offset_len(0.into(), 0.into()), | ||
62 | kind: MODULE, | ||
63 | ptr: None, | ||
64 | }; | ||
65 | rr.resolves_to.push(symbol); | ||
66 | return Ok(Some(rr)); | ||
67 | } | ||
68 | } | ||
69 | } | ||
70 | } | ||
71 | Ok(None) | ||
72 | |||
73 | } | ||