diff options
author | Aleksey Kladov <[email protected]> | 2020-02-29 10:55:36 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-02-29 10:55:36 +0000 |
commit | ca713e462b90afd650a5c07014e066d0aa4dbd69 (patch) | |
tree | f78e3650b3cd4ca1f13a7fdc90b9f4f60e0c6ce0 /crates/ra_syntax | |
parent | 7cf710c66f5645193a765ededfed77eaec9a19a9 (diff) |
More orthogonal API for building paths
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r-- | crates/ra_syntax/src/ast/make.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/ra_syntax/src/ast/make.rs b/crates/ra_syntax/src/ast/make.rs index 7c20fcc10..60cd9d260 100644 --- a/crates/ra_syntax/src/ast/make.rs +++ b/crates/ra_syntax/src/ast/make.rs | |||
@@ -12,11 +12,14 @@ pub fn name_ref(text: &str) -> ast::NameRef { | |||
12 | ast_from_text(&format!("fn f() {{ {}; }}", text)) | 12 | ast_from_text(&format!("fn f() {{ {}; }}", text)) |
13 | } | 13 | } |
14 | 14 | ||
15 | pub fn path_from_name_ref(name_ref: ast::NameRef) -> ast::Path { | 15 | pub fn path_segment(name_ref: ast::NameRef) -> ast::PathSegment { |
16 | path_from_text(&name_ref.syntax().to_string()) | 16 | ast_from_text(&format!("use {};", name_ref.syntax())) |
17 | } | 17 | } |
18 | pub fn path_qualified(qual: ast::Path, name_ref: ast::NameRef) -> ast::Path { | 18 | pub fn path_unqalified(segment: ast::PathSegment) -> ast::Path { |
19 | path_from_text(&format!("{}::{}", qual.syntax(), name_ref.syntax())) | 19 | path_from_text(&format!("use {}", segment.syntax())) |
20 | } | ||
21 | pub fn path_qualified(qual: ast::Path, segment: ast::PathSegment) -> ast::Path { | ||
22 | path_from_text(&format!("{}::{}", qual.syntax(), segment.syntax())) | ||
20 | } | 23 | } |
21 | fn path_from_text(text: &str) -> ast::Path { | 24 | fn path_from_text(text: &str) -> ast::Path { |
22 | ast_from_text(text) | 25 | ast_from_text(text) |