diff --git a/crates/erg_compiler/context/inquire.rs b/crates/erg_compiler/context/inquire.rs index 789ba6e4..c463a6bf 100644 --- a/crates/erg_compiler/context/inquire.rs +++ b/crates/erg_compiler/context/inquire.rs @@ -73,7 +73,7 @@ impl Context { } if self.shared.is_some() && self.promises().is_registered(&path) && !self.mod_cached(&path) { - let _result = self.promises().join(&path); + let _result = self.promises().join(&path, &self.cfg); } self.opt_mod_cache()? .raw_ref_ctx(&path) diff --git a/crates/erg_compiler/lower.rs b/crates/erg_compiler/lower.rs index e1537e8b..aa1a9aa9 100644 --- a/crates/erg_compiler/lower.rs +++ b/crates/erg_compiler/lower.rs @@ -3913,9 +3913,13 @@ impl GenericASTLowerer { self.lint(&hir, mode); if &self.module.context.name[..] == "" || ELS { if ELS { - self.module.context.shared().promises.join_children(); + self.module + .context + .shared() + .promises + .join_children(&self.cfg); } else { - self.module.context.shared().promises.join_all(); + self.module.context.shared().promises.join_all(&self.cfg); } let errs = self.module.context.shared().errors.take(); let warns = self.module.context.shared().warns.take(); diff --git a/crates/erg_compiler/module/promise.rs b/crates/erg_compiler/module/promise.rs index 5c04df11..feba281f 100644 --- a/crates/erg_compiler/module/promise.rs +++ b/crates/erg_compiler/module/promise.rs @@ -1,6 +1,7 @@ use std::fmt; use std::thread::{current, JoinHandle, ThreadId}; +use erg_common::config::ErgConfig; use erg_common::consts::{DEBUG_MODE, PARALLEL}; use erg_common::dict::Dict; use erg_common::pathutil::NormalizedPathBuf; @@ -178,7 +179,7 @@ impl SharedPromises { } } - pub fn join(&self, path: &NormalizedPathBuf) -> std::thread::Result<()> { + pub fn join(&self, path: &NormalizedPathBuf, cfg: &ErgConfig) -> std::thread::Result<()> { if !self.graph.entries().contains(path) { return Err(Box::new(format!("not registered: {path}"))); } @@ -189,7 +190,7 @@ impl SharedPromises { // self.wait_until_finished(path); return Ok(()); } - if !self.graph.deep_depends_on(¤t, path) { + if !cfg.mode.is_language_server() && !self.graph.deep_depends_on(¤t, path) { // no relation, so no need to join if DEBUG_MODE { panic!("not depends on: {current} -> {path}"); @@ -230,7 +231,7 @@ impl SharedPromises { res } - pub fn join_children(&self) { + pub fn join_children(&self, cfg: &ErgConfig) { let cur_id = std::thread::current().id(); let mut paths = vec![]; for (path, promise) in self.promises.borrow().iter() { @@ -240,14 +241,14 @@ impl SharedPromises { paths.push(path.clone()); } for path in paths { - let _result = self.join(&path); + let _result = self.join(&path, cfg); } } - pub fn join_all(&self) { + pub fn join_all(&self, cfg: &ErgConfig) { let paths = self.promises.borrow().keys().cloned().collect::>(); for path in paths { - let _result = self.join(&path); + let _result = self.join(&path, cfg); } }