aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-02-29 10:55:36 +0000
committerAleksey Kladov <[email protected]>2020-02-29 10:55:36 +0000
commitca713e462b90afd650a5c07014e066d0aa4dbd69 (patch)
treef78e3650b3cd4ca1f13a7fdc90b9f4f60e0c6ce0 /crates/ra_syntax
parent7cf710c66f5645193a765ededfed77eaec9a19a9 (diff)
More orthogonal API for building paths
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r--crates/ra_syntax/src/ast/make.rs11
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
15pub fn path_from_name_ref(name_ref: ast::NameRef) -> ast::Path { 15pub 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}
18pub fn path_qualified(qual: ast::Path, name_ref: ast::NameRef) -> ast::Path { 18pub 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}
21pub fn path_qualified(qual: ast::Path, segment: ast::PathSegment) -> ast::Path {
22 path_from_text(&format!("{}::{}", qual.syntax(), segment.syntax()))
20} 23}
21fn path_from_text(text: &str) -> ast::Path { 24fn path_from_text(text: &str) -> ast::Path {
22 ast_from_text(text) 25 ast_from_text(text)