mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
internal: simplify handling of the build scripts
This commit is contained in:
parent
8da560264e
commit
f4de2ece0d
18 changed files with 404 additions and 491 deletions
|
@ -68,7 +68,6 @@ impl AnalysisStatsCmd {
|
|||
cargo_config.no_sysroot = self.no_sysroot;
|
||||
let load_cargo_config = LoadCargoConfig {
|
||||
load_out_dirs_from_check: self.enable_build_scripts,
|
||||
wrap_rustc: false,
|
||||
with_proc_macro: self.enable_proc_macros,
|
||||
prefill_caches: false,
|
||||
};
|
||||
|
|
|
@ -34,12 +34,8 @@ pub fn diagnostics(
|
|||
with_proc_macro: bool,
|
||||
) -> Result<()> {
|
||||
let cargo_config = Default::default();
|
||||
let load_cargo_config = LoadCargoConfig {
|
||||
load_out_dirs_from_check,
|
||||
with_proc_macro,
|
||||
wrap_rustc: false,
|
||||
prefill_caches: false,
|
||||
};
|
||||
let load_cargo_config =
|
||||
LoadCargoConfig { load_out_dirs_from_check, with_proc_macro, prefill_caches: false };
|
||||
let (host, _vfs, _proc_macro) =
|
||||
load_workspace_at(path, &cargo_config, &load_cargo_config, &|_| {})?;
|
||||
let db = host.raw_database();
|
||||
|
|
|
@ -8,7 +8,7 @@ use hir::db::DefDatabase;
|
|||
use ide::{AnalysisHost, Change};
|
||||
use ide_db::base_db::CrateGraph;
|
||||
use project_model::{
|
||||
BuildDataCollector, CargoConfig, ProcMacroClient, ProjectManifest, ProjectWorkspace,
|
||||
CargoConfig, ProcMacroClient, ProjectManifest, ProjectWorkspace, WorkspaceBuildScripts,
|
||||
};
|
||||
use vfs::{loader::Handle, AbsPath, AbsPathBuf};
|
||||
|
||||
|
@ -16,7 +16,6 @@ use crate::reload::{ProjectFolders, SourceRootConfig};
|
|||
|
||||
pub(crate) struct LoadCargoConfig {
|
||||
pub(crate) load_out_dirs_from_check: bool,
|
||||
pub(crate) wrap_rustc: bool,
|
||||
pub(crate) with_proc_macro: bool,
|
||||
pub(crate) prefill_caches: bool,
|
||||
}
|
||||
|
@ -33,12 +32,13 @@ pub(crate) fn load_workspace_at(
|
|||
eprintln!("root = {:?}", root);
|
||||
let workspace = ProjectWorkspace::load(root, cargo_config, progress)?;
|
||||
|
||||
load_workspace(workspace, load_config, progress)
|
||||
load_workspace(workspace, cargo_config, load_config, progress)
|
||||
}
|
||||
|
||||
fn load_workspace(
|
||||
ws: ProjectWorkspace,
|
||||
config: &LoadCargoConfig,
|
||||
cargo_config: &CargoConfig,
|
||||
load_config: &LoadCargoConfig,
|
||||
progress: &dyn Fn(String),
|
||||
) -> Result<(AnalysisHost, vfs::Vfs, Option<ProcMacroClient>)> {
|
||||
let (sender, receiver) = unbounded();
|
||||
|
@ -49,33 +49,29 @@ fn load_workspace(
|
|||
Box::new(loader)
|
||||
};
|
||||
|
||||
let proc_macro_client = if config.with_proc_macro {
|
||||
let proc_macro_client = if load_config.with_proc_macro {
|
||||
let path = AbsPathBuf::assert(std::env::current_exe()?);
|
||||
Some(ProcMacroClient::extern_process(path, &["proc-macro"]).unwrap())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let build_data = if config.load_out_dirs_from_check {
|
||||
let mut collector = BuildDataCollector::new(config.wrap_rustc);
|
||||
ws.collect_build_data_configs(&mut collector);
|
||||
Some(collector.collect(progress)?)
|
||||
} else {
|
||||
None
|
||||
let build_scripts = match &ws {
|
||||
ProjectWorkspace::Cargo { cargo, .. } if load_config.load_out_dirs_from_check => {
|
||||
WorkspaceBuildScripts::run(cargo_config, cargo, progress)?
|
||||
}
|
||||
_ => WorkspaceBuildScripts::default(),
|
||||
};
|
||||
|
||||
let crate_graph = ws.to_crate_graph(
|
||||
build_data.as_ref(),
|
||||
proc_macro_client.as_ref(),
|
||||
&mut |path: &AbsPath| {
|
||||
let crate_graph =
|
||||
ws.to_crate_graph(&build_scripts, proc_macro_client.as_ref(), &mut |path: &AbsPath| {
|
||||
let contents = loader.load_sync(path);
|
||||
let path = vfs::VfsPath::from(path.to_path_buf());
|
||||
vfs.set_file_contents(path.clone(), contents);
|
||||
vfs.file_id(&path)
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
let project_folders = ProjectFolders::new(&[ws], &[], build_data.as_ref());
|
||||
let project_folders = ProjectFolders::new(&[ws], &[build_scripts], &[]);
|
||||
loader.set_config(vfs::loader::Config {
|
||||
load: project_folders.load,
|
||||
watch: vec![],
|
||||
|
@ -86,7 +82,7 @@ fn load_workspace(
|
|||
let host =
|
||||
load_crate_graph(crate_graph, project_folders.source_root_config, &mut vfs, &receiver);
|
||||
|
||||
if config.prefill_caches {
|
||||
if load_config.prefill_caches {
|
||||
host.analysis().prime_caches(|_| {})?;
|
||||
}
|
||||
Ok((host, vfs, proc_macro_client))
|
||||
|
@ -146,10 +142,9 @@ mod tests {
|
|||
#[test]
|
||||
fn test_loading_rust_analyzer() {
|
||||
let path = Path::new(env!("CARGO_MANIFEST_DIR")).parent().unwrap().parent().unwrap();
|
||||
let cargo_config = Default::default();
|
||||
let cargo_config = CargoConfig::default();
|
||||
let load_cargo_config = LoadCargoConfig {
|
||||
load_out_dirs_from_check: false,
|
||||
wrap_rustc: false,
|
||||
with_proc_macro: false,
|
||||
prefill_caches: false,
|
||||
};
|
||||
|
|
|
@ -5,13 +5,13 @@ use crate::cli::{
|
|||
Result,
|
||||
};
|
||||
use ide_ssr::{MatchFinder, SsrPattern, SsrRule};
|
||||
use project_model::CargoConfig;
|
||||
|
||||
pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
|
||||
use ide_db::base_db::SourceDatabaseExt;
|
||||
let cargo_config = Default::default();
|
||||
let cargo_config = CargoConfig::default();
|
||||
let load_cargo_config = LoadCargoConfig {
|
||||
load_out_dirs_from_check: true,
|
||||
wrap_rustc: false,
|
||||
with_proc_macro: true,
|
||||
prefill_caches: false,
|
||||
};
|
||||
|
@ -39,10 +39,9 @@ pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
|
|||
pub fn search_for_patterns(patterns: Vec<SsrPattern>, debug_snippet: Option<String>) -> Result<()> {
|
||||
use ide_db::base_db::SourceDatabaseExt;
|
||||
use ide_db::symbol_index::SymbolsDatabase;
|
||||
let cargo_config = Default::default();
|
||||
let cargo_config = CargoConfig::default();
|
||||
let load_cargo_config = LoadCargoConfig {
|
||||
load_out_dirs_from_check: true,
|
||||
wrap_rustc: true,
|
||||
with_proc_macro: true,
|
||||
prefill_caches: false,
|
||||
};
|
||||
|
|
|
@ -628,9 +628,6 @@ impl Config {
|
|||
pub fn run_build_scripts(&self) -> bool {
|
||||
self.data.cargo_runBuildScripts || self.data.procMacro_enable
|
||||
}
|
||||
pub fn wrap_rustc(&self) -> bool {
|
||||
self.data.cargo_useRustcWrapperForBuildScripts
|
||||
}
|
||||
pub fn cargo(&self) -> CargoConfig {
|
||||
let rustc_source = self.data.rustcSource.as_ref().map(|rustc_src| {
|
||||
if rustc_src == "discover" {
|
||||
|
@ -648,6 +645,7 @@ impl Config {
|
|||
rustc_source,
|
||||
no_sysroot: self.data.cargo_noSysroot,
|
||||
unset_test_crates: self.data.cargo_unsetTest.clone(),
|
||||
wrap_rustc_in_build_scripts: self.data.cargo_useRustcWrapperForBuildScripts,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ use ide_db::base_db::{CrateId, VfsPath};
|
|||
use lsp_types::{SemanticTokens, Url};
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
use project_model::{
|
||||
BuildDataCollector, BuildDataResult, CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target,
|
||||
CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target, WorkspaceBuildScripts,
|
||||
};
|
||||
use rustc_hash::FxHashMap;
|
||||
use vfs::AnchoredPathBuf;
|
||||
|
@ -79,12 +79,15 @@ pub(crate) struct GlobalState {
|
|||
/// fetch.
|
||||
///
|
||||
/// If the fetch (partially) fails, we do not update the values.
|
||||
///
|
||||
/// Invariant: workspaces.len() == workspace_build_data
|
||||
pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>,
|
||||
pub(crate) fetch_workspaces_queue: OpQueue<(), Vec<anyhow::Result<ProjectWorkspace>>>,
|
||||
pub(crate) workspace_build_data: Option<BuildDataResult>,
|
||||
pub(crate) fetch_build_data_queue:
|
||||
OpQueue<BuildDataCollector, Option<anyhow::Result<BuildDataResult>>>,
|
||||
pub(crate) prime_caches_queue: OpQueue<(), ()>,
|
||||
pub(crate) fetch_workspaces_queue: OpQueue<Vec<anyhow::Result<ProjectWorkspace>>>,
|
||||
|
||||
pub(crate) workspace_build_data: Vec<WorkspaceBuildScripts>,
|
||||
pub(crate) fetch_build_data_queue: OpQueue<Vec<anyhow::Result<WorkspaceBuildScripts>>>,
|
||||
|
||||
pub(crate) prime_caches_queue: OpQueue<()>,
|
||||
|
||||
latest_requests: Arc<RwLock<LatestRequests>>,
|
||||
}
|
||||
|
@ -146,7 +149,7 @@ impl GlobalState {
|
|||
|
||||
workspaces: Arc::new(Vec::new()),
|
||||
fetch_workspaces_queue: OpQueue::default(),
|
||||
workspace_build_data: None,
|
||||
workspace_build_data: Vec::new(),
|
||||
prime_caches_queue: OpQueue::default(),
|
||||
|
||||
fetch_build_data_queue: OpQueue::default(),
|
||||
|
|
|
@ -17,6 +17,7 @@ use ide_db::helpers::{
|
|||
insert_use::{ImportGranularity, InsertUseConfig},
|
||||
SnippetCap,
|
||||
};
|
||||
use project_model::CargoConfig;
|
||||
use test_utils::project_root;
|
||||
use vfs::{AbsPathBuf, VfsPath};
|
||||
|
||||
|
@ -32,10 +33,9 @@ fn integrated_highlighting_benchmark() {
|
|||
let workspace_to_load = project_root();
|
||||
let file = "./crates/ide_db/src/apply_change.rs";
|
||||
|
||||
let cargo_config = Default::default();
|
||||
let cargo_config = CargoConfig::default();
|
||||
let load_cargo_config = LoadCargoConfig {
|
||||
load_out_dirs_from_check: true,
|
||||
wrap_rustc: false,
|
||||
with_proc_macro: false,
|
||||
prefill_caches: false,
|
||||
};
|
||||
|
@ -87,10 +87,9 @@ fn integrated_completion_benchmark() {
|
|||
let workspace_to_load = project_root();
|
||||
let file = "./crates/hir/src/lib.rs";
|
||||
|
||||
let cargo_config = Default::default();
|
||||
let cargo_config = CargoConfig::default();
|
||||
let load_cargo_config = LoadCargoConfig {
|
||||
load_out_dirs_from_check: true,
|
||||
wrap_rustc: false,
|
||||
with_proc_macro: false,
|
||||
prefill_caches: true,
|
||||
};
|
||||
|
|
|
@ -12,7 +12,6 @@ use ide::{FileId, PrimeCachesProgress};
|
|||
use ide_db::base_db::VfsPath;
|
||||
use lsp_server::{Connection, Notification, Request, Response};
|
||||
use lsp_types::notification::Notification as _;
|
||||
use project_model::BuildDataCollector;
|
||||
use vfs::ChangeKind;
|
||||
|
||||
use crate::{
|
||||
|
@ -236,12 +235,7 @@ impl GlobalState {
|
|||
let workspaces_updated = !Arc::ptr_eq(&old, &self.workspaces);
|
||||
|
||||
if self.config.run_build_scripts() && workspaces_updated {
|
||||
let mut collector =
|
||||
BuildDataCollector::new(self.config.wrap_rustc());
|
||||
for ws in self.workspaces.iter() {
|
||||
ws.collect_build_data_configs(&mut collector);
|
||||
}
|
||||
self.fetch_build_data_request(collector)
|
||||
self.fetch_build_data_request()
|
||||
}
|
||||
|
||||
(Progress::End, None)
|
||||
|
@ -719,23 +713,21 @@ impl GlobalState {
|
|||
self.maybe_update_diagnostics();
|
||||
|
||||
// Ensure that only one cache priming task can run at a time
|
||||
self.prime_caches_queue.request_op(());
|
||||
if self.prime_caches_queue.should_start_op().is_none() {
|
||||
return;
|
||||
}
|
||||
|
||||
self.task_pool.handle.spawn_with_sender({
|
||||
let snap = self.snapshot();
|
||||
move |sender| {
|
||||
let cb = |progress| {
|
||||
sender.send(Task::PrimeCaches(progress)).unwrap();
|
||||
};
|
||||
match snap.analysis.prime_caches(cb) {
|
||||
Ok(()) => (),
|
||||
Err(_canceled) => (),
|
||||
self.prime_caches_queue.request_op();
|
||||
if self.prime_caches_queue.should_start_op() {
|
||||
self.task_pool.handle.spawn_with_sender({
|
||||
let snap = self.snapshot();
|
||||
move |sender| {
|
||||
let cb = |progress| {
|
||||
sender.send(Task::PrimeCaches(progress)).unwrap();
|
||||
};
|
||||
match snap.analysis.prime_caches(cb) {
|
||||
Ok(()) => (),
|
||||
Err(_canceled) => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
fn maybe_update_diagnostics(&mut self) {
|
||||
let subscriptions = self
|
||||
|
|
|
@ -1,28 +1,29 @@
|
|||
//! Bookkeeping to make sure only one long-running operation is being executed
|
||||
//! at a time.
|
||||
|
||||
pub(crate) struct OpQueue<Args, Output> {
|
||||
op_requested: Option<Args>,
|
||||
pub(crate) struct OpQueue<Output> {
|
||||
op_requested: bool,
|
||||
op_in_progress: bool,
|
||||
last_op_result: Output,
|
||||
}
|
||||
|
||||
impl<Args, Output: Default> Default for OpQueue<Args, Output> {
|
||||
impl<Output: Default> Default for OpQueue<Output> {
|
||||
fn default() -> Self {
|
||||
Self { op_requested: None, op_in_progress: false, last_op_result: Default::default() }
|
||||
Self { op_requested: false, op_in_progress: false, last_op_result: Default::default() }
|
||||
}
|
||||
}
|
||||
|
||||
impl<Args, Output> OpQueue<Args, Output> {
|
||||
pub(crate) fn request_op(&mut self, data: Args) {
|
||||
self.op_requested = Some(data);
|
||||
impl<Output> OpQueue<Output> {
|
||||
pub(crate) fn request_op(&mut self) {
|
||||
self.op_requested = true;
|
||||
}
|
||||
pub(crate) fn should_start_op(&mut self) -> Option<Args> {
|
||||
pub(crate) fn should_start_op(&mut self) -> bool {
|
||||
if self.op_in_progress {
|
||||
return None;
|
||||
return false;
|
||||
}
|
||||
self.op_in_progress = self.op_requested.is_some();
|
||||
self.op_requested.take()
|
||||
self.op_in_progress = self.op_requested;
|
||||
self.op_requested = false;
|
||||
self.op_in_progress
|
||||
}
|
||||
pub(crate) fn op_completed(&mut self, result: Output) {
|
||||
assert!(self.op_in_progress);
|
||||
|
@ -30,7 +31,6 @@ impl<Args, Output> OpQueue<Args, Output> {
|
|||
self.last_op_result = result;
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub(crate) fn last_op_result(&self) -> &Output {
|
||||
&self.last_op_result
|
||||
}
|
||||
|
@ -38,6 +38,6 @@ impl<Args, Output> OpQueue<Args, Output> {
|
|||
self.op_in_progress
|
||||
}
|
||||
pub(crate) fn op_requested(&self) -> bool {
|
||||
self.op_requested.is_some()
|
||||
self.op_requested
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
//! Project loading & configuration updates
|
||||
use std::{mem, sync::Arc};
|
||||
|
||||
use always_assert::always;
|
||||
use flycheck::{FlycheckConfig, FlycheckHandle};
|
||||
use hir::db::DefDatabase;
|
||||
use ide::Change;
|
||||
use ide_db::base_db::{CrateGraph, SourceRoot, VfsPath};
|
||||
use project_model::{BuildDataCollector, BuildDataResult, ProcMacroClient, ProjectWorkspace};
|
||||
use project_model::{ProcMacroClient, ProjectWorkspace, WorkspaceBuildScripts};
|
||||
use vfs::{file_set::FileSetConfig, AbsPath, AbsPathBuf, ChangeKind};
|
||||
|
||||
use crate::{
|
||||
|
@ -26,7 +27,7 @@ pub(crate) enum ProjectWorkspaceProgress {
|
|||
pub(crate) enum BuildDataProgress {
|
||||
Begin,
|
||||
Report(String),
|
||||
End(anyhow::Result<BuildDataResult>),
|
||||
End(Vec<anyhow::Result<WorkspaceBuildScripts>>),
|
||||
}
|
||||
|
||||
impl GlobalState {
|
||||
|
@ -144,10 +145,10 @@ impl GlobalState {
|
|||
}
|
||||
|
||||
pub(crate) fn fetch_workspaces_request(&mut self) {
|
||||
self.fetch_workspaces_queue.request_op(())
|
||||
self.fetch_workspaces_queue.request_op()
|
||||
}
|
||||
pub(crate) fn fetch_workspaces_if_needed(&mut self) {
|
||||
if self.fetch_workspaces_queue.should_start_op().is_none() {
|
||||
if !self.fetch_workspaces_queue.should_start_op() {
|
||||
return;
|
||||
}
|
||||
log::info!("will fetch workspaces");
|
||||
|
@ -207,14 +208,16 @@ impl GlobalState {
|
|||
self.fetch_workspaces_queue.op_completed(workspaces)
|
||||
}
|
||||
|
||||
pub(crate) fn fetch_build_data_request(&mut self, build_data_collector: BuildDataCollector) {
|
||||
self.fetch_build_data_queue.request_op(build_data_collector);
|
||||
pub(crate) fn fetch_build_data_request(&mut self) {
|
||||
self.fetch_build_data_queue.request_op();
|
||||
}
|
||||
pub(crate) fn fetch_build_data_if_needed(&mut self) {
|
||||
let mut build_data_collector = match self.fetch_build_data_queue.should_start_op() {
|
||||
Some(it) => it,
|
||||
None => return,
|
||||
};
|
||||
if !self.fetch_build_data_queue.should_start_op() {
|
||||
return;
|
||||
}
|
||||
|
||||
let workspaces = Arc::clone(&self.workspaces);
|
||||
let config = self.config.cargo();
|
||||
self.task_pool.handle.spawn_with_sender(move |sender| {
|
||||
sender.send(Task::FetchBuildData(BuildDataProgress::Begin)).unwrap();
|
||||
|
||||
|
@ -224,15 +227,25 @@ impl GlobalState {
|
|||
sender.send(Task::FetchBuildData(BuildDataProgress::Report(msg))).unwrap()
|
||||
}
|
||||
};
|
||||
let res = build_data_collector.collect(&progress);
|
||||
let mut res = Vec::new();
|
||||
for ws in workspaces.iter() {
|
||||
let ws = match ws {
|
||||
ProjectWorkspace::Cargo { cargo, .. } => cargo,
|
||||
ProjectWorkspace::DetachedFiles { .. } | ProjectWorkspace::Json { .. } => {
|
||||
res.push(Ok(WorkspaceBuildScripts::default()));
|
||||
continue;
|
||||
}
|
||||
};
|
||||
res.push(WorkspaceBuildScripts::run(&config, ws, &progress))
|
||||
}
|
||||
sender.send(Task::FetchBuildData(BuildDataProgress::End(res))).unwrap();
|
||||
});
|
||||
}
|
||||
pub(crate) fn fetch_build_data_completed(
|
||||
&mut self,
|
||||
build_data: anyhow::Result<BuildDataResult>,
|
||||
build_data: Vec<anyhow::Result<WorkspaceBuildScripts>>,
|
||||
) {
|
||||
self.fetch_build_data_queue.op_completed(Some(build_data))
|
||||
self.fetch_build_data_queue.op_completed(build_data)
|
||||
}
|
||||
|
||||
pub(crate) fn switch_workspaces(&mut self) {
|
||||
|
@ -257,12 +270,22 @@ impl GlobalState {
|
|||
.filter_map(|res| res.as_ref().ok().cloned())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let workspace_build_data = match self.fetch_build_data_queue.last_op_result() {
|
||||
Some(Ok(it)) => Some(it.clone()),
|
||||
None | Some(Err(_)) => None,
|
||||
};
|
||||
let mut build_scripts = self
|
||||
.fetch_build_data_queue
|
||||
.last_op_result()
|
||||
.iter()
|
||||
.map(|res| res.as_ref().ok().cloned().unwrap_or_default())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
if *self.workspaces == workspaces && self.workspace_build_data == workspace_build_data {
|
||||
// FIXME: This is not even remotely correct. I do hope that this is
|
||||
// eventually consistent though. We need to figure a better way to map
|
||||
// `cargo metadata` to `cargo check` in the future.
|
||||
//
|
||||
// I *think* what we need here is an extra field on `ProjectWorkspace`,
|
||||
// and a workflow to set it, once build data is ready.
|
||||
build_scripts.resize_with(workspaces.len(), WorkspaceBuildScripts::default);
|
||||
|
||||
if *self.workspaces == workspaces && self.workspace_build_data == build_scripts {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -271,7 +294,8 @@ impl GlobalState {
|
|||
let registration_options = lsp_types::DidChangeWatchedFilesRegistrationOptions {
|
||||
watchers: workspaces
|
||||
.iter()
|
||||
.flat_map(|it| it.to_roots(workspace_build_data.as_ref()))
|
||||
.zip(&build_scripts)
|
||||
.flat_map(|(ws, bs)| ws.to_roots(bs))
|
||||
.filter(|it| it.is_member)
|
||||
.flat_map(|root| {
|
||||
root.include.into_iter().flat_map(|it| {
|
||||
|
@ -304,7 +328,7 @@ impl GlobalState {
|
|||
|
||||
let files_config = self.config.files();
|
||||
let project_folders =
|
||||
ProjectFolders::new(&workspaces, &files_config.exclude, workspace_build_data.as_ref());
|
||||
ProjectFolders::new(&workspaces, &build_scripts, &files_config.exclude);
|
||||
|
||||
if self.proc_macro_client.is_none() {
|
||||
self.proc_macro_client = match self.config.proc_macro_srv() {
|
||||
|
@ -353,9 +377,9 @@ impl GlobalState {
|
|||
}
|
||||
res
|
||||
};
|
||||
for ws in workspaces.iter() {
|
||||
for (ws, bs) in workspaces.iter().zip(&build_scripts) {
|
||||
crate_graph.extend(ws.to_crate_graph(
|
||||
workspace_build_data.as_ref(),
|
||||
bs,
|
||||
self.proc_macro_client.as_ref(),
|
||||
&mut load,
|
||||
));
|
||||
|
@ -367,7 +391,7 @@ impl GlobalState {
|
|||
|
||||
self.source_root_config = project_folders.source_root_config;
|
||||
self.workspaces = Arc::new(workspaces);
|
||||
self.workspace_build_data = workspace_build_data;
|
||||
self.workspace_build_data = build_scripts;
|
||||
|
||||
self.analysis_host.apply_change(change);
|
||||
self.process_changes();
|
||||
|
@ -392,13 +416,19 @@ impl GlobalState {
|
|||
}
|
||||
|
||||
fn build_data_error(&self) -> Option<String> {
|
||||
match self.fetch_build_data_queue.last_op_result() {
|
||||
Some(Err(err)) => {
|
||||
Some(format!("rust-analyzer failed to fetch build data: {:#}\n", err))
|
||||
let mut buf = String::new();
|
||||
|
||||
for ws in self.fetch_build_data_queue.last_op_result() {
|
||||
if let Err(err) = ws {
|
||||
stdx::format_to!(buf, "rust-analyzer failed to run custom build: {:#}\n", err);
|
||||
}
|
||||
Some(Ok(data)) => data.error(),
|
||||
None => None,
|
||||
}
|
||||
|
||||
if buf.is_empty() {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(buf)
|
||||
}
|
||||
|
||||
fn reload_flycheck(&mut self) {
|
||||
|
@ -451,14 +481,15 @@ pub(crate) struct ProjectFolders {
|
|||
impl ProjectFolders {
|
||||
pub(crate) fn new(
|
||||
workspaces: &[ProjectWorkspace],
|
||||
build_scripts: &[WorkspaceBuildScripts],
|
||||
global_excludes: &[AbsPathBuf],
|
||||
build_data: Option<&BuildDataResult>,
|
||||
) -> ProjectFolders {
|
||||
always!(workspaces.len() == build_scripts.len());
|
||||
let mut res = ProjectFolders::default();
|
||||
let mut fsc = FileSetConfig::builder();
|
||||
let mut local_filesets = vec![];
|
||||
|
||||
for root in workspaces.iter().flat_map(|it| it.to_roots(build_data)) {
|
||||
for root in workspaces.iter().zip(build_scripts).flat_map(|(ws, bs)| ws.to_roots(bs)) {
|
||||
let file_set_roots: Vec<VfsPath> =
|
||||
root.include.iter().cloned().map(VfsPath::from).collect();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue