aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/display
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/display')
-rw-r--r--crates/ra_ide_api/src/display/navigation_target.rs30
1 files changed, 20 insertions, 10 deletions
diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs
index 7ea336c50..1c694cbc9 100644
--- a/crates/ra_ide_api/src/display/navigation_target.rs
+++ b/crates/ra_ide_api/src/display/navigation_target.rs
@@ -5,7 +5,7 @@ use ra_syntax::{
5 ast::{self, NameOwner, VisibilityOwner, TypeAscriptionOwner}, 5 ast::{self, NameOwner, VisibilityOwner, TypeAscriptionOwner},
6 algo::visit::{visitor, Visitor}, 6 algo::visit::{visitor, Visitor},
7}; 7};
8use hir::{ModuleSource, FieldSource, ImplItem, Either}; 8use hir::{ModuleSource, FieldSource, ImplItem};
9 9
10use crate::{FileSymbol, db::RootDatabase}; 10use crate::{FileSymbol, db::RootDatabase};
11 11
@@ -77,17 +77,12 @@ impl NavigationTarget {
77 pub(crate) fn from_pat( 77 pub(crate) fn from_pat(
78 db: &RootDatabase, 78 db: &RootDatabase,
79 file_id: FileId, 79 file_id: FileId,
80 pat: Either<AstPtr<ast::Pat>, AstPtr<ast::SelfParam>>, 80 pat: AstPtr<ast::Pat>,
81 ) -> NavigationTarget { 81 ) -> NavigationTarget {
82 let file = db.parse(file_id); 82 let file = db.parse(file_id);
83 let (name, full_range) = match pat { 83 let (name, full_range) = match pat.to_node(file.syntax()).kind() {
84 Either::A(pat) => match pat.to_node(file.syntax()).kind() { 84 ast::PatKind::BindPat(pat) => return NavigationTarget::from_bind_pat(file_id, &pat),
85 ast::PatKind::BindPat(pat) => { 85 _ => ("_".into(), pat.syntax_node_ptr().range()),
86 return NavigationTarget::from_bind_pat(file_id, &pat)
87 }
88 _ => ("_".into(), pat.syntax_node_ptr().range()),
89 },
90 Either::B(slf) => ("self".into(), slf.syntax_node_ptr().range()),
91 }; 86 };
92 NavigationTarget { 87 NavigationTarget {
93 file_id, 88 file_id,
@@ -99,6 +94,21 @@ impl NavigationTarget {
99 } 94 }
100 } 95 }
101 96
97 pub(crate) fn from_self_param(
98 file_id: FileId,
99 par: AstPtr<ast::SelfParam>,
100 ) -> NavigationTarget {
101 let (name, full_range) = ("self".into(), par.syntax_node_ptr().range());
102 NavigationTarget {
103 file_id,
104 name,
105 full_range,
106 focus_range: None,
107 kind: NAME,
108 container_name: None,
109 }
110 }
111
102 pub(crate) fn from_module(db: &RootDatabase, module: hir::Module) -> NavigationTarget { 112 pub(crate) fn from_module(db: &RootDatabase, module: hir::Module) -> NavigationTarget {
103 let (file_id, source) = module.definition_source(db); 113 let (file_id, source) = module.definition_source(db);
104 let file_id = file_id.as_original_file(); 114 let file_id = file_id.as_original_file();