From 40e6cb196b3e4fdb580812a418edfb8df08cf423 Mon Sep 17 00:00:00 2001 From: Ville Penttinen Date: Sat, 23 Feb 2019 14:08:57 +0200 Subject: Remove unnecessary to_nav_target --- crates/ra_ide_api/src/goto_definition.rs | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'crates') 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 @@ use ra_db::{FileId, SourceDatabase}; use ra_syntax::{ - AstNode, ast::{self, NameOwner}, + AstNode, ast, algo::{find_node_at_offset, visit::{visitor, Visitor}}, SyntaxNode, }; @@ -136,22 +136,18 @@ fn name_definition( } fn named_target(file_id: FileId, node: &SyntaxNode) -> Option { - fn to_nav_target(node: &N, file_id: FileId) -> Option { - Some(NavigationTarget::from_named(file_id, node)) - } - visitor() - .visit(|n: &ast::StructDef| to_nav_target(n, file_id)) - .visit(|n: &ast::EnumDef| to_nav_target(n, file_id)) - .visit(|n: &ast::EnumVariant| to_nav_target(n, file_id)) - .visit(|n: &ast::FnDef| to_nav_target(n, file_id)) - .visit(|n: &ast::TypeDef| to_nav_target(n, file_id)) - .visit(|n: &ast::ConstDef| to_nav_target(n, file_id)) - .visit(|n: &ast::StaticDef| to_nav_target(n, file_id)) - .visit(|n: &ast::TraitDef| to_nav_target(n, file_id)) - .visit(|n: &ast::NamedFieldDef| to_nav_target(n, file_id)) - .visit(|n: &ast::Module| to_nav_target(n, file_id)) - .accept(node)? + .visit(|node: &ast::StructDef| NavigationTarget::from_named(file_id, node)) + .visit(|node: &ast::EnumDef| NavigationTarget::from_named(file_id, node)) + .visit(|node: &ast::EnumVariant| NavigationTarget::from_named(file_id, node)) + .visit(|node: &ast::FnDef| NavigationTarget::from_named(file_id, node)) + .visit(|node: &ast::TypeDef| NavigationTarget::from_named(file_id, node)) + .visit(|node: &ast::ConstDef| NavigationTarget::from_named(file_id, node)) + .visit(|node: &ast::StaticDef| NavigationTarget::from_named(file_id, node)) + .visit(|node: &ast::TraitDef| NavigationTarget::from_named(file_id, node)) + .visit(|node: &ast::NamedFieldDef| NavigationTarget::from_named(file_id, node)) + .visit(|node: &ast::Module| NavigationTarget::from_named(file_id, node)) + .accept(node) } #[cfg(test)] -- cgit v1.2.3