diff options
Diffstat (limited to 'crates/ra_hir/src/path.rs')
-rw-r--r-- | crates/ra_hir/src/path.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/crates/ra_hir/src/path.rs b/crates/ra_hir/src/path.rs index 4a2e427cd..1b3fb4306 100644 --- a/crates/ra_hir/src/path.rs +++ b/crates/ra_hir/src/path.rs | |||
@@ -76,14 +76,32 @@ fn expand_use_tree( | |||
76 | ) { | 76 | ) { |
77 | if let Some(use_tree_list) = tree.use_tree_list() { | 77 | if let Some(use_tree_list) = tree.use_tree_list() { |
78 | let prefix = match tree.path() { | 78 | let prefix = match tree.path() { |
79 | // E.g. use something::{{{inner}}}; | ||
79 | None => prefix, | 80 | None => prefix, |
81 | // E.g. `use something::{inner}` (prefix is `None`, path is `something`) | ||
82 | // or `use something::{path::{inner::{innerer}}}` (prefix is `something::path`, path is `inner`) | ||
80 | Some(path) => match convert_path(prefix, path) { | 83 | Some(path) => match convert_path(prefix, path) { |
81 | Some(it) => Some(it), | 84 | Some(it) => Some(it), |
82 | None => return, // TODO: report errors somewhere | 85 | None => return, // TODO: report errors somewhere |
83 | }, | 86 | }, |
84 | }; | 87 | }; |
85 | for tree in use_tree_list.use_trees() { | 88 | for child_tree in use_tree_list.use_trees() { |
86 | expand_use_tree(prefix.clone(), tree, cb); | 89 | // Handle self in a path. |
90 | // E.g. `use something::{self, <...>}` | ||
91 | if let Some(path) = child_tree.path() { | ||
92 | if path.qualifier().is_none() { | ||
93 | if let Some(segment) = path.segment() { | ||
94 | if segment.kind() == Some(ast::PathSegmentKind::SelfKw) { | ||
95 | /* TODO: Work out what on earth range means in this callback */ | ||
96 | if let Some(prefix) = prefix.clone() { | ||
97 | cb(prefix, Some(segment.syntax().range())); | ||
98 | continue; | ||
99 | } | ||
100 | } | ||
101 | } | ||
102 | } | ||
103 | } | ||
104 | expand_use_tree(prefix.clone(), child_tree, cb); | ||
87 | } | 105 | } |
88 | } else { | 106 | } else { |
89 | if let Some(ast_path) = tree.path() { | 107 | if let Some(ast_path) = tree.path() { |