mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Support Display name in project.json
This commit is contained in:
parent
3b1a648539
commit
f753c3ecd2
3 changed files with 10 additions and 3 deletions
|
@ -335,8 +335,7 @@ impl ProjectWorkspace {
|
||||||
crate_graph.add_crate_root(
|
crate_graph.add_crate_root(
|
||||||
file_id,
|
file_id,
|
||||||
krate.edition,
|
krate.edition,
|
||||||
// FIXME json definitions can store the crate name
|
krate.display_name.clone(),
|
||||||
None,
|
|
||||||
cfg_options,
|
cfg_options,
|
||||||
env,
|
env,
|
||||||
proc_macro.unwrap_or_default(),
|
proc_macro.unwrap_or_default(),
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use base_db::{CrateId, CrateName, Dependency, Edition};
|
use base_db::{CrateDisplayName, CrateId, CrateName, Dependency, Edition};
|
||||||
use paths::{AbsPath, AbsPathBuf};
|
use paths::{AbsPath, AbsPathBuf};
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use serde::{de, Deserialize};
|
use serde::{de, Deserialize};
|
||||||
|
@ -21,6 +21,7 @@ pub struct ProjectJson {
|
||||||
/// useful in creating the crate graph.
|
/// useful in creating the crate graph.
|
||||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||||
pub struct Crate {
|
pub struct Crate {
|
||||||
|
pub(crate) display_name: Option<CrateDisplayName>,
|
||||||
pub(crate) root_module: AbsPathBuf,
|
pub(crate) root_module: AbsPathBuf,
|
||||||
pub(crate) edition: Edition,
|
pub(crate) edition: Edition,
|
||||||
pub(crate) deps: Vec<Dependency>,
|
pub(crate) deps: Vec<Dependency>,
|
||||||
|
@ -68,6 +69,9 @@ impl ProjectJson {
|
||||||
};
|
};
|
||||||
|
|
||||||
Crate {
|
Crate {
|
||||||
|
display_name: crate_data
|
||||||
|
.display_name
|
||||||
|
.map(CrateDisplayName::from_canonical_name),
|
||||||
root_module,
|
root_module,
|
||||||
edition: crate_data.edition.into(),
|
edition: crate_data.edition.into(),
|
||||||
deps: crate_data
|
deps: crate_data
|
||||||
|
@ -114,6 +118,7 @@ pub struct ProjectJsonData {
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct CrateData {
|
struct CrateData {
|
||||||
|
display_name: Option<String>,
|
||||||
root_module: PathBuf,
|
root_module: PathBuf,
|
||||||
edition: EditionData,
|
edition: EditionData,
|
||||||
deps: Vec<DepData>,
|
deps: Vec<DepData>,
|
||||||
|
|
|
@ -287,6 +287,9 @@ interface JsonProject {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Crate {
|
interface Crate {
|
||||||
|
/// Optional crate name used for display purposes, without affecting semantics.
|
||||||
|
/// See the `deps` key for semantically-significant crate names.
|
||||||
|
display_name?: string;
|
||||||
/// Path to the root module of the crate.
|
/// Path to the root module of the crate.
|
||||||
root_module: string;
|
root_module: string;
|
||||||
/// Edition of the crate.
|
/// Edition of the crate.
|
||||||
|
|
Loading…
Reference in a new issue