aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ssr
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ssr')
-rw-r--r--crates/ra_ssr/Cargo.toml2
-rw-r--r--crates/ra_ssr/src/lib.rs2
-rw-r--r--crates/ra_ssr/src/matching.rs8
-rw-r--r--crates/ra_ssr/src/nester.rs2
-rw-r--r--crates/ra_ssr/src/parsing.rs4
-rw-r--r--crates/ra_ssr/src/replacing.rs8
-rw-r--r--crates/ra_ssr/src/resolving.rs8
-rw-r--r--crates/ra_ssr/src/search.rs2
8 files changed, 18 insertions, 18 deletions
diff --git a/crates/ra_ssr/Cargo.toml b/crates/ra_ssr/Cargo.toml
index d0f2ae733..958baa2df 100644
--- a/crates/ra_ssr/Cargo.toml
+++ b/crates/ra_ssr/Cargo.toml
@@ -12,7 +12,7 @@ doctest = false
12 12
13[dependencies] 13[dependencies]
14text_edit = { path = "../text_edit" } 14text_edit = { path = "../text_edit" }
15ra_syntax = { path = "../ra_syntax" } 15syntax = { path = "../syntax" }
16ra_db = { path = "../ra_db" } 16ra_db = { path = "../ra_db" }
17ra_ide_db = { path = "../ra_ide_db" } 17ra_ide_db = { path = "../ra_ide_db" }
18hir = { path = "../ra_hir", package = "ra_hir" } 18hir = { path = "../ra_hir", package = "ra_hir" }
diff --git a/crates/ra_ssr/src/lib.rs b/crates/ra_ssr/src/lib.rs
index c780b460a..fb53212a3 100644
--- a/crates/ra_ssr/src/lib.rs
+++ b/crates/ra_ssr/src/lib.rs
@@ -21,9 +21,9 @@ use crate::matching::MatchFailureReason;
21use hir::Semantics; 21use hir::Semantics;
22use ra_db::{FileId, FilePosition, FileRange}; 22use ra_db::{FileId, FilePosition, FileRange};
23use ra_ide_db::source_change::SourceFileEdit; 23use ra_ide_db::source_change::SourceFileEdit;
24use ra_syntax::{ast, AstNode, SyntaxNode, TextRange};
25use resolving::ResolvedRule; 24use resolving::ResolvedRule;
26use rustc_hash::FxHashMap; 25use rustc_hash::FxHashMap;
26use syntax::{ast, AstNode, SyntaxNode, TextRange};
27 27
28// A structured search replace rule. Create by calling `parse` on a str. 28// A structured search replace rule. Create by calling `parse` on a str.
29#[derive(Debug)] 29#[derive(Debug)]
diff --git a/crates/ra_ssr/src/matching.rs b/crates/ra_ssr/src/matching.rs
index 0f72fea69..125bf3895 100644
--- a/crates/ra_ssr/src/matching.rs
+++ b/crates/ra_ssr/src/matching.rs
@@ -8,10 +8,10 @@ use crate::{
8}; 8};
9use hir::Semantics; 9use hir::Semantics;
10use ra_db::FileRange; 10use ra_db::FileRange;
11use ra_syntax::ast::{AstNode, AstToken};
12use ra_syntax::{ast, SyntaxElement, SyntaxElementChildren, SyntaxKind, SyntaxNode, SyntaxToken};
13use rustc_hash::FxHashMap; 11use rustc_hash::FxHashMap;
14use std::{cell::Cell, iter::Peekable}; 12use std::{cell::Cell, iter::Peekable};
13use syntax::ast::{AstNode, AstToken};
14use syntax::{ast, SyntaxElement, SyntaxElementChildren, SyntaxKind, SyntaxNode, SyntaxToken};
15use test_utils::mark; 15use test_utils::mark;
16 16
17// Creates a match error. If we're currently attempting to match some code that we thought we were 17// Creates a match error. If we're currently attempting to match some code that we thought we were
@@ -264,7 +264,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
264 &self, 264 &self,
265 phase: &mut Phase, 265 phase: &mut Phase,
266 pattern: &mut Peekable<PatternIterator>, 266 pattern: &mut Peekable<PatternIterator>,
267 code: &ra_syntax::SyntaxToken, 267 code: &syntax::SyntaxToken,
268 ) -> Result<(), MatchFailed> { 268 ) -> Result<(), MatchFailed> {
269 phase.record_ignored_comments(code); 269 phase.record_ignored_comments(code);
270 // Ignore whitespace and comments. 270 // Ignore whitespace and comments.
@@ -444,7 +444,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
444 &self, 444 &self,
445 phase: &mut Phase, 445 phase: &mut Phase,
446 pattern: &SyntaxNode, 446 pattern: &SyntaxNode,
447 code: &ra_syntax::SyntaxNode, 447 code: &syntax::SyntaxNode,
448 ) -> Result<(), MatchFailed> { 448 ) -> Result<(), MatchFailed> {
449 let mut pattern = PatternIterator::new(pattern).peekable(); 449 let mut pattern = PatternIterator::new(pattern).peekable();
450 let mut children = code.children_with_tokens(); 450 let mut children = code.children_with_tokens();
diff --git a/crates/ra_ssr/src/nester.rs b/crates/ra_ssr/src/nester.rs
index b3e20579b..8be570d3c 100644
--- a/crates/ra_ssr/src/nester.rs
+++ b/crates/ra_ssr/src/nester.rs
@@ -8,8 +8,8 @@
8//! middle match would take the second `foo` from the outer match. 8//! middle match would take the second `foo` from the outer match.
9 9
10use crate::{Match, SsrMatches}; 10use crate::{Match, SsrMatches};
11use ra_syntax::SyntaxNode;
12use rustc_hash::FxHashMap; 11use rustc_hash::FxHashMap;
12use syntax::SyntaxNode;
13 13
14pub(crate) fn nest_and_remove_collisions( 14pub(crate) fn nest_and_remove_collisions(
15 mut matches: Vec<Match>, 15 mut matches: Vec<Match>,
diff --git a/crates/ra_ssr/src/parsing.rs b/crates/ra_ssr/src/parsing.rs
index f455eb5b7..9570e96e3 100644
--- a/crates/ra_ssr/src/parsing.rs
+++ b/crates/ra_ssr/src/parsing.rs
@@ -7,9 +7,9 @@
7 7
8use crate::errors::bail; 8use crate::errors::bail;
9use crate::{SsrError, SsrPattern, SsrRule}; 9use crate::{SsrError, SsrPattern, SsrRule};
10use ra_syntax::{ast, AstNode, SmolStr, SyntaxKind, SyntaxNode, T};
11use rustc_hash::{FxHashMap, FxHashSet}; 10use rustc_hash::{FxHashMap, FxHashSet};
12use std::str::FromStr; 11use std::str::FromStr;
12use syntax::{ast, AstNode, SmolStr, SyntaxKind, SyntaxNode, T};
13use test_utils::mark; 13use test_utils::mark;
14 14
15#[derive(Debug)] 15#[derive(Debug)]
@@ -243,7 +243,7 @@ fn validate_rule(rule: &SsrRule) -> Result<(), SsrError> {
243 243
244fn tokenize(source: &str) -> Result<Vec<Token>, SsrError> { 244fn tokenize(source: &str) -> Result<Vec<Token>, SsrError> {
245 let mut start = 0; 245 let mut start = 0;
246 let (raw_tokens, errors) = ra_syntax::tokenize(source); 246 let (raw_tokens, errors) = syntax::tokenize(source);
247 if let Some(first_error) = errors.first() { 247 if let Some(first_error) = errors.first() {
248 bail!("Failed to parse pattern: {}", first_error); 248 bail!("Failed to parse pattern: {}", first_error);
249 } 249 }
diff --git a/crates/ra_ssr/src/replacing.rs b/crates/ra_ssr/src/replacing.rs
index 74f9e7db6..8f8fe6149 100644
--- a/crates/ra_ssr/src/replacing.rs
+++ b/crates/ra_ssr/src/replacing.rs
@@ -2,9 +2,9 @@
2 2
3use crate::matching::Var; 3use crate::matching::Var;
4use crate::{resolving::ResolvedRule, Match, SsrMatches}; 4use crate::{resolving::ResolvedRule, Match, SsrMatches};
5use ra_syntax::ast::{self, AstToken};
6use ra_syntax::{SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize};
7use rustc_hash::{FxHashMap, FxHashSet}; 5use rustc_hash::{FxHashMap, FxHashSet};
6use syntax::ast::{self, AstToken};
7use syntax::{SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize};
8use text_edit::TextEdit; 8use text_edit::TextEdit;
9 9
10/// Returns a text edit that will replace each match in `matches` with its corresponding replacement 10/// Returns a text edit that will replace each match in `matches` with its corresponding replacement
@@ -92,7 +92,7 @@ impl ReplacementRenderer<'_> {
92 } 92 }
93 93
94 fn render_node(&mut self, node: &SyntaxNode) { 94 fn render_node(&mut self, node: &SyntaxNode) {
95 use ra_syntax::ast::AstNode; 95 use syntax::ast::AstNode;
96 if let Some(mod_path) = self.match_info.rendered_template_paths.get(&node) { 96 if let Some(mod_path) = self.match_info.rendered_template_paths.get(&node) {
97 self.out.push_str(&mod_path.to_string()); 97 self.out.push_str(&mod_path.to_string());
98 // Emit everything except for the segment's name-ref, since we already effectively 98 // Emit everything except for the segment's name-ref, since we already effectively
@@ -180,7 +180,7 @@ impl ReplacementRenderer<'_> {
180} 180}
181 181
182fn parse_as_kind(code: &str, kind: SyntaxKind) -> Option<SyntaxNode> { 182fn parse_as_kind(code: &str, kind: SyntaxKind) -> Option<SyntaxNode> {
183 use ra_syntax::ast::AstNode; 183 use syntax::ast::AstNode;
184 if ast::Expr::can_cast(kind) { 184 if ast::Expr::can_cast(kind) {
185 if let Ok(expr) = ast::Expr::parse(code) { 185 if let Ok(expr) = ast::Expr::parse(code) {
186 return Some(expr.syntax().clone()); 186 return Some(expr.syntax().clone());
diff --git a/crates/ra_ssr/src/resolving.rs b/crates/ra_ssr/src/resolving.rs
index d53bd46c7..7e7585c8b 100644
--- a/crates/ra_ssr/src/resolving.rs
+++ b/crates/ra_ssr/src/resolving.rs
@@ -4,8 +4,8 @@ use crate::errors::error;
4use crate::{parsing, SsrError}; 4use crate::{parsing, SsrError};
5use parsing::Placeholder; 5use parsing::Placeholder;
6use ra_db::FilePosition; 6use ra_db::FilePosition;
7use ra_syntax::{ast, SmolStr, SyntaxKind, SyntaxNode, SyntaxToken};
8use rustc_hash::FxHashMap; 7use rustc_hash::FxHashMap;
8use syntax::{ast, SmolStr, SyntaxKind, SyntaxNode, SyntaxToken};
9use test_utils::mark; 9use test_utils::mark;
10 10
11pub(crate) struct ResolutionScope<'db> { 11pub(crate) struct ResolutionScope<'db> {
@@ -70,7 +70,7 @@ struct Resolver<'a, 'db> {
70 70
71impl Resolver<'_, '_> { 71impl Resolver<'_, '_> {
72 fn resolve_pattern_tree(&self, pattern: SyntaxNode) -> Result<ResolvedPattern, SsrError> { 72 fn resolve_pattern_tree(&self, pattern: SyntaxNode) -> Result<ResolvedPattern, SsrError> {
73 use ra_syntax::{SyntaxElement, T}; 73 use syntax::{SyntaxElement, T};
74 let mut resolved_paths = FxHashMap::default(); 74 let mut resolved_paths = FxHashMap::default();
75 self.resolve(pattern.clone(), 0, &mut resolved_paths)?; 75 self.resolve(pattern.clone(), 0, &mut resolved_paths)?;
76 let ufcs_function_calls = resolved_paths 76 let ufcs_function_calls = resolved_paths
@@ -108,7 +108,7 @@ impl Resolver<'_, '_> {
108 depth: u32, 108 depth: u32,
109 resolved_paths: &mut FxHashMap<SyntaxNode, ResolvedPath>, 109 resolved_paths: &mut FxHashMap<SyntaxNode, ResolvedPath>,
110 ) -> Result<(), SsrError> { 110 ) -> Result<(), SsrError> {
111 use ra_syntax::ast::AstNode; 111 use syntax::ast::AstNode;
112 if let Some(path) = ast::Path::cast(node.clone()) { 112 if let Some(path) = ast::Path::cast(node.clone()) {
113 if is_self(&path) { 113 if is_self(&path) {
114 // Self cannot be resolved like other paths. 114 // Self cannot be resolved like other paths.
@@ -179,7 +179,7 @@ impl<'db> ResolutionScope<'db> {
179 sema: &hir::Semantics<'db, ra_ide_db::RootDatabase>, 179 sema: &hir::Semantics<'db, ra_ide_db::RootDatabase>,
180 resolve_context: FilePosition, 180 resolve_context: FilePosition,
181 ) -> ResolutionScope<'db> { 181 ) -> ResolutionScope<'db> {
182 use ra_syntax::ast::AstNode; 182 use syntax::ast::AstNode;
183 let file = sema.parse(resolve_context.file_id); 183 let file = sema.parse(resolve_context.file_id);
184 // Find a node at the requested position, falling back to the whole file. 184 // Find a node at the requested position, falling back to the whole file.
185 let node = file 185 let node = file
diff --git a/crates/ra_ssr/src/search.rs b/crates/ra_ssr/src/search.rs
index 85ffa2ac2..e44e14959 100644
--- a/crates/ra_ssr/src/search.rs
+++ b/crates/ra_ssr/src/search.rs
@@ -10,8 +10,8 @@ use ra_ide_db::{
10 defs::Definition, 10 defs::Definition,
11 search::{Reference, SearchScope}, 11 search::{Reference, SearchScope},
12}; 12};
13use ra_syntax::{ast, AstNode, SyntaxKind, SyntaxNode};
14use rustc_hash::FxHashSet; 13use rustc_hash::FxHashSet;
14use syntax::{ast, AstNode, SyntaxKind, SyntaxNode};
15use test_utils::mark; 15use test_utils::mark;
16 16
17/// A cache for the results of find_usages. This is for when we have multiple patterns that have the 17/// A cache for the results of find_usages. This is for when we have multiple patterns that have the