+
+ let mut process_expansion_for_token =
+ |queue: &mut Vec<_>, file_id, item, token: InFile<&_>| {
+ let mapped_tokens = cache
+ .entry(file_id)
+ .or_insert_with(|| file_id.expansion_info(self.db.upcast()))
+ .as_ref()?
+ .map_token_down(self.db.upcast(), item, token)?;
+
+ let len = queue.len();
+ // requeue the tokens we got from mapping our current token down
+ queue.extend(mapped_tokens.inspect(|token| {
+ if let Some(parent) = token.value.parent() {
+ self.cache(find_root(&parent), token.file_id);
+ }
+ }));
+ // if the length changed we have found a mapping for the token
+ (queue.len() != len).then(|| ())
+ };
+