Cleanup project.json deserialization

This commit is contained in:
Aleksey Kladov
2020-06-24 15:52:07 +02:00
parent a07cad16ab
commit e6c61d5072
15 changed files with 141 additions and 144 deletions

View File

@@ -14,7 +14,7 @@ use lsp_types::ClientCapabilities;
use ra_db::AbsPathBuf;
use ra_flycheck::FlycheckConfig;
use ra_ide::{AssistConfig, CompletionConfig, HoverConfig, InlayHintsConfig};
use ra_project_model::{CargoConfig, ProjectJson, ProjectManifest};
use ra_project_model::{CargoConfig, ProjectJson, ProjectJsonData, ProjectManifest};
use serde::Deserialize;
#[derive(Debug, Clone)]
@@ -273,19 +273,19 @@ impl Config {
self.lens = LensConfig::NO_LENS;
}
if let Some(linked_projects) = get::<Vec<ManifestOrJsonProject>>(value, "/linkedProjects") {
if let Some(linked_projects) = get::<Vec<ManifestOrProjectJson>>(value, "/linkedProjects") {
if !linked_projects.is_empty() {
self.linked_projects.clear();
for linked_project in linked_projects {
let linked_project = match linked_project {
ManifestOrJsonProject::Manifest(it) => {
ManifestOrProjectJson::Manifest(it) => {
let path = self.root_path.join(it);
match ProjectManifest::from_manifest_file(path) {
Ok(it) => it.into(),
Err(_) => continue,
}
}
ManifestOrJsonProject::JsonProject(it) => it.into(),
ManifestOrProjectJson::ProjectJson(it) => ProjectJson::new(&self.root_path, it).into(),
};
self.linked_projects.push(linked_project);
}
@@ -371,7 +371,7 @@ impl Config {
#[derive(Deserialize)]
#[serde(untagged)]
enum ManifestOrJsonProject {
enum ManifestOrProjectJson {
Manifest(PathBuf),
JsonProject(ProjectJson),
ProjectJson(ProjectJsonData),
}