aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
authorDJMcNab <[email protected]>2018-12-21 23:01:16 +0000
committerDJMcNab <[email protected]>2018-12-21 23:01:16 +0000
commitbb1ee2f13a67342bdb09bcbf8684f6c9627b89e1 (patch)
treebc99c40e8247623f344cb59bdcb3a0a83323810a /crates/ra_hir
parentd8d60215dacc3eeddeda4d6af7007e2129fdb00e (diff)
Move the self handling from directly inside the loop
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/path.rs25
1 files changed, 12 insertions, 13 deletions
diff --git a/crates/ra_hir/src/path.rs b/crates/ra_hir/src/path.rs
index 1b3fb4306..e04d00900 100644
--- a/crates/ra_hir/src/path.rs
+++ b/crates/ra_hir/src/path.rs
@@ -86,25 +86,22 @@ fn expand_use_tree(
86 }, 86 },
87 }; 87 };
88 for child_tree in use_tree_list.use_trees() { 88 for child_tree in use_tree_list.use_trees() {
89 expand_use_tree(prefix.clone(), child_tree, cb);
90 }
91 } else {
92 if let Some(ast_path) = tree.path() {
89 // Handle self in a path. 93 // Handle self in a path.
90 // E.g. `use something::{self, <...>}` 94 // E.g. `use something::{self, <...>}`
91 if let Some(path) = child_tree.path() { 95 if ast_path.qualifier().is_none() {
92 if path.qualifier().is_none() { 96 if let Some(segment) = ast_path.segment() {
93 if let Some(segment) = path.segment() { 97 if segment.kind() == Some(ast::PathSegmentKind::SelfKw) {
94 if segment.kind() == Some(ast::PathSegmentKind::SelfKw) { 98 if let Some(prefix) = prefix {
95 /* TODO: Work out what on earth range means in this callback */ 99 cb(prefix, Some(segment.syntax().range()));
96 if let Some(prefix) = prefix.clone() { 100 return;
97 cb(prefix, Some(segment.syntax().range()));
98 continue;
99 }
100 } 101 }
101 } 102 }
102 } 103 }
103 } 104 }
104 expand_use_tree(prefix.clone(), child_tree, cb);
105 }
106 } else {
107 if let Some(ast_path) = tree.path() {
108 if let Some(path) = convert_path(prefix, ast_path) { 105 if let Some(path) = convert_path(prefix, ast_path) {
109 let range = if tree.has_star() { 106 let range = if tree.has_star() {
110 None 107 None
@@ -114,6 +111,8 @@ fn expand_use_tree(
114 }; 111 };
115 cb(path, range) 112 cb(path, range)
116 } 113 }
114 // TODO: report errors somewhere
115 // We get here if we do
117 } 116 }
118 } 117 }
119} 118}