Unnamed repository; edit this file 'description' to name the repository.
remove make from add_turbo_fish
bit-aloo 7 weeks ago
parent 2aeb269 · commit 6feab70
-rw-r--r--crates/ide-assists/src/handlers/add_turbo_fish.rs13
-rw-r--r--crates/ide-assists/src/handlers/extract_type_alias.rs9
-rw-r--r--crates/syntax/src/ast/syntax_factory/constructors.rs4
3 files changed, 16 insertions, 10 deletions
diff --git a/crates/ide-assists/src/handlers/add_turbo_fish.rs b/crates/ide-assists/src/handlers/add_turbo_fish.rs
index be13b04873..c5e722d87e 100644
--- a/crates/ide-assists/src/handlers/add_turbo_fish.rs
+++ b/crates/ide-assists/src/handlers/add_turbo_fish.rs
@@ -2,7 +2,7 @@ use either::Either;
use ide_db::defs::{Definition, NameRefClass};
use syntax::{
AstNode,
- ast::{self, HasArgList, HasGenericArgs, make, syntax_factory::SyntaxFactory},
+ ast::{self, HasArgList, HasGenericArgs, syntax_factory::SyntaxFactory},
syntax_editor::Position,
};
@@ -94,20 +94,21 @@ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext<'_>) -> Opti
ident.text_range(),
|builder| {
let mut editor = builder.make_editor(let_stmt.syntax());
+ let make = SyntaxFactory::without_mappings();
if let_stmt.semicolon_token().is_none() {
editor.insert(
Position::last_child_of(let_stmt.syntax()),
- make::tokens::semicolon(),
+ make.token(syntax::SyntaxKind::SEMICOLON),
);
}
- let placeholder_ty = make::ty_placeholder().clone_for_update();
+ let placeholder_ty = make.ty_placeholder();
if let Some(pat) = let_stmt.pat() {
let elements = vec![
- make::token(syntax::SyntaxKind::COLON).into(),
- make::token(syntax::SyntaxKind::WHITESPACE).into(),
+ make.token(syntax::SyntaxKind::COLON).into(),
+ make.whitespace(" ").into(),
placeholder_ty.syntax().clone().into(),
];
editor.insert_all(Position::after(pat.syntax()), elements);
@@ -188,7 +189,7 @@ pub(crate) fn add_turbo_fish(acc: &mut Assists, ctx: &AssistContext<'_>) -> Opti
/// This will create a turbofish generic arg list corresponding to the number of arguments
fn get_fish_head(make: &SyntaxFactory, number_of_arguments: usize) -> ast::GenericArgList {
- let args = (0..number_of_arguments).map(|_| make::type_arg(make::ty_placeholder()).into());
+ let args = (0..number_of_arguments).map(|_| make.type_arg(make.ty_placeholder()).into());
make.generic_arg_list(args, true)
}
diff --git a/crates/ide-assists/src/handlers/extract_type_alias.rs b/crates/ide-assists/src/handlers/extract_type_alias.rs
index 86c2e25b21..e4fdac27f4 100644
--- a/crates/ide-assists/src/handlers/extract_type_alias.rs
+++ b/crates/ide-assists/src/handlers/extract_type_alias.rs
@@ -2,7 +2,10 @@ use either::Either;
use hir::HirDisplay;
use ide_db::syntax_helpers::node_ext::walk_ty;
use syntax::{
- ast::{self, AstNode, HasGenericArgs, HasGenericParams, HasName, edit::IndentLevel, syntax_factory::SyntaxFactory},
+ ast::{
+ self, AstNode, HasGenericArgs, HasGenericParams, HasName, edit::IndentLevel,
+ syntax_factory::SyntaxFactory,
+ },
syntax_editor,
};
@@ -43,8 +46,7 @@ pub(crate) fn extract_type_alias(acc: &mut Assists, ctx: &AssistContext<'_>) ->
let resolved_ty = ctx.sema.resolve_type(&ty)?;
let resolved_ty = if !resolved_ty.contains_unknown() {
let module = ctx.sema.scope(ty.syntax())?.module();
- let resolved_ty = resolved_ty.display_source_code(ctx.db(), module.into(), false).ok()?;
- resolved_ty
+ resolved_ty.display_source_code(ctx.db(), module.into(), false).ok()?
} else {
ty.to_string()
};
@@ -54,7 +56,6 @@ pub(crate) fn extract_type_alias(acc: &mut Assists, ctx: &AssistContext<'_>) ->
"Extract type as type alias",
target,
|builder| {
-
let mut edit = builder.make_editor(node);
let make = SyntaxFactory::without_mappings();
diff --git a/crates/syntax/src/ast/syntax_factory/constructors.rs b/crates/syntax/src/ast/syntax_factory/constructors.rs
index 19d4721fe1..159b191805 100644
--- a/crates/syntax/src/ast/syntax_factory/constructors.rs
+++ b/crates/syntax/src/ast/syntax_factory/constructors.rs
@@ -295,6 +295,10 @@ impl SyntaxFactory {
make::generic_ty_path_segment(name_ref, generic_args).clone_for_update()
}
+ pub fn ty_placeholder(&self) -> ast::Type {
+ make::ty_placeholder().clone_for_update()
+ }
+
pub fn path_segment_generics(
&self,
name_ref: ast::NameRef,