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/goto_definition.rs28
1 files changed, 12 insertions, 16 deletions
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs
index a4ee77d94..4dac96bfe 100644
--- a/crates/ra_ide_api/src/goto_definition.rs
+++ b/crates/ra_ide_api/src/goto_definition.rs
@@ -1,6 +1,6 @@
1use ra_db::{FileId, SourceDatabase}; 1use ra_db::{FileId, SourceDatabase};
2use ra_syntax::{ 2use ra_syntax::{
3 AstNode, ast::{self, NameOwner}, 3 AstNode, ast,
4 algo::{find_node_at_offset, visit::{visitor, Visitor}}, 4 algo::{find_node_at_offset, visit::{visitor, Visitor}},
5 SyntaxNode, 5 SyntaxNode,
6}; 6};
@@ -136,22 +136,18 @@ fn name_definition(
136} 136}
137 137
138fn named_target(file_id: FileId, node: &SyntaxNode) -> Option<NavigationTarget> { 138fn named_target(file_id: FileId, node: &SyntaxNode) -> Option<NavigationTarget> {
139 fn to_nav_target<N: NameOwner>(node: &N, file_id: FileId) -> Option<NavigationTarget> {
140 Some(NavigationTarget::from_named(file_id, node))
141 }
142
143 visitor() 139 visitor()
144 .visit(|n: &ast::StructDef| to_nav_target(n, file_id)) 140 .visit(|node: &ast::StructDef| NavigationTarget::from_named(file_id, node))
145 .visit(|n: &ast::EnumDef| to_nav_target(n, file_id)) 141 .visit(|node: &ast::EnumDef| NavigationTarget::from_named(file_id, node))
146 .visit(|n: &ast::EnumVariant| to_nav_target(n, file_id)) 142 .visit(|node: &ast::EnumVariant| NavigationTarget::from_named(file_id, node))
147 .visit(|n: &ast::FnDef| to_nav_target(n, file_id)) 143 .visit(|node: &ast::FnDef| NavigationTarget::from_named(file_id, node))
148 .visit(|n: &ast::TypeDef| to_nav_target(n, file_id)) 144 .visit(|node: &ast::TypeDef| NavigationTarget::from_named(file_id, node))
149 .visit(|n: &ast::ConstDef| to_nav_target(n, file_id)) 145 .visit(|node: &ast::ConstDef| NavigationTarget::from_named(file_id, node))
150 .visit(|n: &ast::StaticDef| to_nav_target(n, file_id)) 146 .visit(|node: &ast::StaticDef| NavigationTarget::from_named(file_id, node))
151 .visit(|n: &ast::TraitDef| to_nav_target(n, file_id)) 147 .visit(|node: &ast::TraitDef| NavigationTarget::from_named(file_id, node))
152 .visit(|n: &ast::NamedFieldDef| to_nav_target(n, file_id)) 148 .visit(|node: &ast::NamedFieldDef| NavigationTarget::from_named(file_id, node))
153 .visit(|n: &ast::Module| to_nav_target(n, file_id)) 149 .visit(|node: &ast::Module| NavigationTarget::from_named(file_id, node))
154 .accept(node)? 150 .accept(node)
155} 151}
156 152
157#[cfg(test)] 153#[cfg(test)]