From 135c9e2027583181e89c696385c24af89127c7a4 Mon Sep 17 00:00:00 2001 From: Chetan Khilosiya Date: Sun, 28 Feb 2021 02:30:19 +0530 Subject: 7708: Fixed many documentaion example issues. --- .../src/handlers/generate_default_from_new.rs | 12 ++++----- crates/ide_assists/src/tests/generated.rs | 31 ++++++++++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) (limited to 'crates') diff --git a/crates/ide_assists/src/handlers/generate_default_from_new.rs b/crates/ide_assists/src/handlers/generate_default_from_new.rs index e7f4591ac..c7b049a46 100644 --- a/crates/ide_assists/src/handlers/generate_default_from_new.rs +++ b/crates/ide_assists/src/handlers/generate_default_from_new.rs @@ -10,13 +10,13 @@ use test_utils::mark; // Assist: generate_default_from_new // -// Generates default implementation from new method +// Generates default implementation from new method. // // ``` // struct Example { _inner: () } // // impl Example { -// pu|b fn new() -> Self { +// pub fn n$0ew() -> Self { // Self { _inner: () } // } // } @@ -24,13 +24,13 @@ use test_utils::mark; // -> // ``` // struct Example { _inner: () } - +// // impl Example { // pub fn new() -> Self { // Self { _inner: () } // } // } - +// // impl Default for Example { // fn default() -> Self { // Self::new() @@ -62,7 +62,7 @@ pub(crate) fn generate_default_from_new(acc: &mut Assists, ctx: &AssistContext) "Generate a Default impl from a new fn", impl_obj.syntax().text_range(), move |builder| { - // TODO: indentation logic can also go here. + // FIXME: indentation logic can also go here. // let new_indent = IndentLevel::from_node(&insert_after); let insert_location = impl_obj.syntax().text_range().end(); builder.insert(insert_location, default_fn_syntax); @@ -75,7 +75,7 @@ fn scope_for_fn_insertion_node(node: &SyntaxNode) -> Option { } fn default_fn_node_for_new(struct_name: SyntaxText) -> String { - // TODO: Update the implementation to consider the code indentation. + // FIXME: Update the implementation to consider the code indentation. format!( r#" diff --git a/crates/ide_assists/src/tests/generated.rs b/crates/ide_assists/src/tests/generated.rs index 4f007aa48..304b5798f 100644 --- a/crates/ide_assists/src/tests/generated.rs +++ b/crates/ide_assists/src/tests/generated.rs @@ -439,6 +439,37 @@ impl Default for Version { ) } +#[test] +fn doctest_generate_default_from_new() { + check_doc_test( + "generate_default_from_new", + r#####" +struct Example { _inner: () } + +impl Example { + pub fn n$0ew() -> Self { + Self { _inner: () } + } +} +"#####, + r#####" +struct Example { _inner: () } + +impl Example { + pub fn new() -> Self { + Self { _inner: () } + } +} + +impl Default for Example { + fn default() -> Self { + Self::new() + } +} +"#####, + ) +} + #[test] fn doctest_generate_derive() { check_doc_test( -- cgit v1.2.3