diff options
-rw-r--r-- | crates/project_model/src/workspace.rs | 73 |
1 files changed, 32 insertions, 41 deletions
diff --git a/crates/project_model/src/workspace.rs b/crates/project_model/src/workspace.rs index 9ebb0a811..90ab5e7a9 100644 --- a/crates/project_model/src/workspace.rs +++ b/crates/project_model/src/workspace.rs | |||
@@ -70,12 +70,8 @@ impl ProjectWorkspace { | |||
70 | format!("Failed to deserialize json file {}", project_json.display()) | 70 | format!("Failed to deserialize json file {}", project_json.display()) |
71 | })?; | 71 | })?; |
72 | let project_location = project_json.parent().unwrap().to_path_buf(); | 72 | let project_location = project_json.parent().unwrap().to_path_buf(); |
73 | let project = ProjectJson::new(&project_location, data); | 73 | let project_json = ProjectJson::new(&project_location, data); |
74 | let sysroot = match &project.sysroot_src { | 74 | ProjectWorkspace::load_inline(project_json)? |
75 | Some(path) => Some(Sysroot::load(path)?), | ||
76 | None => None, | ||
77 | }; | ||
78 | ProjectWorkspace::Json { project, sysroot } | ||
79 | } | 75 | } |
80 | ProjectManifest::CargoToml(cargo_toml) => { | 76 | ProjectManifest::CargoToml(cargo_toml) => { |
81 | let cargo_version = utf8_stdout({ | 77 | let cargo_version = utf8_stdout({ |
@@ -150,43 +146,38 @@ impl ProjectWorkspace { | |||
150 | }) | 146 | }) |
151 | })) | 147 | })) |
152 | .collect::<Vec<_>>(), | 148 | .collect::<Vec<_>>(), |
153 | ProjectWorkspace::Cargo { cargo, sysroot, rustc } => { | 149 | ProjectWorkspace::Cargo { cargo, sysroot, rustc } => cargo |
154 | let roots = cargo | 150 | .packages() |
155 | .packages() | 151 | .map(|pkg| { |
156 | .map(|pkg| { | 152 | let is_member = cargo[pkg].is_member; |
157 | let is_member = cargo[pkg].is_member; | 153 | let pkg_root = cargo[pkg].root().to_path_buf(); |
158 | let pkg_root = cargo[pkg].root().to_path_buf(); | 154 | |
159 | 155 | let mut include = vec![pkg_root.clone()]; | |
160 | let mut include = vec![pkg_root.clone()]; | 156 | include.extend(cargo[pkg].out_dir.clone()); |
161 | include.extend(cargo[pkg].out_dir.clone()); | 157 | |
162 | 158 | let mut exclude = vec![pkg_root.join(".git")]; | |
163 | let mut exclude = vec![pkg_root.join(".git")]; | 159 | if is_member { |
164 | if is_member { | 160 | exclude.push(pkg_root.join("target")); |
165 | exclude.push(pkg_root.join("target")); | 161 | } else { |
166 | } else { | 162 | exclude.push(pkg_root.join("tests")); |
167 | exclude.push(pkg_root.join("tests")); | 163 | exclude.push(pkg_root.join("examples")); |
168 | exclude.push(pkg_root.join("examples")); | 164 | exclude.push(pkg_root.join("benches")); |
169 | exclude.push(pkg_root.join("benches")); | 165 | } |
170 | } | 166 | PackageRoot { is_member, include, exclude } |
171 | PackageRoot { is_member, include, exclude } | 167 | }) |
172 | }) | 168 | .chain(sysroot.crates().map(|krate| PackageRoot { |
173 | .chain(sysroot.crates().map(|krate| PackageRoot { | 169 | is_member: false, |
170 | include: vec![sysroot[krate].root_dir().to_path_buf()], | ||
171 | exclude: Vec::new(), | ||
172 | })) | ||
173 | .chain(rustc.into_iter().flat_map(|rustc| { | ||
174 | rustc.packages().map(move |krate| PackageRoot { | ||
174 | is_member: false, | 175 | is_member: false, |
175 | include: vec![sysroot[krate].root_dir().to_path_buf()], | 176 | include: vec![rustc[krate].root().to_path_buf()], |
176 | exclude: Vec::new(), | 177 | exclude: Vec::new(), |
177 | })); | 178 | }) |
178 | if let Some(rustc_packages) = rustc { | 179 | })) |
179 | roots | 180 | .collect(), |
180 | .chain(rustc_packages.packages().map(|krate| PackageRoot { | ||
181 | is_member: false, | ||
182 | include: vec![rustc_packages[krate].root().to_path_buf()], | ||
183 | exclude: Vec::new(), | ||
184 | })) | ||
185 | .collect() | ||
186 | } else { | ||
187 | roots.collect() | ||
188 | } | ||
189 | } | ||
190 | } | 181 | } |
191 | } | 182 | } |
192 | 183 | ||