aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ssr/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ssr/src/lib.rs')
-rw-r--r--crates/ra_ssr/src/lib.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/crates/ra_ssr/src/lib.rs b/crates/ra_ssr/src/lib.rs
index 3009dcb93..b28913a65 100644
--- a/crates/ra_ssr/src/lib.rs
+++ b/crates/ra_ssr/src/lib.rs
@@ -15,7 +15,6 @@ pub use crate::errors::SsrError;
15pub use crate::matching::Match; 15pub use crate::matching::Match;
16use crate::matching::MatchFailureReason; 16use crate::matching::MatchFailureReason;
17use hir::Semantics; 17use hir::Semantics;
18use parsing::SsrTemplate;
19use ra_db::{FileId, FileRange}; 18use ra_db::{FileId, FileRange};
20use ra_syntax::{ast, AstNode, SyntaxNode, TextRange}; 19use ra_syntax::{ast, AstNode, SyntaxNode, TextRange};
21use ra_text_edit::TextEdit; 20use ra_text_edit::TextEdit;
@@ -26,7 +25,7 @@ pub struct SsrRule {
26 /// A structured pattern that we're searching for. 25 /// A structured pattern that we're searching for.
27 pattern: parsing::RawPattern, 26 pattern: parsing::RawPattern,
28 /// What we'll replace it with. 27 /// What we'll replace it with.
29 template: SsrTemplate, 28 template: parsing::RawPattern,
30 parsed_rules: Vec<parsing::ParsedRule>, 29 parsed_rules: Vec<parsing::ParsedRule>,
31} 30}
32 31
@@ -72,7 +71,11 @@ impl<'db> MatchFinder<'db> {
72 None 71 None
73 } else { 72 } else {
74 use ra_db::SourceDatabaseExt; 73 use ra_db::SourceDatabaseExt;
75 Some(replacing::matches_to_edit(&matches, &self.sema.db.file_text(file_id))) 74 Some(replacing::matches_to_edit(
75 &matches,
76 &self.sema.db.file_text(file_id),
77 &self.rules,
78 ))
76 } 79 }
77 } 80 }
78 81
@@ -111,9 +114,8 @@ impl<'db> MatchFinder<'db> {
111 } 114 }
112 115
113 fn add_parsed_rules(&mut self, parsed_rules: Vec<parsing::ParsedRule>) { 116 fn add_parsed_rules(&mut self, parsed_rules: Vec<parsing::ParsedRule>) {
114 // FIXME: This doesn't need to be a for loop, but does in a subsequent commit. Justify it 117 for mut parsed_rule in parsed_rules {
115 // being a for-loop. 118 parsed_rule.index = self.rules.len();
116 for parsed_rule in parsed_rules {
117 self.rules.push(parsed_rule); 119 self.rules.push(parsed_rule);
118 } 120 }
119 } 121 }