fn calculate_deps(
    sources: &[String],
    input_deps: &[String],
    regex: &Regex,
) -> anyhow::Result<Vec<String>> {
    let file_map = calculate_file_map(input_deps)?;
    let mut deps = vec![];
    let mut visited = BTreeSet::new();
    for src in sources.iter() {
        calculate_deps_recursively(Path::new(src), &file_map, &mut visited, &mut deps, regex)?;
    }
    // Remove input sources from deps. They can end here because our dep analysis is an
    // over-approximation and for example cannot distinguish between references inside
    // and outside comments.
    let mut deps = remove_sources(sources, deps);
    // Sort deps by simple file name. Sorting is important because different orders
    // caused by platform dependent ways how `calculate_deps_recursively` may return values, can
    // cause different behavior of the SMT solver (butterfly effect). By using the simple file
    // name we abstract from places where the sources live in the file system. Since Move has
    // no namespaces and file names can be expected to be unique matching module/script names,
    // this should work in most cases.
    deps.sort_by(|a, b| {
        let fa = PathBuf::from(a);
        let fb = PathBuf::from(b);
        Ord::cmp(fa.file_name().unwrap(), fb.file_name().unwrap())
    });
    Ok(deps)
}
/// Calculates transitive dependencies of the given Move sources. This function
/// is also used to calculate transitive friends depending on the regex provided
/// for extracting matches.
Calculates transitive dependencies of the given Move sources. This function
is also used to calculate transitive friends depending on the regex provided
for extracting matches.
Calculates transitive dependencies of the given Move sources . This function is also used to calculate transitive friends depending on the regex provided for extracting matches .
fn calculate_deps(
    sources: &[String],
    input_deps: &[String],
    regex: &Regex,
) -> anyhow::Result<Vec<String>> {
    let file_map = calculate_file_map(input_deps)?;
    let mut deps = vec![];
    let mut visited = BTreeSet::new();
    for src in sources.iter() {
        calculate_deps_recursively(Path::new(src), &file_map, &mut visited, &mut deps, regex)?;
    }
    // Remove input sources from deps. They can end here because our dep analysis is an
    // over-approximation and for example cannot distinguish between references inside
    // and outside comments.
    let mut deps = remove_sources(sources, deps);
    // Sort deps by simple file name. Sorting is important because different orders
    // caused by platform dependent ways how `calculate_deps_recursively` may return values, can
    // cause different behavior of the SMT solver (butterfly effect). By using the simple file
    // name we abstract from places where the sources live in the file system. Since Move has
    // no namespaces and file names can be expected to be unique matching module/script names,
    // this should work in most cases.
    deps.sort_by(|a, b| {
        let fa = PathBuf::from(a);
        let fb = PathBuf::from(b);
        Ord::cmp(fa.file_name().unwrap(), fb.file_name().unwrap())
    });
    Ok(deps)
}
fn calculate_deps ( sources : & [ String ] , input_deps : & [ String ] , regex : & Regex , ) -> anyhow :: Result < Vec < String > > { let file_map = calculate_file_map ( input_deps ) ? ; let mut deps = vec ! [ ] ; let mut visited = BTreeSet :: new ( ) ; for src in sources . iter ( ) { calculate_deps_recursively ( Path :: new ( src ) , & file_map , & mut visited , & mut deps , regex ) ? ; } // Remove input sources from deps. They can end here because our dep analysis is an // over-approximation and for example cannot distinguish between references inside // and outside comments. let mut deps = remove_sources ( sources , deps ) ; // Sort deps by simple file name. Sorting is important because different orders // caused by platform dependent ways how `calculate_deps_recursively` may return values, can // cause different behavior of the SMT solver (butterfly effect). By using the simple file // name we abstract from places where the sources live in the file system. Since Move has // no namespaces and file names can be expected to be unique matching module/script names, // this should work in most cases. deps . sort_by ( | a , b | { let fa = PathBuf :: from ( a ) ; let fb = PathBuf :: from ( b ) ; Ord :: cmp ( fa . file_name ( ) . unwrap ( ) , fb . file_name ( ) . unwrap ( ) ) } ) ; Ok ( deps ) }
Calculates transitive dependencies of the given Move sources.
Calculates transitive dependencies of the given Move sources .
sources
&[String]
input_deps
&[String]
regex
&Regex