aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_tt/src
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-05-28 07:03:47 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-05-28 07:03:47 +0100
commit0545e4781d3aba3083835cfa8afab07b7442a3aa (patch)
treea74609717cd2e986057ac9e9c3a0f70088ec5682 /crates/ra_tt/src
parentb2bf41b2bac48edd53e3059adfba4a12b3c96aa0 (diff)
parent464a00814cf604a57c77ce456d1ca2677eb4e61a (diff)
Merge #1336
1336: Refactor SubtreeSource r=matklad a=edwin0cheng This PR simplify `SubtreeSource` by removing `SubtreeWalk` and `Querier` and only walk through the top level `TokenTree` when collecting token from source, by comparing two cursors directly. Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_tt/src')
-rw-r--r--crates/ra_tt/src/buffer.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/ra_tt/src/buffer.rs b/crates/ra_tt/src/buffer.rs
index 56b844b8b..940f2b807 100644
--- a/crates/ra_tt/src/buffer.rs
+++ b/crates/ra_tt/src/buffer.rs
@@ -166,4 +166,19 @@ impl<'a> Cursor<'a> {
166 Cursor::create(self.buffer, EntryPtr(self.ptr.0, self.ptr.1 + 1)) 166 Cursor::create(self.buffer, EntryPtr(self.ptr.0, self.ptr.1 + 1))
167 } 167 }
168 } 168 }
169
170 /// Bump the cursor, if it is a subtree, returns
171 /// a cursor into that subtree
172 pub fn bump_subtree(self) -> Cursor<'a> {
173 match self.entry() {
174 Some(Entry::Subtree(_, _)) => self.subtree().unwrap(),
175 _ => self.bump(),
176 }
177 }
178
179 /// Check whether it is a top level
180 pub fn is_root(&self) -> bool {
181 let entry_id = self.ptr.0;
182 return entry_id.0 == 0;
183 }
169} 184}