aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_assists/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_assists/src')
-rw-r--r--crates/ide_assists/src/lib.rs2
-rw-r--r--crates/ide_assists/src/path_transform.rs (renamed from crates/ide_assists/src/ast_transform.rs)13
-rw-r--r--crates/ide_assists/src/utils.rs4
3 files changed, 7 insertions, 12 deletions
diff --git a/crates/ide_assists/src/lib.rs b/crates/ide_assists/src/lib.rs
index 2e0c58504..05644b6ff 100644
--- a/crates/ide_assists/src/lib.rs
+++ b/crates/ide_assists/src/lib.rs
@@ -15,7 +15,7 @@ mod assist_context;
15#[cfg(test)] 15#[cfg(test)]
16mod tests; 16mod tests;
17pub mod utils; 17pub mod utils;
18pub mod ast_transform; 18pub mod path_transform;
19 19
20use std::str::FromStr; 20use std::str::FromStr;
21 21
diff --git a/crates/ide_assists/src/ast_transform.rs b/crates/ide_assists/src/path_transform.rs
index 5d9cc5551..6ec318c4c 100644
--- a/crates/ide_assists/src/ast_transform.rs
+++ b/crates/ide_assists/src/path_transform.rs
@@ -1,4 +1,4 @@
1//! `AstTransformer`s are functions that replace nodes in an AST and can be easily combined. 1//! See `PathTransform`
2use hir::{HirDisplay, SemanticsScope}; 2use hir::{HirDisplay, SemanticsScope};
3use ide_db::helpers::mod_path_to_ast; 3use ide_db::helpers::mod_path_to_ast;
4use rustc_hash::FxHashMap; 4use rustc_hash::FxHashMap;
@@ -7,7 +7,7 @@ use syntax::{
7 ted, 7 ted,
8}; 8};
9 9
10/// `AstTransform` helps with applying bulk transformations to syntax nodes. 10/// `PathTransform` substitutes path in SyntaxNodes in bulk.
11/// 11///
12/// This is mostly useful for IDE code generation. If you paste some existing 12/// This is mostly useful for IDE code generation. If you paste some existing
13/// code into a new context (for example, to add method overrides to an `impl` 13/// code into a new context (for example, to add method overrides to an `impl`
@@ -30,18 +30,13 @@ use syntax::{
30/// } 30/// }
31/// } 31/// }
32/// ``` 32/// ```
33/// 33pub(crate) struct PathTransform<'a> {
34/// So, a single `AstTransform` describes such function from `SyntaxNode` to
35/// `SyntaxNode`. Note that the API here is a bit too high-order and high-brow.
36/// We'd want to somehow express this concept simpler, but so far nobody got to
37/// simplifying this!
38pub(crate) struct AstTransform<'a> {
39 pub(crate) subst: (hir::Trait, ast::Impl), 34 pub(crate) subst: (hir::Trait, ast::Impl),
40 pub(crate) target_scope: &'a SemanticsScope<'a>, 35 pub(crate) target_scope: &'a SemanticsScope<'a>,
41 pub(crate) source_scope: &'a SemanticsScope<'a>, 36 pub(crate) source_scope: &'a SemanticsScope<'a>,
42} 37}
43 38
44impl<'a> AstTransform<'a> { 39impl<'a> PathTransform<'a> {
45 pub(crate) fn apply(&self, item: ast::AssocItem) { 40 pub(crate) fn apply(&self, item: ast::AssocItem) {
46 if let Some(ctx) = self.build_ctx() { 41 if let Some(ctx) = self.build_ctx() {
47 ctx.apply(item) 42 ctx.apply(item)
diff --git a/crates/ide_assists/src/utils.rs b/crates/ide_assists/src/utils.rs
index 2e79a3aed..30128a24a 100644
--- a/crates/ide_assists/src/utils.rs
+++ b/crates/ide_assists/src/utils.rs
@@ -24,7 +24,7 @@ use syntax::{
24 24
25use crate::{ 25use crate::{
26 assist_context::{AssistBuilder, AssistContext}, 26 assist_context::{AssistBuilder, AssistContext},
27 ast_transform::AstTransform, 27 path_transform::PathTransform,
28}; 28};
29 29
30pub(crate) fn unwrap_trivial_block(block: ast::BlockExpr) -> ast::Expr { 30pub(crate) fn unwrap_trivial_block(block: ast::BlockExpr) -> ast::Expr {
@@ -133,7 +133,7 @@ pub fn add_trait_assoc_items_to_impl(
133) -> (ast::Impl, ast::AssocItem) { 133) -> (ast::Impl, ast::AssocItem) {
134 let source_scope = sema.scope_for_def(trait_); 134 let source_scope = sema.scope_for_def(trait_);
135 135
136 let transform = AstTransform { 136 let transform = PathTransform {
137 subst: (trait_, impl_.clone()), 137 subst: (trait_, impl_.clone()),
138 source_scope: &source_scope, 138 source_scope: &source_scope,
139 target_scope: &target_scope, 139 target_scope: &target_scope,