aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api
diff options
context:
space:
mode:
authorVille Penttinen <[email protected]>2019-02-23 12:08:57 +0000
committerVille Penttinen <[email protected]>2019-02-23 12:08:57 +0000
commit40e6cb196b3e4fdb580812a418edfb8df08cf423 (patch)
treeedbaea68ce746329cd4734ea974d7289f2125eb9 /crates/ra_ide_api
parentc565ec2d6e736c90b8c5a6b89795022d1cc1c1a3 (diff)
Remove unnecessary to_nav_target
Diffstat (limited to 'crates/ra_ide_api')
-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)]