From 3c6c1c99b41e2a3c9a31b0d4c73d660399255cba Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 29 Mar 2021 13:23:07 +0200 Subject: Don't use snippets --- .../ide_assists/src/handlers/extract_type_alias.rs | 29 +++++++++------------- crates/ide_assists/src/tests/generated.rs | 4 +-- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/crates/ide_assists/src/handlers/extract_type_alias.rs b/crates/ide_assists/src/handlers/extract_type_alias.rs index f75d35462..442a209b9 100644 --- a/crates/ide_assists/src/handlers/extract_type_alias.rs +++ b/crates/ide_assists/src/handlers/extract_type_alias.rs @@ -13,10 +13,10 @@ use crate::{AssistContext, AssistId, AssistKind, Assists}; // ``` // -> // ``` -// type ${0:Type} = (u8, u8, u8); +// type $0Type = (u8, u8, u8); // // struct S { -// field: ${0:Type}, +// field: Type, // } // ``` pub(crate) fn extract_type_alias(acc: &mut Assists, ctx: &AssistContext) -> Option<()> { @@ -34,17 +34,12 @@ pub(crate) fn extract_type_alias(acc: &mut Assists, ctx: &AssistContext) -> Opti target, |builder| { builder.edit_file(ctx.frange.file_id); + builder.replace(target, "Type"); match ctx.config.snippet_cap { Some(cap) => { - builder.replace_snippet(cap, target, "${0:Type}"); - builder.insert_snippet( - cap, - insert, - format!("type ${{0:Type}} = {};\n\n", node), - ); + builder.insert_snippet(cap, insert, format!("type $0Type = {};\n\n", node)); } None => { - builder.replace(target, "Type"); builder.insert(insert, format!("type Type = {};\n\n", node)); } } @@ -80,10 +75,10 @@ struct S { } ", r#" -type ${0:Type} = u8; +type $0Type = u8; struct S { - field: ${0:Type}, + field: Type, } "#, ); @@ -103,10 +98,10 @@ fn f() { r#" fn generic() {} -type ${0:Type} = (); +type $0Type = (); fn f() { - generic::<${0:Type}>(); + generic::(); } "#, ); @@ -124,10 +119,10 @@ struct S { ", r#" struct Vec {} -type ${0:Type} = Vec; +type $0Type = Vec; struct S { - v: Vec>, + v: Vec>, } "#, ); @@ -143,10 +138,10 @@ struct S { } ", r#" -type ${0:Type} = u8; +type $0Type = u8; struct S { - field: (${0:Type},), + field: (Type,), } "#, ); diff --git a/crates/ide_assists/src/tests/generated.rs b/crates/ide_assists/src/tests/generated.rs index becd640b1..03b7fb366 100644 --- a/crates/ide_assists/src/tests/generated.rs +++ b/crates/ide_assists/src/tests/generated.rs @@ -338,10 +338,10 @@ struct S { } "#####, r#####" -type ${0:Type} = (u8, u8, u8); +type $0Type = (u8, u8, u8); struct S { - field: ${0:Type}, + field: Type, } "#####, ) -- cgit v1.2.3