diff options
Diffstat (limited to 'crates/ra_ide_api/src/goto_definition.rs')
-rw-r--r-- | crates/ra_ide_api/src/goto_definition.rs | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/crates/ra_ide_api/src/goto_definition.rs b/crates/ra_ide_api/src/goto_definition.rs index 31b6679ae..fbd881bfe 100644 --- a/crates/ra_ide_api/src/goto_definition.rs +++ b/crates/ra_ide_api/src/goto_definition.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use ra_db::{FileId, SourceDatabase}; | 1 | use ra_db::{FileId, SourceDatabase}; |
2 | use ra_syntax::{ | 2 | use ra_syntax::{ |
3 | AstNode, ast, | 3 | AstNode, ast::{self, DocCommentsOwner}, |
4 | algo::{ | 4 | algo::{ |
5 | find_node_at_offset, | 5 | find_node_at_offset, |
6 | visit::{visitor, Visitor}, | 6 | visit::{visitor, Visitor}, |
@@ -114,17 +114,39 @@ pub(crate) fn name_definition( | |||
114 | 114 | ||
115 | fn named_target(file_id: FileId, node: &SyntaxNode) -> Option<NavigationTarget> { | 115 | fn named_target(file_id: FileId, node: &SyntaxNode) -> Option<NavigationTarget> { |
116 | visitor() | 116 | visitor() |
117 | .visit(|node: &ast::StructDef| NavigationTarget::from_named(file_id, node)) | 117 | .visit(|node: &ast::StructDef| { |
118 | .visit(|node: &ast::EnumDef| NavigationTarget::from_named(file_id, node)) | 118 | NavigationTarget::from_named(file_id, node, node.doc_comment_text()) |
119 | .visit(|node: &ast::EnumVariant| NavigationTarget::from_named(file_id, node)) | 119 | }) |
120 | .visit(|node: &ast::FnDef| NavigationTarget::from_named(file_id, node)) | 120 | .visit(|node: &ast::EnumDef| { |
121 | .visit(|node: &ast::TypeAliasDef| NavigationTarget::from_named(file_id, node)) | 121 | NavigationTarget::from_named(file_id, node, node.doc_comment_text()) |
122 | .visit(|node: &ast::ConstDef| NavigationTarget::from_named(file_id, node)) | 122 | }) |
123 | .visit(|node: &ast::StaticDef| NavigationTarget::from_named(file_id, node)) | 123 | .visit(|node: &ast::EnumVariant| { |
124 | .visit(|node: &ast::TraitDef| NavigationTarget::from_named(file_id, node)) | 124 | NavigationTarget::from_named(file_id, node, node.doc_comment_text()) |
125 | .visit(|node: &ast::NamedFieldDef| NavigationTarget::from_named(file_id, node)) | 125 | }) |
126 | .visit(|node: &ast::Module| NavigationTarget::from_named(file_id, node)) | 126 | .visit(|node: &ast::FnDef| { |
127 | .visit(|node: &ast::MacroCall| NavigationTarget::from_named(file_id, node)) | 127 | NavigationTarget::from_named(file_id, node, node.doc_comment_text()) |
128 | }) | ||
129 | .visit(|node: &ast::TypeAliasDef| { | ||
130 | NavigationTarget::from_named(file_id, node, node.doc_comment_text()) | ||
131 | }) | ||
132 | .visit(|node: &ast::ConstDef| { | ||
133 | NavigationTarget::from_named(file_id, node, node.doc_comment_text()) | ||
134 | }) | ||
135 | .visit(|node: &ast::StaticDef| { | ||
136 | NavigationTarget::from_named(file_id, node, node.doc_comment_text()) | ||
137 | }) | ||
138 | .visit(|node: &ast::TraitDef| { | ||
139 | NavigationTarget::from_named(file_id, node, node.doc_comment_text()) | ||
140 | }) | ||
141 | .visit(|node: &ast::NamedFieldDef| { | ||
142 | NavigationTarget::from_named(file_id, node, node.doc_comment_text()) | ||
143 | }) | ||
144 | .visit(|node: &ast::Module| { | ||
145 | NavigationTarget::from_named(file_id, node, node.doc_comment_text()) | ||
146 | }) | ||
147 | .visit(|node: &ast::MacroCall| { | ||
148 | NavigationTarget::from_named(file_id, node, node.doc_comment_text()) | ||
149 | }) | ||
128 | .accept(node) | 150 | .accept(node) |
129 | } | 151 | } |
130 | 152 | ||