aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ssr
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-08-13 15:39:16 +0100
committerAleksey Kladov <[email protected]>2020-08-13 15:39:16 +0100
commitbb5c189b7dae1ea63ccd5d7a0c2e097d7c676f77 (patch)
tree62db93464dbd9ea154a8cb579a576202d97c01cc /crates/ra_ssr
parentae71a631fd657368e8593feb5e025d23147afe60 (diff)
Rename ra_ide_db -> ide_db
Diffstat (limited to 'crates/ra_ssr')
-rw-r--r--crates/ra_ssr/Cargo.toml2
-rw-r--r--crates/ra_ssr/src/lib.rs10
-rw-r--r--crates/ra_ssr/src/matching.rs8
-rw-r--r--crates/ra_ssr/src/nester.rs10
-rw-r--r--crates/ra_ssr/src/resolving.rs2
-rw-r--r--crates/ra_ssr/src/search.rs4
-rw-r--r--crates/ra_ssr/src/tests.rs8
7 files changed, 20 insertions, 24 deletions
diff --git a/crates/ra_ssr/Cargo.toml b/crates/ra_ssr/Cargo.toml
index bed4bbdf1..4d22a8a98 100644
--- a/crates/ra_ssr/Cargo.toml
+++ b/crates/ra_ssr/Cargo.toml
@@ -14,7 +14,7 @@ doctest = false
14text_edit = { path = "../text_edit" } 14text_edit = { path = "../text_edit" }
15syntax = { path = "../syntax" } 15syntax = { path = "../syntax" }
16base_db = { path = "../base_db" } 16base_db = { path = "../base_db" }
17ra_ide_db = { path = "../ra_ide_db" } 17ide_db = { path = "../ide_db" }
18hir = { path = "../hir" } 18hir = { path = "../hir" }
19rustc-hash = "1.1.0" 19rustc-hash = "1.1.0"
20test_utils = { path = "../test_utils" } 20test_utils = { path = "../test_utils" }
diff --git a/crates/ra_ssr/src/lib.rs b/crates/ra_ssr/src/lib.rs
index 6725582e4..b4e35107e 100644
--- a/crates/ra_ssr/src/lib.rs
+++ b/crates/ra_ssr/src/lib.rs
@@ -20,7 +20,7 @@ pub use crate::matching::Match;
20use crate::matching::MatchFailureReason; 20use crate::matching::MatchFailureReason;
21use base_db::{FileId, FilePosition, FileRange}; 21use base_db::{FileId, FilePosition, FileRange};
22use hir::Semantics; 22use hir::Semantics;
23use ra_ide_db::source_change::SourceFileEdit; 23use ide_db::source_change::SourceFileEdit;
24use resolving::ResolvedRule; 24use resolving::ResolvedRule;
25use rustc_hash::FxHashMap; 25use rustc_hash::FxHashMap;
26use syntax::{ast, AstNode, SyntaxNode, TextRange}; 26use syntax::{ast, AstNode, SyntaxNode, TextRange};
@@ -49,7 +49,7 @@ pub struct SsrMatches {
49/// Searches a crate for pattern matches and possibly replaces them with something else. 49/// Searches a crate for pattern matches and possibly replaces them with something else.
50pub struct MatchFinder<'db> { 50pub struct MatchFinder<'db> {
51 /// Our source of information about the user's code. 51 /// Our source of information about the user's code.
52 sema: Semantics<'db, ra_ide_db::RootDatabase>, 52 sema: Semantics<'db, ide_db::RootDatabase>,
53 rules: Vec<ResolvedRule>, 53 rules: Vec<ResolvedRule>,
54 resolution_scope: resolving::ResolutionScope<'db>, 54 resolution_scope: resolving::ResolutionScope<'db>,
55 restrict_ranges: Vec<FileRange>, 55 restrict_ranges: Vec<FileRange>,
@@ -59,7 +59,7 @@ impl<'db> MatchFinder<'db> {
59 /// Constructs a new instance where names will be looked up as if they appeared at 59 /// Constructs a new instance where names will be looked up as if they appeared at
60 /// `lookup_context`. 60 /// `lookup_context`.
61 pub fn in_context( 61 pub fn in_context(
62 db: &'db ra_ide_db::RootDatabase, 62 db: &'db ide_db::RootDatabase,
63 lookup_context: FilePosition, 63 lookup_context: FilePosition,
64 mut restrict_ranges: Vec<FileRange>, 64 mut restrict_ranges: Vec<FileRange>,
65 ) -> MatchFinder<'db> { 65 ) -> MatchFinder<'db> {
@@ -70,9 +70,9 @@ impl<'db> MatchFinder<'db> {
70 } 70 }
71 71
72 /// Constructs an instance using the start of the first file in `db` as the lookup context. 72 /// Constructs an instance using the start of the first file in `db` as the lookup context.
73 pub fn at_first_file(db: &'db ra_ide_db::RootDatabase) -> Result<MatchFinder<'db>, SsrError> { 73 pub fn at_first_file(db: &'db ide_db::RootDatabase) -> Result<MatchFinder<'db>, SsrError> {
74 use base_db::SourceDatabaseExt; 74 use base_db::SourceDatabaseExt;
75 use ra_ide_db::symbol_index::SymbolsDatabase; 75 use ide_db::symbol_index::SymbolsDatabase;
76 if let Some(first_file_id) = db 76 if let Some(first_file_id) = db
77 .local_roots() 77 .local_roots()
78 .iter() 78 .iter()
diff --git a/crates/ra_ssr/src/matching.rs b/crates/ra_ssr/src/matching.rs
index e81a87c47..ffc7202ae 100644
--- a/crates/ra_ssr/src/matching.rs
+++ b/crates/ra_ssr/src/matching.rs
@@ -92,7 +92,7 @@ pub(crate) fn get_match(
92 rule: &ResolvedRule, 92 rule: &ResolvedRule,
93 code: &SyntaxNode, 93 code: &SyntaxNode,
94 restrict_range: &Option<FileRange>, 94 restrict_range: &Option<FileRange>,
95 sema: &Semantics<ra_ide_db::RootDatabase>, 95 sema: &Semantics<ide_db::RootDatabase>,
96) -> Result<Match, MatchFailed> { 96) -> Result<Match, MatchFailed> {
97 record_match_fails_reasons_scope(debug_active, || { 97 record_match_fails_reasons_scope(debug_active, || {
98 Matcher::try_match(rule, code, restrict_range, sema) 98 Matcher::try_match(rule, code, restrict_range, sema)
@@ -101,7 +101,7 @@ pub(crate) fn get_match(
101 101
102/// Checks if our search pattern matches a particular node of the AST. 102/// Checks if our search pattern matches a particular node of the AST.
103struct Matcher<'db, 'sema> { 103struct Matcher<'db, 'sema> {
104 sema: &'sema Semantics<'db, ra_ide_db::RootDatabase>, 104 sema: &'sema Semantics<'db, ide_db::RootDatabase>,
105 /// If any placeholders come from anywhere outside of this range, then the match will be 105 /// If any placeholders come from anywhere outside of this range, then the match will be
106 /// rejected. 106 /// rejected.
107 restrict_range: Option<FileRange>, 107 restrict_range: Option<FileRange>,
@@ -123,7 +123,7 @@ impl<'db, 'sema> Matcher<'db, 'sema> {
123 rule: &ResolvedRule, 123 rule: &ResolvedRule,
124 code: &SyntaxNode, 124 code: &SyntaxNode,
125 restrict_range: &Option<FileRange>, 125 restrict_range: &Option<FileRange>,
126 sema: &'sema Semantics<'db, ra_ide_db::RootDatabase>, 126 sema: &'sema Semantics<'db, ide_db::RootDatabase>,
127 ) -> Result<Match, MatchFailed> { 127 ) -> Result<Match, MatchFailed> {
128 let match_state = Matcher { sema, restrict_range: restrict_range.clone(), rule }; 128 let match_state = Matcher { sema, restrict_range: restrict_range.clone(), rule };
129 // First pass at matching, where we check that node types and idents match. 129 // First pass at matching, where we check that node types and idents match.
@@ -606,7 +606,7 @@ impl Match {
606 fn render_template_paths( 606 fn render_template_paths(
607 &mut self, 607 &mut self,
608 template: &ResolvedPattern, 608 template: &ResolvedPattern,
609 sema: &Semantics<ra_ide_db::RootDatabase>, 609 sema: &Semantics<ide_db::RootDatabase>,
610 ) -> Result<(), MatchFailed> { 610 ) -> Result<(), MatchFailed> {
611 let module = sema 611 let module = sema
612 .scope(&self.matched_node) 612 .scope(&self.matched_node)
diff --git a/crates/ra_ssr/src/nester.rs b/crates/ra_ssr/src/nester.rs
index 8be570d3c..6ac355dfc 100644
--- a/crates/ra_ssr/src/nester.rs
+++ b/crates/ra_ssr/src/nester.rs
@@ -13,7 +13,7 @@ use 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>,
16 sema: &hir::Semantics<ra_ide_db::RootDatabase>, 16 sema: &hir::Semantics<ide_db::RootDatabase>,
17) -> SsrMatches { 17) -> SsrMatches {
18 // We sort the matches by depth then by rule index. Sorting by depth means that by the time we 18 // We sort the matches by depth then by rule index. Sorting by depth means that by the time we
19 // see a match, any parent matches or conflicting matches will have already been seen. Sorting 19 // see a match, any parent matches or conflicting matches will have already been seen. Sorting
@@ -36,7 +36,7 @@ impl MatchCollector {
36 /// Attempts to add `m` to matches. If it conflicts with an existing match, it is discarded. If 36 /// Attempts to add `m` to matches. If it conflicts with an existing match, it is discarded. If
37 /// it is entirely within the a placeholder of an existing match, then it is added as a child 37 /// it is entirely within the a placeholder of an existing match, then it is added as a child
38 /// match of the existing match. 38 /// match of the existing match.
39 fn add_match(&mut self, m: Match, sema: &hir::Semantics<ra_ide_db::RootDatabase>) { 39 fn add_match(&mut self, m: Match, sema: &hir::Semantics<ide_db::RootDatabase>) {
40 let matched_node = m.matched_node.clone(); 40 let matched_node = m.matched_node.clone();
41 if let Some(existing) = self.matches_by_node.get_mut(&matched_node) { 41 if let Some(existing) = self.matches_by_node.get_mut(&matched_node) {
42 try_add_sub_match(m, existing, sema); 42 try_add_sub_match(m, existing, sema);
@@ -53,11 +53,7 @@ impl MatchCollector {
53} 53}
54 54
55/// Attempts to add `m` as a sub-match of `existing`. 55/// Attempts to add `m` as a sub-match of `existing`.
56fn try_add_sub_match( 56fn try_add_sub_match(m: Match, existing: &mut Match, sema: &hir::Semantics<ide_db::RootDatabase>) {
57 m: Match,
58 existing: &mut Match,
59 sema: &hir::Semantics<ra_ide_db::RootDatabase>,
60) {
61 for p in existing.placeholder_values.values_mut() { 57 for p in existing.placeholder_values.values_mut() {
62 // Note, no need to check if p.range.file is equal to m.range.file, since we 58 // Note, no need to check if p.range.file is equal to m.range.file, since we
63 // already know we're within `existing`. 59 // already know we're within `existing`.
diff --git a/crates/ra_ssr/src/resolving.rs b/crates/ra_ssr/src/resolving.rs
index dac09bae8..020fd7994 100644
--- a/crates/ra_ssr/src/resolving.rs
+++ b/crates/ra_ssr/src/resolving.rs
@@ -187,7 +187,7 @@ impl Resolver<'_, '_> {
187 187
188impl<'db> ResolutionScope<'db> { 188impl<'db> ResolutionScope<'db> {
189 pub(crate) fn new( 189 pub(crate) fn new(
190 sema: &hir::Semantics<'db, ra_ide_db::RootDatabase>, 190 sema: &hir::Semantics<'db, ide_db::RootDatabase>,
191 resolve_context: FilePosition, 191 resolve_context: FilePosition,
192 ) -> ResolutionScope<'db> { 192 ) -> ResolutionScope<'db> {
193 use syntax::ast::AstNode; 193 use syntax::ast::AstNode;
diff --git a/crates/ra_ssr/src/search.rs b/crates/ra_ssr/src/search.rs
index 434953fb4..8509cfa4d 100644
--- a/crates/ra_ssr/src/search.rs
+++ b/crates/ra_ssr/src/search.rs
@@ -6,7 +6,7 @@ use crate::{
6 Match, MatchFinder, 6 Match, MatchFinder,
7}; 7};
8use base_db::{FileId, FileRange}; 8use base_db::{FileId, FileRange};
9use ra_ide_db::{ 9use ide_db::{
10 defs::Definition, 10 defs::Definition,
11 search::{Reference, SearchScope}, 11 search::{Reference, SearchScope},
12}; 12};
@@ -146,7 +146,7 @@ impl<'db> MatchFinder<'db> {
146 if self.restrict_ranges.is_empty() { 146 if self.restrict_ranges.is_empty() {
147 // Unrestricted search. 147 // Unrestricted search.
148 use base_db::SourceDatabaseExt; 148 use base_db::SourceDatabaseExt;
149 use ra_ide_db::symbol_index::SymbolsDatabase; 149 use ide_db::symbol_index::SymbolsDatabase;
150 for &root in self.sema.db.local_roots().iter() { 150 for &root in self.sema.db.local_roots().iter() {
151 let sr = self.sema.db.source_root(root); 151 let sr = self.sema.db.source_root(root);
152 for file_id in sr.iter() { 152 for file_id in sr.iter() {
diff --git a/crates/ra_ssr/src/tests.rs b/crates/ra_ssr/src/tests.rs
index 54c3da9db..0d0a00090 100644
--- a/crates/ra_ssr/src/tests.rs
+++ b/crates/ra_ssr/src/tests.rs
@@ -61,13 +61,13 @@ fn parser_undefined_placeholder_in_replacement() {
61 61
62/// `code` may optionally contain a cursor marker `<|>`. If it doesn't, then the position will be 62/// `code` may optionally contain a cursor marker `<|>`. If it doesn't, then the position will be
63/// the start of the file. If there's a second cursor marker, then we'll return a single range. 63/// the start of the file. If there's a second cursor marker, then we'll return a single range.
64pub(crate) fn single_file(code: &str) -> (ra_ide_db::RootDatabase, FilePosition, Vec<FileRange>) { 64pub(crate) fn single_file(code: &str) -> (ide_db::RootDatabase, FilePosition, Vec<FileRange>) {
65 use base_db::fixture::WithFixture; 65 use base_db::fixture::WithFixture;
66 use ra_ide_db::symbol_index::SymbolsDatabase; 66 use ide_db::symbol_index::SymbolsDatabase;
67 let (mut db, file_id, range_or_offset) = if code.contains(test_utils::CURSOR_MARKER) { 67 let (mut db, file_id, range_or_offset) = if code.contains(test_utils::CURSOR_MARKER) {
68 ra_ide_db::RootDatabase::with_range_or_offset(code) 68 ide_db::RootDatabase::with_range_or_offset(code)
69 } else { 69 } else {
70 let (db, file_id) = ra_ide_db::RootDatabase::with_single_file(code); 70 let (db, file_id) = ide_db::RootDatabase::with_single_file(code);
71 (db, file_id, RangeOrOffset::Offset(0.into())) 71 (db, file_id, RangeOrOffset::Offset(0.into()))
72 }; 72 };
73 let selections; 73 let selections;