aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/path.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/path.rs')
-rw-r--r--crates/ra_hir/src/path.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/crates/ra_hir/src/path.rs b/crates/ra_hir/src/path.rs
index 4a2e427cd..e04d00900 100644
--- a/crates/ra_hir/src/path.rs
+++ b/crates/ra_hir/src/path.rs
@@ -76,17 +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 expand_use_tree(prefix.clone(), child_tree, cb);
87 } 90 }
88 } else { 91 } else {
89 if let Some(ast_path) = tree.path() { 92 if let Some(ast_path) = tree.path() {
93 // Handle self in a path.
94 // E.g. `use something::{self, <...>}`
95 if ast_path.qualifier().is_none() {
96 if let Some(segment) = ast_path.segment() {
97 if segment.kind() == Some(ast::PathSegmentKind::SelfKw) {
98 if let Some(prefix) = prefix {
99 cb(prefix, Some(segment.syntax().range()));
100 return;
101 }
102 }
103 }
104 }
90 if let Some(path) = convert_path(prefix, ast_path) { 105 if let Some(path) = convert_path(prefix, ast_path) {
91 let range = if tree.has_star() { 106 let range = if tree.has_star() {
92 None 107 None
@@ -96,6 +111,8 @@ fn expand_use_tree(
96 }; 111 };
97 cb(path, range) 112 cb(path, range)
98 } 113 }
114 // TODO: report errors somewhere
115 // We get here if we do
99 } 116 }
100 } 117 }
101} 118}