mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-22 11:24:24 +00:00
Remove make::path_from_text
This commit is contained in:
parent
4bc8015370
commit
f2ae412ccf
6 changed files with 61 additions and 47 deletions
|
@ -24,18 +24,41 @@ pub fn ty(text: &str) -> ast::Type {
|
|||
pub fn path_segment(name_ref: ast::NameRef) -> ast::PathSegment {
|
||||
ast_from_text(&format!("use {};", name_ref))
|
||||
}
|
||||
|
||||
pub fn path_segment_self() -> ast::PathSegment {
|
||||
ast_from_text("use self;")
|
||||
}
|
||||
|
||||
pub fn path_segment_super() -> ast::PathSegment {
|
||||
ast_from_text("use super;")
|
||||
}
|
||||
|
||||
pub fn path_segment_crate() -> ast::PathSegment {
|
||||
ast_from_text("use crate;")
|
||||
}
|
||||
|
||||
pub fn path_unqualified(segment: ast::PathSegment) -> ast::Path {
|
||||
path_from_text(&format!("use {}", segment))
|
||||
ast_from_text(&format!("use {}", segment))
|
||||
}
|
||||
|
||||
pub fn path_qualified(qual: ast::Path, segment: ast::PathSegment) -> ast::Path {
|
||||
path_from_text(&format!("{}::{}", qual, segment))
|
||||
ast_from_text(&format!("{}::{}", qual, segment))
|
||||
}
|
||||
// FIXME: make this private
|
||||
pub fn path_from_text(text: &str) -> ast::Path {
|
||||
ast_from_text(text)
|
||||
|
||||
pub fn path_concat(first: ast::Path, second: ast::Path) -> ast::Path {
|
||||
ast_from_text(&format!("{}::{}", first, second))
|
||||
}
|
||||
|
||||
pub fn path_from_segments(
|
||||
segments: impl IntoIterator<Item = ast::PathSegment>,
|
||||
is_abs: bool,
|
||||
) -> ast::Path {
|
||||
let segments = segments.into_iter().map(|it| it.syntax().clone()).join("::");
|
||||
ast_from_text(&if is_abs {
|
||||
format!("use ::{};", segments)
|
||||
} else {
|
||||
format!("use {};", segments)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn use_tree(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue