MCPcopy Create free account
hub / github.com/SeaQL/FireDBG.for.Rust / parse_file

Function parse_file

parser/src/lib.rs:65–84  ·  view source on GitHub ↗
(path: T)

Source from the content-addressed store, hash-verified

63};
64
65pub fn parse_file<T>(path: T) -> Result<Vec<FunctionDef>>
66where
67 T: AsRef<Path>,
68{
69 let path = path.as_ref();
70 let mut file = std::fs::File::open(path)
71 .with_context(|| format!("Fail to open file: `{}`", path.display()))?;
72 let mut source_code = String::new();
73 file.read_to_string(&mut source_code)
74 .with_context(|| format!("Fail to read file: `{}`", path.display()))?;
75 let res = syn::parse_file(&source_code)
76 .with_context(|| format!("Fail to parse file: `{}`", path.display()))?
77 .items
78 .into_iter()
79 .fold(Vec::new(), |mut acc, item| {
80 acc.extend(item.parse());
81 acc
82 });
83 Ok(res)
84}
85
86pub fn parse_directory<T>(directory: T) -> Result<Vec<File>>
87where

Callers 10

cache_workspaceFunction · 0.85
parse_directoryFunction · 0.85
parse_stmtFunction · 0.85
parse_result_fnFunction · 0.85
parse_nested_fnFunction · 0.85
parse_impl_traitFunction · 0.85
parse_impl_fnFunction · 0.85
parse_free_fnFunction · 0.85

Calls 2

openFunction · 0.85
parseMethod · 0.80

Tested by 8

parse_stmtFunction · 0.68
parse_result_fnFunction · 0.68
parse_nested_fnFunction · 0.68
parse_impl_traitFunction · 0.68
parse_impl_fnFunction · 0.68
parse_free_fnFunction · 0.68