mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 20:42:04 +00:00
Add pub(crate)
to functions generated in other module
This commit is contained in:
parent
74780a15f6
commit
f2f882bc44
2 changed files with 27 additions and 46 deletions
|
@ -303,6 +303,10 @@ pub fn add_trailing_newlines(amount_of_newlines: usize, t: impl AstNode) -> ast:
|
|||
ast_from_text(&format!("{}{}", t.syntax(), newlines))
|
||||
}
|
||||
|
||||
pub fn add_pub_crate_modifier(fn_def: ast::FnDef) -> ast::FnDef {
|
||||
ast_from_text(&format!("pub(crate) {}", fn_def))
|
||||
}
|
||||
|
||||
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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue