From 317fc650d5c1267a8c192041efe6b591d900808f Mon Sep 17 00:00:00 2001 From: Timo Freiberg Date: Thu, 16 Apr 2020 23:53:25 +0200 Subject: Make add_function generate functions in other modules via qualified path --- crates/ra_syntax/src/ast/make.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'crates/ra_syntax') diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 0f4a50be4..b0f4803f3 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs @@ -293,11 +293,16 @@ pub fn fn_def( ast_from_text(&format!("fn {}{}{} {}", fn_name, type_params, params, body)) } -pub fn add_newlines(amount_of_newlines: usize, t: impl AstNode) -> ast::SourceFile { +pub fn add_leading_newlines(amount_of_newlines: usize, t: impl AstNode) -> ast::SourceFile { let newlines = "\n".repeat(amount_of_newlines); ast_from_text(&format!("{}{}", newlines, t.syntax())) } +pub fn add_trailing_newlines(amount_of_newlines: usize, t: impl AstNode) -> ast::SourceFile { + let newlines = "\n".repeat(amount_of_newlines); + ast_from_text(&format!("{}{}", t.syntax(), newlines)) +} + fn ast_from_text(text: &str) -> N { let parse = SourceFile::parse(text); let node = parse.tree().syntax().descendants().find_map(N::cast).unwrap(); -- cgit v1.2.3