diff options
author | Aleksey Kladov <[email protected]> | 2020-10-20 16:13:15 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2020-10-20 16:13:15 +0100 |
commit | f753c3ecd20c4a448403d2d7d9b334a289f9e5b3 (patch) | |
tree | 8ac8a8f761db3bd3b60446001739b94bb1ed44dd | |
parent | 3b1a648539487c08bc613b6fd6e573b0e0e38948 (diff) |
Support Display name in project.json
-rw-r--r-- | crates/project_model/src/lib.rs | 3 | ||||
-rw-r--r-- | crates/project_model/src/project_json.rs | 7 | ||||
-rw-r--r-- | docs/user/manual.adoc | 3 |
3 files changed, 10 insertions, 3 deletions
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 { | |||
335 | crate_graph.add_crate_root( | 335 | crate_graph.add_crate_root( |
336 | file_id, | 336 | file_id, |
337 | krate.edition, | 337 | krate.edition, |
338 | // FIXME json definitions can store the crate name | 338 | krate.display_name.clone(), |
339 | None, | ||
340 | cfg_options, | 339 | cfg_options, |
341 | env, | 340 | env, |
342 | proc_macro.unwrap_or_default(), | 341 | 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 @@ | |||
2 | 2 | ||
3 | use std::path::PathBuf; | 3 | use std::path::PathBuf; |
4 | 4 | ||
5 | use base_db::{CrateId, CrateName, Dependency, Edition}; | 5 | use base_db::{CrateDisplayName, CrateId, CrateName, Dependency, Edition}; |
6 | use paths::{AbsPath, AbsPathBuf}; | 6 | use paths::{AbsPath, AbsPathBuf}; |
7 | use rustc_hash::FxHashMap; | 7 | use rustc_hash::FxHashMap; |
8 | use serde::{de, Deserialize}; | 8 | use serde::{de, Deserialize}; |
@@ -21,6 +21,7 @@ pub struct ProjectJson { | |||
21 | /// useful in creating the crate graph. | 21 | /// useful in creating the crate graph. |
22 | #[derive(Clone, Debug, Eq, PartialEq)] | 22 | #[derive(Clone, Debug, Eq, PartialEq)] |
23 | pub struct Crate { | 23 | pub struct Crate { |
24 | pub(crate) display_name: Option<CrateDisplayName>, | ||
24 | pub(crate) root_module: AbsPathBuf, | 25 | pub(crate) root_module: AbsPathBuf, |
25 | pub(crate) edition: Edition, | 26 | pub(crate) edition: Edition, |
26 | pub(crate) deps: Vec<Dependency>, | 27 | pub(crate) deps: Vec<Dependency>, |
@@ -68,6 +69,9 @@ impl ProjectJson { | |||
68 | }; | 69 | }; |
69 | 70 | ||
70 | Crate { | 71 | Crate { |
72 | display_name: crate_data | ||
73 | .display_name | ||
74 | .map(CrateDisplayName::from_canonical_name), | ||
71 | root_module, | 75 | root_module, |
72 | edition: crate_data.edition.into(), | 76 | edition: crate_data.edition.into(), |
73 | deps: crate_data | 77 | deps: crate_data |
@@ -114,6 +118,7 @@ pub struct ProjectJsonData { | |||
114 | 118 | ||
115 | #[derive(Deserialize)] | 119 | #[derive(Deserialize)] |
116 | struct CrateData { | 120 | struct CrateData { |
121 | display_name: Option<String>, | ||
117 | root_module: PathBuf, | 122 | root_module: PathBuf, |
118 | edition: EditionData, | 123 | edition: EditionData, |
119 | deps: Vec<DepData>, | 124 | deps: Vec<DepData>, |
diff --git a/docs/user/manual.adoc b/docs/user/manual.adoc index e95bff8f9..7e8adcdb7 100644 --- a/docs/user/manual.adoc +++ b/docs/user/manual.adoc | |||
@@ -287,6 +287,9 @@ interface JsonProject { | |||
287 | } | 287 | } |
288 | 288 | ||
289 | interface Crate { | 289 | interface Crate { |
290 | /// Optional crate name used for display purposes, without affecting semantics. | ||
291 | /// See the `deps` key for semantically-significant crate names. | ||
292 | display_name?: string; | ||
290 | /// Path to the root module of the crate. | 293 | /// Path to the root module of the crate. |
291 | root_module: string; | 294 | root_module: string; |
292 | /// Edition of the crate. | 295 | /// Edition of the crate. |