aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ssr/src/matching.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ssr/src/matching.rs')
-rw-r--r--crates/ra_ssr/src/matching.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/crates/ra_ssr/src/matching.rs b/crates/ra_ssr/src/matching.rs
index 064e3a204..005569f6f 100644
--- a/crates/ra_ssr/src/matching.rs
+++ b/crates/ra_ssr/src/matching.rs
@@ -49,6 +49,8 @@ pub struct Match {
49 pub(crate) placeholder_values: FxHashMap<Var, PlaceholderMatch>, 49 pub(crate) placeholder_values: FxHashMap<Var, PlaceholderMatch>,
50 pub(crate) ignored_comments: Vec<ast::Comment>, 50 pub(crate) ignored_comments: Vec<ast::Comment>,
51 pub(crate) rule_index: usize, 51 pub(crate) rule_index: usize,
52 /// The depth of matched_node.
53 pub(crate) depth: usize,
52} 54}
53 55
54/// Represents a `$var` in an SSR query. 56/// Represents a `$var` in an SSR query.
@@ -130,10 +132,12 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
130 placeholder_values: FxHashMap::default(), 132 placeholder_values: FxHashMap::default(),
131 ignored_comments: Vec::new(), 133 ignored_comments: Vec::new(),
132 rule_index: rule.index, 134 rule_index: rule.index,
135 depth: 0,
133 }; 136 };
134 // Second matching pass, where we record placeholder matches, ignored comments and maybe do 137 // Second matching pass, where we record placeholder matches, ignored comments and maybe do
135 // any other more expensive checks that we didn't want to do on the first pass. 138 // any other more expensive checks that we didn't want to do on the first pass.
136 match_state.attempt_match_node(&mut Phase::Second(&mut the_match), &rule.pattern, code)?; 139 match_state.attempt_match_node(&mut Phase::Second(&mut the_match), &rule.pattern, code)?;
140 the_match.depth = sema.ancestors_with_macros(the_match.matched_node.clone()).count();
137 Ok(the_match) 141 Ok(the_match)
138 } 142 }
139 143