From 32c067f8c9aec56bb502c5a569884679bae27af3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 8 Dec 2018 21:54:00 +0300 Subject: track deps in project model --- crates/ra_lsp_server/src/project_model.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'crates/ra_lsp_server/src') diff --git a/crates/ra_lsp_server/src/project_model.rs b/crates/ra_lsp_server/src/project_model.rs index 3305d468a..22495f49c 100644 --- a/crates/ra_lsp_server/src/project_model.rs +++ b/crates/ra_lsp_server/src/project_model.rs @@ -28,6 +28,7 @@ struct PackageData { manifest: PathBuf, targets: Vec, is_member: bool, + dependencies: Vec, } #[derive(Debug, Clone)] @@ -106,6 +107,7 @@ impl CargoWorkspace { manifest: PathBuf::from(meta_pkg.manifest_path), targets: Vec::new(), is_member, + dependencies: Vec::new(), }; for meta_tgt in meta_pkg.targets { let tgt = Target(targets.len()); @@ -119,6 +121,14 @@ impl CargoWorkspace { } packages.push(pkg_data) } + let resolve = meta.resolve.expect("metadata executed with deps"); + for node in resolve.nodes { + let source = pkg_by_id[&node.id]; + for id in node.dependencies { + let target = pkg_by_id[&id]; + packages[source.0].dependencies.push(target); + } + } Ok(CargoWorkspace { packages, targets }) } -- cgit v1.2.3