From ca713e462b90afd650a5c07014e066d0aa4dbd69 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 29 Feb 2020 11:55:36 +0100 Subject: More orthogonal API for building paths --- crates/ra_syntax/src/ast/make.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'crates/ra_syntax/src/ast/make.rs') 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 { ast_from_text(&format!("fn f() {{ {}; }}", text)) } -pub fn path_from_name_ref(name_ref: ast::NameRef) -> ast::Path { - path_from_text(&name_ref.syntax().to_string()) +pub fn path_segment(name_ref: ast::NameRef) -> ast::PathSegment { + ast_from_text(&format!("use {};", name_ref.syntax())) } -pub fn path_qualified(qual: ast::Path, name_ref: ast::NameRef) -> ast::Path { - path_from_text(&format!("{}::{}", qual.syntax(), name_ref.syntax())) +pub fn path_unqalified(segment: ast::PathSegment) -> ast::Path { + path_from_text(&format!("use {}", segment.syntax())) +} +pub fn path_qualified(qual: ast::Path, segment: ast::PathSegment) -> ast::Path { + path_from_text(&format!("{}::{}", qual.syntax(), segment.syntax())) } fn path_from_text(text: &str) -> ast::Path { ast_from_text(text) -- cgit v1.2.3