pub fn create_node_from_file(
    project: &model::Project,
    graph: &controller::Graph,
    path: &std::path::Path,
) -> FallibleResult {
    let ls_path = from_file_browser_path(path)?;
    let path_segments = ls_path.segments.into_iter().join("/");
    let content_root = project.content_root_by_id(ls_path.root_id)?;
    let path = match &*content_root {
        ContentRoot::Project { .. } => format!("Enso_Project.root/\"{}\"", path_segments),
        ContentRoot::FileSystemRoot { path, .. } => format!("\"{}/{}\"", path, path_segments),
        ContentRoot::Home { .. } => format!("File.home/\"{}\"", path_segments),
        ContentRoot::Library { namespace, name, .. } =>
            format!("{}.{}.Enso_Project.root / \"{}\"", namespace, name, path_segments),
        ContentRoot::Custom { .. } => "Unsupported Content Root".to_owned(),
    };
    let expression = format!("File.read {}", path);
    let node_info = NewNodeInfo::new_pushed_back(expression);
    graph.add_node(node_info)?;
    Ok(())
}
/// Create a node reading the given file.
///
/// The `path` should be a path convertible to Path from Language Server Protocol - see
/// [`from_file_browser_path`], otherwise function will return `Err`.
Create a node reading the given file.
Create a node reading the given file .
pub fn create_node_from_file(
    project: &model::Project,
    graph: &controller::Graph,
    path: &std::path::Path,
) -> FallibleResult {
    let ls_path = from_file_browser_path(path)?;
    let path_segments = ls_path.segments.into_iter().join("/");
    let content_root = project.content_root_by_id(ls_path.root_id)?;
    let path = match &*content_root {
        ContentRoot::Project { .. } => format!("Enso_Project.root/\"{}\"", path_segments),
        ContentRoot::FileSystemRoot { path, .. } => format!("\"{}/{}\"", path, path_segments),
        ContentRoot::Home { .. } => format!("File.home/\"{}\"", path_segments),
        ContentRoot::Library { namespace, name, .. } =>
            format!("{}.{}.Enso_Project.root / \"{}\"", namespace, name, path_segments),
        ContentRoot::Custom { .. } => "Unsupported Content Root".to_owned(),
    };
    let expression = format!("File.read {}", path);
    let node_info = NewNodeInfo::new_pushed_back(expression);
    graph.add_node(node_info)?;
    Ok(())
}
pub fn create_node_from_file ( project : & model :: Project , graph : & controller :: Graph , path : & std :: path :: Path , ) -> FallibleResult { let ls_path = from_file_browser_path ( path ) ? ; let path_segments = ls_path . segments . into_iter ( ) . join ( " " ) ; let content_root = project . content_root_by_id ( ls_path . root_id ) ? ; let path = match & * content_root { ContentRoot :: Project { .. } => format ! ( " \" \" " path_segments ) , ContentRoot :: FileSystemRoot { path , .. } => format ! ( " \" \" " path path_segments ) , ContentRoot :: Home { .. } => format ! ( " \" \" " path_segments ) , ContentRoot :: Library { namespace , name , .. } => format ! ( " \" \" " namespace name path_segments ) , ContentRoot :: Custom { .. } => " " . to_owned ( ) , } ; let expression = format ! ( " " path ) ; let node_info = NewNodeInfo :: new_pushed_back ( expression ) ; graph . add_node ( node_info ) ? ; Ok ( ( ) ) }
Create a node reading the given file.
Create a node reading the given file .
project
&model::Project
graph
&controller::Graph
path
&std::path::Path
project
&model::Project
graph
&controller::Graph
path
&std::path::Path