Add support for custom flycheck commands with JSON project workspaces

Enable flychecks with JSON project workspaces if an override command was provided as part
of the client configuration.
This commit is contained in:
Aaron Wood
2020-09-15 18:51:57 -07:00
parent 37f3b9ca2a
commit 74c26a785a
2 changed files with 19 additions and 7 deletions

View File

@@ -13,6 +13,7 @@ use crate::cfg_flag::CfgFlag;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ProjectJson {
pub(crate) sysroot_src: Option<AbsPathBuf>,
project_root: Option<AbsPathBuf>,
crates: Vec<Crate>,
}
@@ -36,6 +37,7 @@ impl ProjectJson {
pub fn new(base: &AbsPath, data: ProjectJsonData) -> ProjectJson {
ProjectJson {
sysroot_src: data.sysroot_src.map(|it| base.join(it)),
project_root: base.parent().map(AbsPath::to_path_buf),
crates: data
.crates
.into_iter()
@@ -89,6 +91,12 @@ impl ProjectJson {
pub fn crates(&self) -> impl Iterator<Item = (CrateId, &Crate)> + '_ {
self.crates.iter().enumerate().map(|(idx, krate)| (CrateId(idx as u32), krate))
}
pub fn path(&self) -> Option<&AbsPath> {
match &self.project_root {
Some(p) => Some(p.as_path()),
None => None,
}
}
}
#[derive(Deserialize)]