Make add_function generate functions in other modules via qualified path
This commit is contained in:
@@ -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<N: AstNode>(text: &str) -> N {
|
||||
let parse = SourceFile::parse(text);
|
||||
let node = parse.tree().syntax().descendants().find_map(N::cast).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user