diff options
author | Edwin Cheng <[email protected]> | 2019-11-08 20:00:27 +0000 |
---|---|---|
committer | Edwin Cheng <[email protected]> | 2019-11-08 20:26:28 +0000 |
commit | d01e0abdb57c5be340934cb51e2f6b1a2e6c0373 (patch) | |
tree | 837abe3c0c20d35040fd8f21c34e093e16cd09db /crates/ra_ide_api/src | |
parent | 62ed93db13877888379ea38c843729419bdf99d0 (diff) |
Refactor and simpfily
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r-- | crates/ra_ide_api/src/display/navigation_target.rs | 5 | ||||
-rw-r--r-- | crates/ra_ide_api/src/status.rs | 4 |
2 files changed, 3 insertions, 6 deletions
diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs index b9e3132f4..b77e19231 100644 --- a/crates/ra_ide_api/src/display/navigation_target.rs +++ b/crates/ra_ide_api/src/display/navigation_target.rs | |||
@@ -37,7 +37,7 @@ fn find_range_from_node( | |||
37 | let text_range = node.text_range(); | 37 | let text_range = node.text_range(); |
38 | let (file_id, text_range) = src | 38 | let (file_id, text_range) = src |
39 | .parent_expansion(db) | 39 | .parent_expansion(db) |
40 | .and_then(|(files, expansion_info)| expansion_info.find_range(text_range, files)) | 40 | .and_then(|expansion_info| expansion_info.find_range(text_range)) |
41 | .unwrap_or((src, text_range)); | 41 | .unwrap_or((src, text_range)); |
42 | 42 | ||
43 | // FIXME: handle recursive macro generated macro | 43 | // FIXME: handle recursive macro generated macro |
@@ -139,7 +139,6 @@ impl NavigationTarget { | |||
139 | pub(crate) fn from_module(db: &RootDatabase, module: hir::Module) -> NavigationTarget { | 139 | pub(crate) fn from_module(db: &RootDatabase, module: hir::Module) -> NavigationTarget { |
140 | let src = module.definition_source(db); | 140 | let src = module.definition_source(db); |
141 | let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default(); | 141 | let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default(); |
142 | |||
143 | match src.ast { | 142 | match src.ast { |
144 | ModuleSource::SourceFile(node) => { | 143 | ModuleSource::SourceFile(node) => { |
145 | let (file_id, text_range) = find_range_from_node(db, src.file_id, node.syntax()); | 144 | let (file_id, text_range) = find_range_from_node(db, src.file_id, node.syntax()); |
@@ -324,9 +323,7 @@ impl NavigationTarget { | |||
324 | ) -> NavigationTarget { | 323 | ) -> NavigationTarget { |
325 | //FIXME: use `_` instead of empty string | 324 | //FIXME: use `_` instead of empty string |
326 | let name = node.name().map(|it| it.text().clone()).unwrap_or_default(); | 325 | let name = node.name().map(|it| it.text().clone()).unwrap_or_default(); |
327 | |||
328 | let focus_range = node.name().map(|it| find_range_from_node(db, file_id, it.syntax()).1); | 326 | let focus_range = node.name().map(|it| find_range_from_node(db, file_id, it.syntax()).1); |
329 | |||
330 | let (file_id, full_range) = find_range_from_node(db, file_id, node.syntax()); | 327 | let (file_id, full_range) = find_range_from_node(db, file_id, node.syntax()); |
331 | 328 | ||
332 | NavigationTarget::from_syntax( | 329 | NavigationTarget::from_syntax( |
diff --git a/crates/ra_ide_api/src/status.rs b/crates/ra_ide_api/src/status.rs index f91f16c8e..1bb27eb85 100644 --- a/crates/ra_ide_api/src/status.rs +++ b/crates/ra_ide_api/src/status.rs | |||
@@ -94,10 +94,10 @@ impl FromIterator<TableEntry<FileId, Parse<ast::SourceFile>>> for SyntaxTreeStat | |||
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | impl FromIterator<TableEntry<MacroFile, Option<Parse<SyntaxNode>>>> for SyntaxTreeStats { | 97 | impl<M> FromIterator<TableEntry<MacroFile, Option<(Parse<SyntaxNode>, M)>>> for SyntaxTreeStats { |
98 | fn from_iter<T>(iter: T) -> SyntaxTreeStats | 98 | fn from_iter<T>(iter: T) -> SyntaxTreeStats |
99 | where | 99 | where |
100 | T: IntoIterator<Item = TableEntry<MacroFile, Option<Parse<SyntaxNode>>>>, | 100 | T: IntoIterator<Item = TableEntry<MacroFile, Option<(Parse<SyntaxNode>, M)>>>, |
101 | { | 101 | { |
102 | let mut res = SyntaxTreeStats::default(); | 102 | let mut res = SyntaxTreeStats::default(); |
103 | for entry in iter { | 103 | for entry in iter { |