mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-12 21:28:51 +00:00
Rename json_project -> project_json
This commit is contained in:
parent
97c4d06258
commit
a07cad16ab
3 changed files with 14 additions and 14 deletions
|
@ -1,7 +1,7 @@
|
||||||
//! FIXME: write short doc here
|
//! FIXME: write short doc here
|
||||||
|
|
||||||
mod cargo_workspace;
|
mod cargo_workspace;
|
||||||
mod json_project;
|
mod project_json;
|
||||||
mod sysroot;
|
mod sysroot;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -20,7 +20,7 @@ use serde_json::from_reader;
|
||||||
|
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
cargo_workspace::{CargoConfig, CargoWorkspace, Package, Target, TargetKind},
|
cargo_workspace::{CargoConfig, CargoWorkspace, Package, Target, TargetKind},
|
||||||
json_project::JsonProject,
|
project_json::ProjectJson,
|
||||||
sysroot::Sysroot,
|
sysroot::Sysroot,
|
||||||
};
|
};
|
||||||
pub use ra_proc_macro::ProcMacroClient;
|
pub use ra_proc_macro::ProcMacroClient;
|
||||||
|
@ -30,7 +30,7 @@ pub enum ProjectWorkspace {
|
||||||
/// Project workspace was discovered by running `cargo metadata` and `rustc --print sysroot`.
|
/// Project workspace was discovered by running `cargo metadata` and `rustc --print sysroot`.
|
||||||
Cargo { cargo: CargoWorkspace, sysroot: Sysroot },
|
Cargo { cargo: CargoWorkspace, sysroot: Sysroot },
|
||||||
/// Project workspace was manually specified using a `rust-project.json` file.
|
/// Project workspace was manually specified using a `rust-project.json` file.
|
||||||
Json { project: JsonProject, project_location: AbsPathBuf },
|
Json { project: ProjectJson, project_location: AbsPathBuf },
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `PackageRoot` describes a package root folder.
|
/// `PackageRoot` describes a package root folder.
|
||||||
|
@ -259,8 +259,8 @@ impl ProjectWorkspace {
|
||||||
let file_path = project_location.join(&krate.root_module);
|
let file_path = project_location.join(&krate.root_module);
|
||||||
let file_id = load(&file_path)?;
|
let file_id = load(&file_path)?;
|
||||||
let edition = match krate.edition {
|
let edition = match krate.edition {
|
||||||
json_project::Edition::Edition2015 => Edition::Edition2015,
|
project_json::Edition::Edition2015 => Edition::Edition2015,
|
||||||
json_project::Edition::Edition2018 => Edition::Edition2018,
|
project_json::Edition::Edition2018 => Edition::Edition2018,
|
||||||
};
|
};
|
||||||
let cfg_options = {
|
let cfg_options = {
|
||||||
let mut opts = CfgOptions::default();
|
let mut opts = CfgOptions::default();
|
||||||
|
@ -290,7 +290,7 @@ impl ProjectWorkspace {
|
||||||
.map(|it| proc_macro_client.by_dylib_path(&it));
|
.map(|it| proc_macro_client.by_dylib_path(&it));
|
||||||
// FIXME: No crate name in json definition such that we cannot add OUT_DIR to env
|
// FIXME: No crate name in json definition such that we cannot add OUT_DIR to env
|
||||||
Some((
|
Some((
|
||||||
json_project::CrateId(seq_index),
|
project_json::CrateId(seq_index),
|
||||||
crate_graph.add_crate_root(
|
crate_graph.add_crate_root(
|
||||||
file_id,
|
file_id,
|
||||||
edition,
|
edition,
|
||||||
|
@ -306,7 +306,7 @@ impl ProjectWorkspace {
|
||||||
|
|
||||||
for (id, krate) in project.crates.iter().enumerate() {
|
for (id, krate) in project.crates.iter().enumerate() {
|
||||||
for dep in &krate.deps {
|
for dep in &krate.deps {
|
||||||
let from_crate_id = json_project::CrateId(id);
|
let from_crate_id = project_json::CrateId(id);
|
||||||
let to_crate_id = dep.krate;
|
let to_crate_id = dep.krate;
|
||||||
if let (Some(&from), Some(&to)) =
|
if let (Some(&from), Some(&to)) =
|
||||||
(crates.get(&from_crate_id), crates.get(&to_crate_id))
|
(crates.get(&from_crate_id), crates.get(&to_crate_id))
|
||||||
|
@ -528,7 +528,7 @@ impl ProjectWorkspace {
|
||||||
ProjectWorkspace::Cargo { cargo, .. } => {
|
ProjectWorkspace::Cargo { cargo, .. } => {
|
||||||
Some(cargo.workspace_root()).filter(|root| path.starts_with(root))
|
Some(cargo.workspace_root()).filter(|root| path.starts_with(root))
|
||||||
}
|
}
|
||||||
ProjectWorkspace::Json { project: JsonProject { roots, .. }, .. } => roots
|
ProjectWorkspace::Json { project: ProjectJson { roots, .. }, .. } => roots
|
||||||
.iter()
|
.iter()
|
||||||
.find(|root| path.starts_with(&root.path))
|
.find(|root| path.starts_with(&root.path))
|
||||||
.map(|root| root.path.as_ref()),
|
.map(|root| root.path.as_ref()),
|
||||||
|
|
|
@ -7,7 +7,7 @@ use serde::Deserialize;
|
||||||
|
|
||||||
/// Roots and crates that compose this Rust project.
|
/// Roots and crates that compose this Rust project.
|
||||||
#[derive(Clone, Debug, Deserialize)]
|
#[derive(Clone, Debug, Deserialize)]
|
||||||
pub struct JsonProject {
|
pub struct ProjectJson {
|
||||||
pub(crate) roots: Vec<Root>,
|
pub(crate) roots: Vec<Root>,
|
||||||
pub(crate) crates: Vec<Crate>,
|
pub(crate) crates: Vec<Crate>,
|
||||||
}
|
}
|
|
@ -14,7 +14,7 @@ use lsp_types::ClientCapabilities;
|
||||||
use ra_db::AbsPathBuf;
|
use ra_db::AbsPathBuf;
|
||||||
use ra_flycheck::FlycheckConfig;
|
use ra_flycheck::FlycheckConfig;
|
||||||
use ra_ide::{AssistConfig, CompletionConfig, HoverConfig, InlayHintsConfig};
|
use ra_ide::{AssistConfig, CompletionConfig, HoverConfig, InlayHintsConfig};
|
||||||
use ra_project_model::{CargoConfig, JsonProject, ProjectManifest};
|
use ra_project_model::{CargoConfig, ProjectJson, ProjectManifest};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -47,7 +47,7 @@ pub struct Config {
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum LinkedProject {
|
pub enum LinkedProject {
|
||||||
ProjectManifest(ProjectManifest),
|
ProjectManifest(ProjectManifest),
|
||||||
InlineJsonProject(JsonProject),
|
InlineJsonProject(ProjectJson),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<ProjectManifest> for LinkedProject {
|
impl From<ProjectManifest> for LinkedProject {
|
||||||
|
@ -56,8 +56,8 @@ impl From<ProjectManifest> for LinkedProject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<JsonProject> for LinkedProject {
|
impl From<ProjectJson> for LinkedProject {
|
||||||
fn from(v: JsonProject) -> Self {
|
fn from(v: ProjectJson) -> Self {
|
||||||
LinkedProject::InlineJsonProject(v)
|
LinkedProject::InlineJsonProject(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -373,5 +373,5 @@ impl Config {
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
enum ManifestOrJsonProject {
|
enum ManifestOrJsonProject {
|
||||||
Manifest(PathBuf),
|
Manifest(PathBuf),
|
||||||
JsonProject(JsonProject),
|
JsonProject(ProjectJson),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue