From f753c3ecd20c4a448403d2d7d9b334a289f9e5b3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 20 Oct 2020 17:13:15 +0200 Subject: Support Display name in project.json --- crates/project_model/src/lib.rs | 3 +-- crates/project_model/src/project_json.rs | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'crates/project_model/src') diff --git a/crates/project_model/src/lib.rs b/crates/project_model/src/lib.rs index 5db41bc16..e92cfea59 100644 --- a/crates/project_model/src/lib.rs +++ b/crates/project_model/src/lib.rs @@ -335,8 +335,7 @@ impl ProjectWorkspace { crate_graph.add_crate_root( file_id, krate.edition, - // FIXME json definitions can store the crate name - None, + krate.display_name.clone(), cfg_options, env, proc_macro.unwrap_or_default(), diff --git a/crates/project_model/src/project_json.rs b/crates/project_model/src/project_json.rs index a6895ecdd..aab279223 100644 --- a/crates/project_model/src/project_json.rs +++ b/crates/project_model/src/project_json.rs @@ -2,7 +2,7 @@ use std::path::PathBuf; -use base_db::{CrateId, CrateName, Dependency, Edition}; +use base_db::{CrateDisplayName, CrateId, CrateName, Dependency, Edition}; use paths::{AbsPath, AbsPathBuf}; use rustc_hash::FxHashMap; use serde::{de, Deserialize}; @@ -21,6 +21,7 @@ pub struct ProjectJson { /// useful in creating the crate graph. #[derive(Clone, Debug, Eq, PartialEq)] pub struct Crate { + pub(crate) display_name: Option, pub(crate) root_module: AbsPathBuf, pub(crate) edition: Edition, pub(crate) deps: Vec, @@ -68,6 +69,9 @@ impl ProjectJson { }; Crate { + display_name: crate_data + .display_name + .map(CrateDisplayName::from_canonical_name), root_module, edition: crate_data.edition.into(), deps: crate_data @@ -114,6 +118,7 @@ pub struct ProjectJsonData { #[derive(Deserialize)] struct CrateData { + display_name: Option, root_module: PathBuf, edition: EditionData, deps: Vec, -- cgit v1.2.3