diff options
Diffstat (limited to 'crates/ra_ssr/src/parsing.rs')
-rw-r--r-- | crates/ra_ssr/src/parsing.rs | 17 |
1 files changed, 1 insertions, 16 deletions
diff --git a/crates/ra_ssr/src/parsing.rs b/crates/ra_ssr/src/parsing.rs index cf7fb517f..2d6f4e514 100644 --- a/crates/ra_ssr/src/parsing.rs +++ b/crates/ra_ssr/src/parsing.rs | |||
@@ -7,7 +7,7 @@ | |||
7 | 7 | ||
8 | use crate::errors::bail; | 8 | use crate::errors::bail; |
9 | use crate::{SsrError, SsrPattern, SsrRule}; | 9 | use crate::{SsrError, SsrPattern, SsrRule}; |
10 | use ra_syntax::{ast, AstNode, SmolStr, SyntaxKind, SyntaxNode, SyntaxToken, T}; | 10 | use ra_syntax::{ast, AstNode, SmolStr, SyntaxKind, SyntaxNode, T}; |
11 | use rustc_hash::{FxHashMap, FxHashSet}; | 11 | use rustc_hash::{FxHashMap, FxHashSet}; |
12 | use std::str::FromStr; | 12 | use std::str::FromStr; |
13 | 13 | ||
@@ -16,7 +16,6 @@ pub(crate) struct ParsedRule { | |||
16 | pub(crate) placeholders_by_stand_in: FxHashMap<SmolStr, Placeholder>, | 16 | pub(crate) placeholders_by_stand_in: FxHashMap<SmolStr, Placeholder>, |
17 | pub(crate) pattern: SyntaxNode, | 17 | pub(crate) pattern: SyntaxNode, |
18 | pub(crate) template: Option<SyntaxNode>, | 18 | pub(crate) template: Option<SyntaxNode>, |
19 | pub(crate) index: usize, | ||
20 | } | 19 | } |
21 | 20 | ||
22 | #[derive(Debug)] | 21 | #[derive(Debug)] |
@@ -93,16 +92,11 @@ impl RuleBuilder { | |||
93 | placeholders_by_stand_in: self.placeholders_by_stand_in.clone(), | 92 | placeholders_by_stand_in: self.placeholders_by_stand_in.clone(), |
94 | pattern: pattern.syntax().clone(), | 93 | pattern: pattern.syntax().clone(), |
95 | template: Some(template.syntax().clone()), | 94 | template: Some(template.syntax().clone()), |
96 | // For now we give the rule an index of 0. It's given a proper index when the rule | ||
97 | // is added to the SsrMatcher. Using an Option<usize>, instead would be slightly | ||
98 | // more correct, but we delete this field from ParsedRule in a subsequent commit. | ||
99 | index: 0, | ||
100 | }), | 95 | }), |
101 | (Ok(pattern), None) => self.rules.push(ParsedRule { | 96 | (Ok(pattern), None) => self.rules.push(ParsedRule { |
102 | placeholders_by_stand_in: self.placeholders_by_stand_in.clone(), | 97 | placeholders_by_stand_in: self.placeholders_by_stand_in.clone(), |
103 | pattern: pattern.syntax().clone(), | 98 | pattern: pattern.syntax().clone(), |
104 | template: None, | 99 | template: None, |
105 | index: 0, | ||
106 | }), | 100 | }), |
107 | _ => {} | 101 | _ => {} |
108 | } | 102 | } |
@@ -171,15 +165,6 @@ impl RawPattern { | |||
171 | } | 165 | } |
172 | } | 166 | } |
173 | 167 | ||
174 | impl ParsedRule { | ||
175 | pub(crate) fn get_placeholder(&self, token: &SyntaxToken) -> Option<&Placeholder> { | ||
176 | if token.kind() != SyntaxKind::IDENT { | ||
177 | return None; | ||
178 | } | ||
179 | self.placeholders_by_stand_in.get(token.text()) | ||
180 | } | ||
181 | } | ||
182 | |||
183 | impl FromStr for SsrPattern { | 168 | impl FromStr for SsrPattern { |
184 | type Err = SsrError; | 169 | type Err = SsrError; |
185 | 170 | ||