From 757f755c29e041fd319af466d7d0418f54cb090a Mon Sep 17 00:00:00 2001 From: David Lattimore Date: Wed, 22 Jul 2020 16:46:29 +1000 Subject: SSR: Match paths based on what they resolve to Also render template paths appropriately for their context. --- crates/ra_ssr/src/parsing.rs | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) (limited to 'crates/ra_ssr/src/parsing.rs') 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 @@ use crate::errors::bail; use crate::{SsrError, SsrPattern, SsrRule}; -use ra_syntax::{ast, AstNode, SmolStr, SyntaxKind, SyntaxNode, SyntaxToken, T}; +use ra_syntax::{ast, AstNode, SmolStr, SyntaxKind, SyntaxNode, T}; use rustc_hash::{FxHashMap, FxHashSet}; use std::str::FromStr; @@ -16,7 +16,6 @@ pub(crate) struct ParsedRule { pub(crate) placeholders_by_stand_in: FxHashMap, pub(crate) pattern: SyntaxNode, pub(crate) template: Option, - pub(crate) index: usize, } #[derive(Debug)] @@ -93,16 +92,11 @@ impl RuleBuilder { placeholders_by_stand_in: self.placeholders_by_stand_in.clone(), pattern: pattern.syntax().clone(), template: Some(template.syntax().clone()), - // For now we give the rule an index of 0. It's given a proper index when the rule - // is added to the SsrMatcher. Using an Option, instead would be slightly - // more correct, but we delete this field from ParsedRule in a subsequent commit. - index: 0, }), (Ok(pattern), None) => self.rules.push(ParsedRule { placeholders_by_stand_in: self.placeholders_by_stand_in.clone(), pattern: pattern.syntax().clone(), template: None, - index: 0, }), _ => {} } @@ -171,15 +165,6 @@ impl RawPattern { } } -impl ParsedRule { - pub(crate) fn get_placeholder(&self, token: &SyntaxToken) -> Option<&Placeholder> { - if token.kind() != SyntaxKind::IDENT { - return None; - } - self.placeholders_by_stand_in.get(token.text()) - } -} - impl FromStr for SsrPattern { type Err = SsrError; -- cgit v1.2.3