diff options
Diffstat (limited to 'crates/ra_analysis/src/descriptors/path.rs')
-rw-r--r-- | crates/ra_analysis/src/descriptors/path.rs | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/crates/ra_analysis/src/descriptors/path.rs b/crates/ra_analysis/src/descriptors/path.rs index 99fca18b1..8279daf4b 100644 --- a/crates/ra_analysis/src/descriptors/path.rs +++ b/crates/ra_analysis/src/descriptors/path.rs | |||
@@ -1,6 +1,4 @@ | |||
1 | use ra_syntax::{SmolStr, ast, AstNode}; | 1 | use ra_syntax::{SmolStr, ast, AstNode, TextRange}; |
2 | |||
3 | use crate::syntax_ptr::LocalSyntaxPtr; | ||
4 | 2 | ||
5 | #[derive(Debug, Clone, PartialEq, Eq)] | 3 | #[derive(Debug, Clone, PartialEq, Eq)] |
6 | pub(crate) struct Path { | 4 | pub(crate) struct Path { |
@@ -18,10 +16,7 @@ pub(crate) enum PathKind { | |||
18 | 16 | ||
19 | impl Path { | 17 | impl Path { |
20 | /// Calls `cb` with all paths, represented by this use item. | 18 | /// Calls `cb` with all paths, represented by this use item. |
21 | pub(crate) fn expand_use_item( | 19 | pub(crate) fn expand_use_item(item: ast::UseItem, mut cb: impl FnMut(Path, Option<TextRange>)) { |
22 | item: ast::UseItem, | ||
23 | mut cb: impl FnMut(Path, Option<LocalSyntaxPtr>), | ||
24 | ) { | ||
25 | if let Some(tree) = item.use_tree() { | 20 | if let Some(tree) = item.use_tree() { |
26 | expand_use_tree(None, tree, &mut cb); | 21 | expand_use_tree(None, tree, &mut cb); |
27 | } | 22 | } |
@@ -77,7 +72,7 @@ impl Path { | |||
77 | fn expand_use_tree( | 72 | fn expand_use_tree( |
78 | prefix: Option<Path>, | 73 | prefix: Option<Path>, |
79 | tree: ast::UseTree, | 74 | tree: ast::UseTree, |
80 | cb: &mut impl FnMut(Path, Option<LocalSyntaxPtr>), | 75 | cb: &mut impl FnMut(Path, Option<TextRange>), |
81 | ) { | 76 | ) { |
82 | if let Some(use_tree_list) = tree.use_tree_list() { | 77 | if let Some(use_tree_list) = tree.use_tree_list() { |
83 | let prefix = match tree.path() { | 78 | let prefix = match tree.path() { |
@@ -93,13 +88,13 @@ fn expand_use_tree( | |||
93 | } else { | 88 | } else { |
94 | if let Some(ast_path) = tree.path() { | 89 | if let Some(ast_path) = tree.path() { |
95 | if let Some(path) = convert_path(prefix, ast_path) { | 90 | if let Some(path) = convert_path(prefix, ast_path) { |
96 | let ptr = if tree.has_star() { | 91 | let range = if tree.has_star() { |
97 | None | 92 | None |
98 | } else { | 93 | } else { |
99 | let ptr = LocalSyntaxPtr::new(ast_path.segment().unwrap().syntax()); | 94 | let range = ast_path.segment().unwrap().syntax().range(); |
100 | Some(ptr) | 95 | Some(range) |
101 | }; | 96 | }; |
102 | cb(path, ptr) | 97 | cb(path, range) |
103 | } | 98 | } |
104 | } | 99 | } |
105 | } | 100 | } |