aboutsummaryrefslogtreecommitdiff
path: root/crates/project_model
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-09-16 19:04:29 +0100
committerGitHub <[email protected]>2020-09-16 19:04:29 +0100
commit4bc8015370e3698248bc93184ef7ec5fefd2c1d4 (patch)
tree81c029b5bb262e7dcd10235510b77ef49fc2e8f7 /crates/project_model
parent5df69d903445319bc01a32c93eb4175da5bb94d2 (diff)
parent74c26a785ad8e8ef857b903d3639beb623077933 (diff)
Merge #6013
6013: Add support for custom flycheck commands with JSON project workspaces r=jonas-schievink a=woody77 Enable flychecks with JSON project workspaces if an override command was provided as part of the client configuration: ``` "rust-analyzer.checkOnSave.enable": true, "rust-analyzer.checkOnSave.overrideCommand": ["custom_tool", "arg1", "arg2"], ``` Co-authored-by: Aaron Wood <[email protected]>
Diffstat (limited to 'crates/project_model')
-rw-r--r--crates/project_model/src/project_json.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/crates/project_model/src/project_json.rs b/crates/project_model/src/project_json.rs
index 979e90058..545f254aa 100644
--- a/crates/project_model/src/project_json.rs
+++ b/crates/project_model/src/project_json.rs
@@ -13,6 +13,7 @@ use crate::cfg_flag::CfgFlag;
13#[derive(Clone, Debug, Eq, PartialEq)] 13#[derive(Clone, Debug, Eq, PartialEq)]
14pub struct ProjectJson { 14pub struct ProjectJson {
15 pub(crate) sysroot_src: Option<AbsPathBuf>, 15 pub(crate) sysroot_src: Option<AbsPathBuf>,
16 project_root: Option<AbsPathBuf>,
16 crates: Vec<Crate>, 17 crates: Vec<Crate>,
17} 18}
18 19
@@ -36,6 +37,7 @@ impl ProjectJson {
36 pub fn new(base: &AbsPath, data: ProjectJsonData) -> ProjectJson { 37 pub fn new(base: &AbsPath, data: ProjectJsonData) -> ProjectJson {
37 ProjectJson { 38 ProjectJson {
38 sysroot_src: data.sysroot_src.map(|it| base.join(it)), 39 sysroot_src: data.sysroot_src.map(|it| base.join(it)),
40 project_root: base.parent().map(AbsPath::to_path_buf),
39 crates: data 41 crates: data
40 .crates 42 .crates
41 .into_iter() 43 .into_iter()
@@ -89,6 +91,12 @@ impl ProjectJson {
89 pub fn crates(&self) -> impl Iterator<Item = (CrateId, &Crate)> + '_ { 91 pub fn crates(&self) -> impl Iterator<Item = (CrateId, &Crate)> + '_ {
90 self.crates.iter().enumerate().map(|(idx, krate)| (CrateId(idx as u32), krate)) 92 self.crates.iter().enumerate().map(|(idx, krate)| (CrateId(idx as u32), krate))
91 } 93 }
94 pub fn path(&self) -> Option<&AbsPath> {
95 match &self.project_root {
96 Some(p) => Some(p.as_path()),
97 None => None,
98 }
99 }
92} 100}
93 101
94#[derive(Deserialize)] 102#[derive(Deserialize)]