Fix operations to reflect concurrent module import behavior (#6568)
* Fix operations to reflect concurrent module import behavior * Add new generated output * Fix root module import tracking * Rename test so that it's easier to filter * Update output ops * Fix clippy * Update output after rebase * Disable e2e tests until future PR * Fix generated output; probably from recent merge * Delete unused snap file
This commit is contained in:
@ -3,6 +3,8 @@ use std::collections::HashMap;
|
||||
use async_recursion::async_recursion;
|
||||
use indexmap::IndexMap;
|
||||
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
use crate::execution::cad_op::{Group, OpArg, OpKclValue, Operation};
|
||||
use crate::{
|
||||
errors::{KclError, KclErrorDetails},
|
||||
execution::{
|
||||
@ -28,11 +30,6 @@ use crate::{
|
||||
},
|
||||
CompilationError,
|
||||
};
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
use crate::{
|
||||
execution::cad_op::{Group, OpArg, OpKclValue, Operation},
|
||||
parsing::ast::types::BoxNode,
|
||||
};
|
||||
|
||||
enum StatementKind<'a> {
|
||||
Declaration { name: &'a str },
|
||||
@ -519,19 +516,9 @@ impl ExecutorContext {
|
||||
async fn exec_module_for_result(
|
||||
&self,
|
||||
module_id: ModuleId,
|
||||
#[cfg(feature = "artifact-graph")] module_name: &BoxNode<Name>,
|
||||
exec_state: &mut ExecState,
|
||||
source_range: SourceRange,
|
||||
) -> Result<Option<KclValue>, KclError> {
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
exec_state.global.operations.push(Operation::GroupBegin {
|
||||
group: Group::ModuleInstance {
|
||||
name: module_name.to_string(),
|
||||
module_id,
|
||||
},
|
||||
source_range,
|
||||
});
|
||||
|
||||
let path = exec_state.global.module_infos[&module_id].path.clone();
|
||||
let mut repr = exec_state.global.module_infos[&module_id].take_repr();
|
||||
// DON'T EARLY RETURN! We need to restore the module repr
|
||||
@ -570,9 +557,6 @@ impl ExecutorContext {
|
||||
|
||||
exec_state.global.module_infos[&module_id].restore_repr(repr);
|
||||
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
exec_state.global.operations.push(Operation::GroupEnd);
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
@ -626,7 +610,6 @@ impl ExecutorContext {
|
||||
if let KclValue::Module { value: module_id, meta } = value {
|
||||
self.exec_module_for_result(
|
||||
module_id,
|
||||
#[cfg(feature = "artifact-graph")] name,
|
||||
exec_state,
|
||||
metadata.source_range
|
||||
).await?
|
||||
|
@ -10,7 +10,7 @@ pub use artifact::{
|
||||
use cache::OldAstState;
|
||||
pub use cache::{bust_cache, clear_mem_cache};
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
pub use cad_op::Operation;
|
||||
pub use cad_op::{Group, Operation};
|
||||
pub use geometry::*;
|
||||
pub use id_generator::IdGenerator;
|
||||
pub(crate) use import::PreImportedGeometry;
|
||||
@ -738,7 +738,8 @@ impl ExecutorContext {
|
||||
let mut universe = std::collections::HashMap::new();
|
||||
|
||||
let default_planes = self.engine.get_default_planes().read().await.clone();
|
||||
crate::walk::import_universe(
|
||||
#[cfg_attr(not(feature = "artifact-graph"), expect(unused_variables))]
|
||||
let root_imports = crate::walk::import_universe(
|
||||
self,
|
||||
&ModuleRepr::Kcl(program.ast.clone(), None),
|
||||
&mut universe,
|
||||
@ -810,11 +811,39 @@ impl ExecutorContext {
|
||||
};
|
||||
let module_id = *module_id;
|
||||
let module_path = module_path.clone();
|
||||
let source_range = SourceRange::from(import_stmt);
|
||||
|
||||
#[cfg(feature = "artifact-graph")]
|
||||
match &module_path {
|
||||
ModulePath::Main => {
|
||||
// This should never happen.
|
||||
}
|
||||
ModulePath::Local { value, .. } => {
|
||||
// We only want to display the top-level module imports in
|
||||
// the Feature Tree, not transitive imports.
|
||||
if root_imports.contains_key(value) {
|
||||
exec_state.global.operations.push(Operation::GroupBegin {
|
||||
group: Group::ModuleInstance {
|
||||
name: value.file_name().unwrap_or_default().to_string_lossy().into_owned(),
|
||||
module_id,
|
||||
},
|
||||
source_range,
|
||||
});
|
||||
// Due to concurrent execution, we cannot easily
|
||||
// group operations by module. So we leave the
|
||||
// group empty and close it immediately.
|
||||
exec_state.global.operations.push(Operation::GroupEnd);
|
||||
}
|
||||
}
|
||||
ModulePath::Std { .. } => {
|
||||
// We don't want to display stdlib in the Feature Tree.
|
||||
}
|
||||
}
|
||||
|
||||
let repr = repr.clone();
|
||||
let exec_state = exec_state.clone();
|
||||
let exec_ctxt = self.clone();
|
||||
let results_tx = results_tx.clone();
|
||||
let source_range = SourceRange::from(import_stmt);
|
||||
|
||||
let exec_module = async |exec_ctxt: &ExecutorContext,
|
||||
repr: &ModuleRepr,
|
||||
|
Reference in New Issue
Block a user