aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
authorice1000 <[email protected]>2019-12-03 20:24:02 +0000
committerice1000 <[email protected]>2019-12-04 23:30:42 +0000
commit38853459e3d964cc7f635829cdc66f5faee33d85 (patch)
treec4e60a8f5fa9c18915e8aed7857424d454cd130e /crates/ra_ide/src
parent7cbedc50bcf048c87f141a85418581076d67fc7a (diff)
Add `ModuleSource::Block`
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/display/navigation_target.rs43
-rw-r--r--crates/ra_ide/src/references/rename.rs2
-rw-r--r--crates/ra_ide/src/references/search_scope.rs5
3 files changed, 21 insertions, 29 deletions
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs
index f920d3db6..b376fcdae 100644
--- a/crates/ra_ide/src/display/navigation_target.rs
+++ b/crates/ra_ide/src/display/navigation_target.rs
@@ -231,34 +231,21 @@ impl ToNav for hir::Module {
231 fn to_nav(&self, db: &RootDatabase) -> NavigationTarget { 231 fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
232 let src = self.definition_source(db); 232 let src = self.definition_source(db);
233 let name = self.name(db).map(|it| it.to_string().into()).unwrap_or_default(); 233 let name = self.name(db).map(|it| it.to_string().into()).unwrap_or_default();
234 match &src.value { 234 let syntax = match &src.value {
235 ModuleSource::SourceFile(node) => { 235 ModuleSource::SourceFile(node) => node.syntax(),
236 let frange = original_range(db, src.with_value(node.syntax())); 236 ModuleSource::Module(node) => node.syntax(),
237 237 ModuleSource::Block(node) => node.syntax(),
238 NavigationTarget::from_syntax( 238 };
239 frange.file_id, 239 let frange = original_range(db, src.with_value(syntax));
240 name, 240 NavigationTarget::from_syntax(
241 None, 241 frange.file_id,
242 frange.range, 242 name,
243 node.syntax().kind(), 243 None,
244 None, 244 frange.range,
245 None, 245 syntax.kind(),
246 ) 246 None,
247 } 247 None,
248 ModuleSource::Module(node) => { 248 )
249 let frange = original_range(db, src.with_value(node.syntax()));
250
251 NavigationTarget::from_syntax(
252 frange.file_id,
253 name,
254 None,
255 frange.range,
256 node.syntax().kind(),
257 node.doc_comment_text(),
258 node.short_label(),
259 )
260 }
261 }
262 } 249 }
263} 250}
264 251
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs
index b804d5f6d..1abf20215 100644
--- a/crates/ra_ide/src/references/rename.rs
+++ b/crates/ra_ide/src/references/rename.rs
@@ -88,7 +88,7 @@ fn rename_mod(
88 file_system_edits.push(move_file); 88 file_system_edits.push(move_file);
89 } 89 }
90 } 90 }
91 ModuleSource::Module(..) => {} 91 ModuleSource::Module(..) | ModuleSource::Block(..) => {}
92 } 92 }
93 } 93 }
94 94
diff --git a/crates/ra_ide/src/references/search_scope.rs b/crates/ra_ide/src/references/search_scope.rs
index f5c9589f4..92eb2015b 100644
--- a/crates/ra_ide/src/references/search_scope.rs
+++ b/crates/ra_ide/src/references/search_scope.rs
@@ -96,6 +96,10 @@ impl NameDefinition {
96 let range = Some(m.syntax().text_range()); 96 let range = Some(m.syntax().text_range());
97 res.insert(file_id, range); 97 res.insert(file_id, range);
98 } 98 }
99 ModuleSource::Block(b) => {
100 let range = Some(b.syntax().text_range());
101 res.insert(file_id, range);
102 }
99 ModuleSource::SourceFile(_) => { 103 ModuleSource::SourceFile(_) => {
100 res.insert(file_id, None); 104 res.insert(file_id, None);
101 res.extend(parent_module.children(db).map(|m| { 105 res.extend(parent_module.children(db).map(|m| {
@@ -137,6 +141,7 @@ impl NameDefinition {
137 let mut res = FxHashMap::default(); 141 let mut res = FxHashMap::default();
138 let range = match module_src.value { 142 let range = match module_src.value {
139 ModuleSource::Module(m) => Some(m.syntax().text_range()), 143 ModuleSource::Module(m) => Some(m.syntax().text_range()),
144 ModuleSource::Block(b) => Some(b.syntax().text_range()),
140 ModuleSource::SourceFile(_) => None, 145 ModuleSource::SourceFile(_) => None,
141 }; 146 };
142 res.insert(file_id, range); 147 res.insert(file_id, range);