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.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/crates/ra_ssr/src/matching.rs b/crates/ra_ssr/src/matching.rs
index 842f4b6f3..486191635 100644
--- a/crates/ra_ssr/src/matching.rs
+++ b/crates/ra_ssr/src/matching.rs
@@ -2,7 +2,7 @@
2//! process of matching, placeholder values are recorded. 2//! process of matching, placeholder values are recorded.
3 3
4use crate::{ 4use crate::{
5 parsing::{Constraint, NodeKind, ParsedRule, Placeholder, SsrTemplate}, 5 parsing::{Constraint, NodeKind, ParsedRule, Placeholder},
6 SsrMatches, 6 SsrMatches,
7}; 7};
8use hir::Semantics; 8use hir::Semantics;
@@ -48,9 +48,7 @@ pub struct Match {
48 pub(crate) matched_node: SyntaxNode, 48 pub(crate) matched_node: SyntaxNode,
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 // A copy of the template for the rule that produced this match. We store this on the match for 51 pub(crate) rule_index: usize,
52 // if/when we do replacement.
53 pub(crate) template: Option<SsrTemplate>,
54} 52}
55 53
56/// Represents a `$var` in an SSR query. 54/// Represents a `$var` in an SSR query.
@@ -131,7 +129,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
131 matched_node: code.clone(), 129 matched_node: code.clone(),
132 placeholder_values: FxHashMap::default(), 130 placeholder_values: FxHashMap::default(),
133 ignored_comments: Vec::new(), 131 ignored_comments: Vec::new(),
134 template: rule.template.clone(), 132 rule_index: rule.index,
135 }; 133 };
136 // Second matching pass, where we record placeholder matches, ignored comments and maybe do 134 // Second matching pass, where we record placeholder matches, ignored comments and maybe do
137 // any other more expensive checks that we didn't want to do on the first pass. 135 // any other more expensive checks that we didn't want to do on the first pass.
@@ -591,7 +589,7 @@ mod tests {
591 "1+2" 589 "1+2"
592 ); 590 );
593 591
594 let edit = crate::replacing::matches_to_edit(&matches, input); 592 let edit = crate::replacing::matches_to_edit(&matches, input, &match_finder.rules);
595 let mut after = input.to_string(); 593 let mut after = input.to_string();
596 edit.apply(&mut after); 594 edit.apply(&mut after);
597 assert_eq!(after, "fn foo() {} fn main() { bar(1+2); }"); 595 assert_eq!(after, "fn foo() {} fn main() { bar(1+2); }");