diff options
Diffstat (limited to 'crates/ra_ide')
26 files changed, 43 insertions, 113 deletions
diff --git a/crates/ra_ide/Cargo.toml b/crates/ra_ide/Cargo.toml index 1af51f3ae..8519e9cca 100644 --- a/crates/ra_ide/Cargo.toml +++ b/crates/ra_ide/Cargo.toml | |||
@@ -24,16 +24,16 @@ stdx = { path = "../stdx" } | |||
24 | syntax = { path = "../syntax" } | 24 | syntax = { path = "../syntax" } |
25 | text_edit = { path = "../text_edit" } | 25 | text_edit = { path = "../text_edit" } |
26 | base_db = { path = "../base_db" } | 26 | base_db = { path = "../base_db" } |
27 | ra_ide_db = { path = "../ra_ide_db" } | 27 | ide_db = { path = "../ide_db" } |
28 | cfg = { path = "../cfg" } | 28 | cfg = { path = "../cfg" } |
29 | profile = { path = "../profile" } | 29 | profile = { path = "../profile" } |
30 | test_utils = { path = "../test_utils" } | 30 | test_utils = { path = "../test_utils" } |
31 | ra_assists = { path = "../ra_assists" } | 31 | ra_assists = { path = "../ra_assists" } |
32 | ra_ssr = { path = "../ra_ssr" } | 32 | ssr = { path = "../ssr" } |
33 | 33 | ||
34 | # ra_ide should depend only on the top-level `hir` package. if you need | 34 | # ra_ide should depend only on the top-level `hir` package. if you need |
35 | # something from some `hir_xxx` subpackage, reexport the API via `hir`. | 35 | # something from some `hir_xxx` subpackage, reexport the API via `hir`. |
36 | hir = { path = "../ra_hir", package = "ra_hir" } | 36 | hir = { path = "../hir" } |
37 | 37 | ||
38 | [dev-dependencies] | 38 | [dev-dependencies] |
39 | expect = { path = "../expect" } | 39 | expect = { path = "../expect" } |
diff --git a/crates/ra_ide/src/call_hierarchy.rs b/crates/ra_ide/src/call_hierarchy.rs index 3578b8d3c..58e26b94c 100644 --- a/crates/ra_ide/src/call_hierarchy.rs +++ b/crates/ra_ide/src/call_hierarchy.rs | |||
@@ -3,7 +3,7 @@ | |||
3 | use indexmap::IndexMap; | 3 | use indexmap::IndexMap; |
4 | 4 | ||
5 | use hir::Semantics; | 5 | use hir::Semantics; |
6 | use ra_ide_db::RootDatabase; | 6 | use ide_db::RootDatabase; |
7 | use syntax::{ast, match_ast, AstNode, TextRange}; | 7 | use syntax::{ast, match_ast, AstNode, TextRange}; |
8 | 8 | ||
9 | use crate::{ | 9 | use crate::{ |
diff --git a/crates/ra_ide/src/call_info.rs b/crates/ra_ide/src/call_info.rs index 703cbc6b4..86abd2d8c 100644 --- a/crates/ra_ide/src/call_info.rs +++ b/crates/ra_ide/src/call_info.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | use either::Either; | 2 | use either::Either; |
3 | use hir::{Docs, HirDisplay, Semantics, Type}; | 3 | use hir::{Docs, HirDisplay, Semantics, Type}; |
4 | use ra_ide_db::RootDatabase; | 4 | use ide_db::RootDatabase; |
5 | use stdx::format_to; | 5 | use stdx::format_to; |
6 | use syntax::{ | 6 | use syntax::{ |
7 | ast::{self, ArgListOwner}, | 7 | ast::{self, ArgListOwner}, |
diff --git a/crates/ra_ide/src/completion.rs b/crates/ra_ide/src/completion.rs index 68ac05e4c..7fb4d687e 100644 --- a/crates/ra_ide/src/completion.rs +++ b/crates/ra_ide/src/completion.rs | |||
@@ -19,7 +19,7 @@ mod complete_postfix; | |||
19 | mod complete_macro_in_item_position; | 19 | mod complete_macro_in_item_position; |
20 | mod complete_trait_impl; | 20 | mod complete_trait_impl; |
21 | 21 | ||
22 | use ra_ide_db::RootDatabase; | 22 | use ide_db::RootDatabase; |
23 | 23 | ||
24 | use crate::{ | 24 | use crate::{ |
25 | completion::{ | 25 | completion::{ |
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index 0e0a201d0..047ecd9d7 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | use base_db::SourceDatabase; | 3 | use base_db::SourceDatabase; |
4 | use hir::{Semantics, SemanticsScope, Type}; | 4 | use hir::{Semantics, SemanticsScope, Type}; |
5 | use ra_ide_db::RootDatabase; | 5 | use ide_db::RootDatabase; |
6 | use syntax::{ | 6 | use syntax::{ |
7 | algo::{find_covering_element, find_node_at_offset}, | 7 | algo::{find_covering_element, find_node_at_offset}, |
8 | ast, match_ast, AstNode, NodeOrToken, | 8 | ast, match_ast, AstNode, NodeOrToken, |
diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs index 4e59e3a48..a3ec98178 100644 --- a/crates/ra_ide/src/diagnostics.rs +++ b/crates/ra_ide/src/diagnostics.rs | |||
@@ -8,8 +8,8 @@ use std::cell::RefCell; | |||
8 | 8 | ||
9 | use base_db::SourceDatabase; | 9 | use base_db::SourceDatabase; |
10 | use hir::{diagnostics::DiagnosticSinkBuilder, Semantics}; | 10 | use hir::{diagnostics::DiagnosticSinkBuilder, Semantics}; |
11 | use ide_db::RootDatabase; | ||
11 | use itertools::Itertools; | 12 | use itertools::Itertools; |
12 | use ra_ide_db::RootDatabase; | ||
13 | use syntax::{ | 13 | use syntax::{ |
14 | ast::{self, AstNode}, | 14 | ast::{self, AstNode}, |
15 | SyntaxNode, TextRange, T, | 15 | SyntaxNode, TextRange, T, |
diff --git a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs index 7e126d7a6..85b46c995 100644 --- a/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs +++ b/crates/ra_ide/src/diagnostics/diagnostics_with_fix.rs | |||
@@ -8,7 +8,7 @@ use hir::{ | |||
8 | diagnostics::{Diagnostic, MissingFields, MissingOkInTailExpr, NoSuchField, UnresolvedModule}, | 8 | diagnostics::{Diagnostic, MissingFields, MissingOkInTailExpr, NoSuchField, UnresolvedModule}, |
9 | HasSource, HirDisplay, Semantics, VariantDef, | 9 | HasSource, HirDisplay, Semantics, VariantDef, |
10 | }; | 10 | }; |
11 | use ra_ide_db::{ | 11 | use ide_db::{ |
12 | source_change::{FileSystemEdit, SourceFileEdit}, | 12 | source_change::{FileSystemEdit, SourceFileEdit}, |
13 | RootDatabase, | 13 | RootDatabase, |
14 | }; | 14 | }; |
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index 09ec3f65e..e77106177 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs | |||
@@ -3,7 +3,7 @@ | |||
3 | use base_db::{FileId, SourceDatabase}; | 3 | use base_db::{FileId, SourceDatabase}; |
4 | use either::Either; | 4 | use either::Either; |
5 | use hir::{original_range, AssocItem, FieldSource, HasSource, InFile, ModuleSource}; | 5 | use hir::{original_range, AssocItem, FieldSource, HasSource, InFile, ModuleSource}; |
6 | use ra_ide_db::{defs::Definition, RootDatabase}; | 6 | use ide_db::{defs::Definition, RootDatabase}; |
7 | use syntax::{ | 7 | use syntax::{ |
8 | ast::{self, DocCommentsOwner, NameOwner}, | 8 | ast::{self, DocCommentsOwner, NameOwner}, |
9 | match_ast, AstNode, SmolStr, | 9 | match_ast, AstNode, SmolStr, |
diff --git a/crates/ra_ide/src/expand_macro.rs b/crates/ra_ide/src/expand_macro.rs index c25e068d6..31455709d 100644 --- a/crates/ra_ide/src/expand_macro.rs +++ b/crates/ra_ide/src/expand_macro.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use hir::Semantics; | 1 | use hir::Semantics; |
2 | use ra_ide_db::RootDatabase; | 2 | use ide_db::RootDatabase; |
3 | use syntax::{ | 3 | use syntax::{ |
4 | algo::{find_node_at_offset, SyntaxRewriter}, | 4 | algo::{find_node_at_offset, SyntaxRewriter}, |
5 | ast, AstNode, NodeOrToken, SyntaxKind, | 5 | ast, AstNode, NodeOrToken, SyntaxKind, |
diff --git a/crates/ra_ide/src/extend_selection.rs b/crates/ra_ide/src/extend_selection.rs index f30df2bff..34563a026 100644 --- a/crates/ra_ide/src/extend_selection.rs +++ b/crates/ra_ide/src/extend_selection.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use std::iter::successors; | 1 | use std::iter::successors; |
2 | 2 | ||
3 | use hir::Semantics; | 3 | use hir::Semantics; |
4 | use ra_ide_db::RootDatabase; | 4 | use ide_db::RootDatabase; |
5 | use syntax::{ | 5 | use syntax::{ |
6 | algo::{self, find_covering_element, skip_trivia_token}, | 6 | algo::{self, find_covering_element, skip_trivia_token}, |
7 | ast::{self, AstNode, AstToken}, | 7 | ast::{self, AstNode, AstToken}, |
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index b93d116bf..15e9b7fad 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use hir::Semantics; | 1 | use hir::Semantics; |
2 | use ra_ide_db::{ | 2 | use ide_db::{ |
3 | defs::{classify_name, classify_name_ref}, | 3 | defs::{classify_name, classify_name_ref}, |
4 | symbol_index, RootDatabase, | 4 | symbol_index, RootDatabase, |
5 | }; | 5 | }; |
diff --git a/crates/ra_ide/src/goto_implementation.rs b/crates/ra_ide/src/goto_implementation.rs index 6dc2ccfd0..f503f4ec5 100644 --- a/crates/ra_ide/src/goto_implementation.rs +++ b/crates/ra_ide/src/goto_implementation.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use hir::{Crate, ImplDef, Semantics}; | 1 | use hir::{Crate, ImplDef, Semantics}; |
2 | use ra_ide_db::RootDatabase; | 2 | use ide_db::RootDatabase; |
3 | use syntax::{algo::find_node_at_offset, ast, AstNode}; | 3 | use syntax::{algo::find_node_at_offset, ast, AstNode}; |
4 | 4 | ||
5 | use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo}; | 5 | use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo}; |
diff --git a/crates/ra_ide/src/goto_type_definition.rs b/crates/ra_ide/src/goto_type_definition.rs index 8017ca58c..4a151b150 100644 --- a/crates/ra_ide/src/goto_type_definition.rs +++ b/crates/ra_ide/src/goto_type_definition.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use ra_ide_db::RootDatabase; | 1 | use ide_db::RootDatabase; |
2 | use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; | 2 | use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; |
3 | 3 | ||
4 | use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo}; | 4 | use crate::{display::ToNav, FilePosition, NavigationTarget, RangeInfo}; |
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index a74087f87..331aa4db0 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs | |||
@@ -3,11 +3,11 @@ use hir::{ | |||
3 | Adt, AsAssocItem, AssocItemContainer, Documentation, FieldSource, HasSource, HirDisplay, | 3 | Adt, AsAssocItem, AssocItemContainer, Documentation, FieldSource, HasSource, HirDisplay, |
4 | Module, ModuleDef, ModuleSource, Semantics, | 4 | Module, ModuleDef, ModuleSource, Semantics, |
5 | }; | 5 | }; |
6 | use itertools::Itertools; | 6 | use ide_db::{ |
7 | use ra_ide_db::{ | ||
8 | defs::{classify_name, classify_name_ref, Definition}, | 7 | defs::{classify_name, classify_name_ref, Definition}, |
9 | RootDatabase, | 8 | RootDatabase, |
10 | }; | 9 | }; |
10 | use itertools::Itertools; | ||
11 | use stdx::format_to; | 11 | use stdx::format_to; |
12 | use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; | 12 | use syntax::{ast, match_ast, AstNode, SyntaxKind::*, SyntaxToken, TokenAtOffset, T}; |
13 | use test_utils::mark; | 13 | use test_utils::mark; |
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 81fe274ad..002adf915 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use hir::{Adt, Callable, HirDisplay, Semantics, Type}; | 1 | use hir::{Adt, Callable, HirDisplay, Semantics, Type}; |
2 | use ra_ide_db::RootDatabase; | 2 | use ide_db::RootDatabase; |
3 | use stdx::to_lower_snake_case; | 3 | use stdx::to_lower_snake_case; |
4 | use syntax::{ | 4 | use syntax::{ |
5 | ast::{self, ArgListOwner, AstNode}, | 5 | ast::{self, ArgListOwner, AstNode}, |
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 789fbdaf2..bbc9e4b8a 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs | |||
@@ -3,7 +3,7 @@ | |||
3 | //! Strings, suitable for displaying to the human. | 3 | //! Strings, suitable for displaying to the human. |
4 | //! | 4 | //! |
5 | //! What powers this API are the `RootDatabase` struct, which defines a `salsa` | 5 | //! What powers this API are the `RootDatabase` struct, which defines a `salsa` |
6 | //! database, and the `ra_hir` crate, where majority of the analysis happens. | 6 | //! database, and the `hir` crate, where majority of the analysis happens. |
7 | //! However, IDE specific bits of the analysis (most notably completion) happen | 7 | //! However, IDE specific bits of the analysis (most notably completion) happen |
8 | //! in this crate. | 8 | //! in this crate. |
9 | 9 | ||
@@ -39,7 +39,6 @@ mod matching_brace; | |||
39 | mod parent_module; | 39 | mod parent_module; |
40 | mod references; | 40 | mod references; |
41 | mod runnables; | 41 | mod runnables; |
42 | mod ssr; | ||
43 | mod status; | 42 | mod status; |
44 | mod syntax_highlighting; | 43 | mod syntax_highlighting; |
45 | mod syntax_tree; | 44 | mod syntax_tree; |
@@ -52,7 +51,7 @@ use base_db::{ | |||
52 | CheckCanceled, Env, FileLoader, FileSet, SourceDatabase, VfsPath, | 51 | CheckCanceled, Env, FileLoader, FileSet, SourceDatabase, VfsPath, |
53 | }; | 52 | }; |
54 | use cfg::CfgOptions; | 53 | use cfg::CfgOptions; |
55 | use ra_ide_db::{ | 54 | use ide_db::{ |
56 | symbol_index::{self, FileSymbol}, | 55 | symbol_index::{self, FileSymbol}, |
57 | LineIndexDatabase, | 56 | LineIndexDatabase, |
58 | }; | 57 | }; |
@@ -86,8 +85,7 @@ pub use base_db::{ | |||
86 | SourceRootId, | 85 | SourceRootId, |
87 | }; | 86 | }; |
88 | pub use hir::{Documentation, Semantics}; | 87 | pub use hir::{Documentation, Semantics}; |
89 | pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist}; | 88 | pub use ide_db::{ |
90 | pub use ra_ide_db::{ | ||
91 | change::AnalysisChange, | 89 | change::AnalysisChange, |
92 | line_index::{LineCol, LineIndex}, | 90 | line_index::{LineCol, LineIndex}, |
93 | search::SearchScope, | 91 | search::SearchScope, |
@@ -95,7 +93,8 @@ pub use ra_ide_db::{ | |||
95 | symbol_index::Query, | 93 | symbol_index::Query, |
96 | RootDatabase, | 94 | RootDatabase, |
97 | }; | 95 | }; |
98 | pub use ra_ssr::SsrError; | 96 | pub use ra_assists::{Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist}; |
97 | pub use ssr::SsrError; | ||
99 | pub use text_edit::{Indel, TextEdit}; | 98 | pub use text_edit::{Indel, TextEdit}; |
100 | 99 | ||
101 | pub type Cancelable<T> = Result<T, Canceled>; | 100 | pub type Cancelable<T> = Result<T, Canceled>; |
@@ -515,20 +514,23 @@ impl Analysis { | |||
515 | &self, | 514 | &self, |
516 | query: &str, | 515 | query: &str, |
517 | parse_only: bool, | 516 | parse_only: bool, |
518 | position: FilePosition, | 517 | resolve_context: FilePosition, |
519 | selections: Vec<FileRange>, | 518 | selections: Vec<FileRange>, |
520 | ) -> Cancelable<Result<SourceChange, SsrError>> { | 519 | ) -> Cancelable<Result<SourceChange, SsrError>> { |
521 | self.with_db(|db| { | 520 | self.with_db(|db| { |
522 | let edits = ssr::parse_search_replace(query, parse_only, db, position, selections)?; | 521 | let rule: ssr::SsrRule = query.parse()?; |
522 | let mut match_finder = ssr::MatchFinder::in_context(db, resolve_context, selections); | ||
523 | match_finder.add_rule(rule)?; | ||
524 | let edits = if parse_only { Vec::new() } else { match_finder.edits() }; | ||
523 | Ok(SourceChange::from(edits)) | 525 | Ok(SourceChange::from(edits)) |
524 | }) | 526 | }) |
525 | } | 527 | } |
526 | 528 | ||
527 | /// Performs an operation on that may be Canceled. | 529 | /// Performs an operation on that may be Canceled. |
528 | fn with_db<F: FnOnce(&RootDatabase) -> T + std::panic::UnwindSafe, T>( | 530 | fn with_db<F, T>(&self, f: F) -> Cancelable<T> |
529 | &self, | 531 | where |
530 | f: F, | 532 | F: FnOnce(&RootDatabase) -> T + std::panic::UnwindSafe, |
531 | ) -> Cancelable<T> { | 533 | { |
532 | self.db.catch_canceled(f) | 534 | self.db.catch_canceled(f) |
533 | } | 535 | } |
534 | } | 536 | } |
diff --git a/crates/ra_ide/src/parent_module.rs b/crates/ra_ide/src/parent_module.rs index 8439e1d5d..59ed2967c 100644 --- a/crates/ra_ide/src/parent_module.rs +++ b/crates/ra_ide/src/parent_module.rs | |||
@@ -1,6 +1,6 @@ | |||
1 | use base_db::{CrateId, FileId, FilePosition}; | 1 | use base_db::{CrateId, FileId, FilePosition}; |
2 | use hir::Semantics; | 2 | use hir::Semantics; |
3 | use ra_ide_db::RootDatabase; | 3 | use ide_db::RootDatabase; |
4 | use syntax::{ | 4 | use syntax::{ |
5 | algo::find_node_at_offset, | 5 | algo::find_node_at_offset, |
6 | ast::{self, AstNode}, | 6 | ast::{self, AstNode}, |
diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index e89dca869..0a76ec6b4 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs | |||
@@ -12,7 +12,7 @@ | |||
12 | mod rename; | 12 | mod rename; |
13 | 13 | ||
14 | use hir::Semantics; | 14 | use hir::Semantics; |
15 | use ra_ide_db::{ | 15 | use ide_db::{ |
16 | defs::{classify_name, classify_name_ref, Definition}, | 16 | defs::{classify_name, classify_name_ref, Definition}, |
17 | search::SearchScope, | 17 | search::SearchScope, |
18 | RootDatabase, | 18 | RootDatabase, |
@@ -27,7 +27,7 @@ use crate::{display::TryToNav, FilePosition, FileRange, NavigationTarget, RangeI | |||
27 | 27 | ||
28 | pub(crate) use self::rename::rename; | 28 | pub(crate) use self::rename::rename; |
29 | 29 | ||
30 | pub use ra_ide_db::search::{Reference, ReferenceAccess, ReferenceKind}; | 30 | pub use ide_db::search::{Reference, ReferenceAccess, ReferenceKind}; |
31 | 31 | ||
32 | #[derive(Debug, Clone)] | 32 | #[derive(Debug, Clone)] |
33 | pub struct ReferenceSearchResult { | 33 | pub struct ReferenceSearchResult { |
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs index 5697b9d87..d73dc9cd0 100644 --- a/crates/ra_ide/src/references/rename.rs +++ b/crates/ra_ide/src/references/rename.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | 2 | ||
3 | use base_db::SourceDatabaseExt; | 3 | use base_db::SourceDatabaseExt; |
4 | use hir::{Module, ModuleDef, ModuleSource, Semantics}; | 4 | use hir::{Module, ModuleDef, ModuleSource, Semantics}; |
5 | use ra_ide_db::{ | 5 | use ide_db::{ |
6 | defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, | 6 | defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, |
7 | RootDatabase, | 7 | RootDatabase, |
8 | }; | 8 | }; |
diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs index fb40762cf..c3e07c8de 100644 --- a/crates/ra_ide/src/runnables.rs +++ b/crates/ra_ide/src/runnables.rs | |||
@@ -2,8 +2,8 @@ use std::fmt; | |||
2 | 2 | ||
3 | use cfg::CfgExpr; | 3 | use cfg::CfgExpr; |
4 | use hir::{AsAssocItem, Attrs, HirFileId, InFile, Semantics}; | 4 | use hir::{AsAssocItem, Attrs, HirFileId, InFile, Semantics}; |
5 | use ide_db::RootDatabase; | ||
5 | use itertools::Itertools; | 6 | use itertools::Itertools; |
6 | use ra_ide_db::RootDatabase; | ||
7 | use syntax::{ | 7 | use syntax::{ |
8 | ast::{self, AstNode, AttrsOwner, DocCommentsOwner, ModuleItemOwner, NameOwner}, | 8 | ast::{self, AstNode, AttrsOwner, DocCommentsOwner, ModuleItemOwner, NameOwner}, |
9 | match_ast, SyntaxNode, | 9 | match_ast, SyntaxNode, |
diff --git a/crates/ra_ide/src/ssr.rs b/crates/ra_ide/src/ssr.rs deleted file mode 100644 index 97b82b70e..000000000 --- a/crates/ra_ide/src/ssr.rs +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | use base_db::{FilePosition, FileRange}; | ||
2 | use ra_ide_db::RootDatabase; | ||
3 | |||
4 | use crate::SourceFileEdit; | ||
5 | use ra_ssr::{MatchFinder, SsrError, SsrRule}; | ||
6 | |||
7 | // Feature: Structural Search and Replace | ||
8 | // | ||
9 | // Search and replace with named wildcards that will match any expression, type, path, pattern or item. | ||
10 | // The syntax for a structural search replace command is `<search_pattern> ==>> <replace_pattern>`. | ||
11 | // A `$<name>` placeholder in the search pattern will match any AST node and `$<name>` will reference it in the replacement. | ||
12 | // Within a macro call, a placeholder will match up until whatever token follows the placeholder. | ||
13 | // | ||
14 | // All paths in both the search pattern and the replacement template must resolve in the context | ||
15 | // in which this command is invoked. Paths in the search pattern will then match the code if they | ||
16 | // resolve to the same item, even if they're written differently. For example if we invoke the | ||
17 | // command in the module `foo` with a pattern of `Bar`, then code in the parent module that refers | ||
18 | // to `foo::Bar` will match. | ||
19 | // | ||
20 | // Paths in the replacement template will be rendered appropriately for the context in which the | ||
21 | // replacement occurs. For example if our replacement template is `foo::Bar` and we match some | ||
22 | // code in the `foo` module, we'll insert just `Bar`. | ||
23 | // | ||
24 | // Inherent method calls should generally be written in UFCS form. e.g. `foo::Bar::baz($s, $a)` will | ||
25 | // match `$s.baz($a)`, provided the method call `baz` resolves to the method `foo::Bar::baz`. | ||
26 | // | ||
27 | // The scope of the search / replace will be restricted to the current selection if any, otherwise | ||
28 | // it will apply to the whole workspace. | ||
29 | // | ||
30 | // Placeholders may be given constraints by writing them as `${<name>:<constraint1>:<constraint2>...}`. | ||
31 | // | ||
32 | // Supported constraints: | ||
33 | // | ||
34 | // |=== | ||
35 | // | Constraint | Restricts placeholder | ||
36 | // | ||
37 | // | kind(literal) | Is a literal (e.g. `42` or `"forty two"`) | ||
38 | // | not(a) | Negates the constraint `a` | ||
39 | // |=== | ||
40 | // | ||
41 | // Available via the command `rust-analyzer.ssr`. | ||
42 | // | ||
43 | // ```rust | ||
44 | // // Using structural search replace command [foo($a, $b) ==>> ($a).foo($b)] | ||
45 | // | ||
46 | // // BEFORE | ||
47 | // String::from(foo(y + 5, z)) | ||
48 | // | ||
49 | // // AFTER | ||
50 | // String::from((y + 5).foo(z)) | ||
51 | // ``` | ||
52 | // | ||
53 | // |=== | ||
54 | // | Editor | Action Name | ||
55 | // | ||
56 | // | VS Code | **Rust Analyzer: Structural Search Replace** | ||
57 | // |=== | ||
58 | pub fn parse_search_replace( | ||
59 | rule: &str, | ||
60 | parse_only: bool, | ||
61 | db: &RootDatabase, | ||
62 | resolve_context: FilePosition, | ||
63 | selections: Vec<FileRange>, | ||
64 | ) -> Result<Vec<SourceFileEdit>, SsrError> { | ||
65 | let rule: SsrRule = rule.parse()?; | ||
66 | let mut match_finder = MatchFinder::in_context(db, resolve_context, selections); | ||
67 | match_finder.add_rule(rule)?; | ||
68 | if parse_only { | ||
69 | return Ok(Vec::new()); | ||
70 | } | ||
71 | Ok(match_finder.edits()) | ||
72 | } | ||
diff --git a/crates/ra_ide/src/status.rs b/crates/ra_ide/src/status.rs index 869c74acc..c23708181 100644 --- a/crates/ra_ide/src/status.rs +++ b/crates/ra_ide/src/status.rs | |||
@@ -5,11 +5,11 @@ use base_db::{ | |||
5 | FileTextQuery, SourceRootId, | 5 | FileTextQuery, SourceRootId, |
6 | }; | 6 | }; |
7 | use hir::MacroFile; | 7 | use hir::MacroFile; |
8 | use profile::{memory_usage, Bytes}; | 8 | use ide_db::{ |
9 | use ra_ide_db::{ | ||
10 | symbol_index::{LibrarySymbolsQuery, SymbolIndex}, | 9 | symbol_index::{LibrarySymbolsQuery, SymbolIndex}, |
11 | RootDatabase, | 10 | RootDatabase, |
12 | }; | 11 | }; |
12 | use profile::{memory_usage, Bytes}; | ||
13 | use rustc_hash::FxHashMap; | 13 | use rustc_hash::FxHashMap; |
14 | use syntax::{ast, Parse, SyntaxNode}; | 14 | use syntax::{ast, Parse, SyntaxNode}; |
15 | 15 | ||
diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 4b41ceb1d..5d7c7e8d0 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs | |||
@@ -5,7 +5,7 @@ mod injection; | |||
5 | mod tests; | 5 | mod tests; |
6 | 6 | ||
7 | use hir::{Name, Semantics, VariantDef}; | 7 | use hir::{Name, Semantics, VariantDef}; |
8 | use ra_ide_db::{ | 8 | use ide_db::{ |
9 | defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, | 9 | defs::{classify_name, classify_name_ref, Definition, NameClass, NameRefClass}, |
10 | RootDatabase, | 10 | RootDatabase, |
11 | }; | 11 | }; |
diff --git a/crates/ra_ide/src/syntax_tree.rs b/crates/ra_ide/src/syntax_tree.rs index 17daf06b6..f80044959 100644 --- a/crates/ra_ide/src/syntax_tree.rs +++ b/crates/ra_ide/src/syntax_tree.rs | |||
@@ -1,5 +1,5 @@ | |||
1 | use base_db::{FileId, SourceDatabase}; | 1 | use base_db::{FileId, SourceDatabase}; |
2 | use ra_ide_db::RootDatabase; | 2 | use ide_db::RootDatabase; |
3 | use syntax::{ | 3 | use syntax::{ |
4 | algo, AstNode, NodeOrToken, SourceFile, | 4 | algo, AstNode, NodeOrToken, SourceFile, |
5 | SyntaxKind::{RAW_STRING, STRING}, | 5 | SyntaxKind::{RAW_STRING, STRING}, |
diff --git a/crates/ra_ide/src/typing.rs b/crates/ra_ide/src/typing.rs index 75f2a6b60..899ce5f26 100644 --- a/crates/ra_ide/src/typing.rs +++ b/crates/ra_ide/src/typing.rs | |||
@@ -16,7 +16,7 @@ | |||
16 | mod on_enter; | 16 | mod on_enter; |
17 | 17 | ||
18 | use base_db::{FilePosition, SourceDatabase}; | 18 | use base_db::{FilePosition, SourceDatabase}; |
19 | use ra_ide_db::{source_change::SourceFileEdit, RootDatabase}; | 19 | use ide_db::{source_change::SourceFileEdit, RootDatabase}; |
20 | use syntax::{ | 20 | use syntax::{ |
21 | algo::find_node_at_offset, | 21 | algo::find_node_at_offset, |
22 | ast::{self, edit::IndentLevel, AstToken}, | 22 | ast::{self, edit::IndentLevel, AstToken}, |
diff --git a/crates/ra_ide/src/typing/on_enter.rs b/crates/ra_ide/src/typing/on_enter.rs index 193930659..f7d46146c 100644 --- a/crates/ra_ide/src/typing/on_enter.rs +++ b/crates/ra_ide/src/typing/on_enter.rs | |||
@@ -2,7 +2,7 @@ | |||
2 | //! comments, but should handle indent some time in the future as well. | 2 | //! comments, but should handle indent some time in the future as well. |
3 | 3 | ||
4 | use base_db::{FilePosition, SourceDatabase}; | 4 | use base_db::{FilePosition, SourceDatabase}; |
5 | use ra_ide_db::RootDatabase; | 5 | use ide_db::RootDatabase; |
6 | use syntax::{ | 6 | use syntax::{ |
7 | ast::{self, AstToken}, | 7 | ast::{self, AstToken}, |
8 | AstNode, SmolStr, SourceFile, | 8 | AstNode, SmolStr, SourceFile, |