fix error

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2025-04-07 14:58:51 -07:00
parent 4777ea8e64
commit 002bf80cf2
2 changed files with 41 additions and 5 deletions

View File

@ -217,10 +217,13 @@ impl IntoDiagnostic for KclErrorWithOutputs {
fn to_lsp_diagnostics(&self, code: &str) -> Vec<Diagnostic> { fn to_lsp_diagnostics(&self, code: &str) -> Vec<Diagnostic> {
let message = self.error.get_message(); let message = self.error.get_message();
let source_ranges = self.error.source_ranges(); let source_ranges = self.error.source_ranges();
println!("self: {:?}", self);
source_ranges source_ranges
.into_iter() .into_iter()
.map(|source_range| { .map(|source_range| {
println!("source_range: {:?}", source_range);
println!("filenames: {:?}", self.filenames);
let source = self let source = self
.source_files .source_files
.get(&source_range.module_id()) .get(&source_range.module_id())

View File

@ -722,16 +722,52 @@ impl ExecutorContext {
exec_state: &mut ExecState, exec_state: &mut ExecState,
preserve_mem: bool, preserve_mem: bool,
) -> Result<(EnvironmentRef, Option<ModelingSessionData>), KclErrorWithOutputs> { ) -> Result<(EnvironmentRef, Option<ModelingSessionData>), KclErrorWithOutputs> {
exec_state.add_root_module_contents(program);
self.prepare_mem(exec_state).await?; self.prepare_mem(exec_state).await?;
let mut universe = std::collections::HashMap::new(); let mut universe = std::collections::HashMap::new();
let default_planes = self.engine.get_default_planes().read().await.clone();
crate::walk::import_universe(self, &program.ast, &mut universe, exec_state) crate::walk::import_universe(self, &program.ast, &mut universe, exec_state)
.await .await
.map_err(KclErrorWithOutputs::no_outputs)?; .map_err(|err| {
let module_id_to_module_path: IndexMap<ModuleId, ModulePath> = exec_state
.global
.path_to_source_id
.iter()
.map(|(k, v)| ((*v), k.clone()))
.collect();
KclErrorWithOutputs::new(
err,
exec_state.global.operations.clone(),
exec_state.global.artifact_commands.clone(),
exec_state.global.artifact_graph.clone(),
module_id_to_module_path,
exec_state.global.id_to_source.clone(),
default_planes.clone(),
)
})?;
for modules in crate::walk::import_graph(&universe, self) for modules in crate::walk::import_graph(&universe, self)
.map_err(KclErrorWithOutputs::no_outputs)? .map_err(|err| {
let module_id_to_module_path: IndexMap<ModuleId, ModulePath> = exec_state
.global
.path_to_source_id
.iter()
.map(|(k, v)| ((*v), k.clone()))
.collect();
KclErrorWithOutputs::new(
err,
exec_state.global.operations.clone(),
exec_state.global.artifact_commands.clone(),
exec_state.global.artifact_graph.clone(),
module_id_to_module_path,
exec_state.global.id_to_source.clone(),
default_planes.clone(),
)
})?
.into_iter() .into_iter()
{ {
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]
@ -818,7 +854,6 @@ impl ExecutorContext {
.iter() .iter()
.map(|(k, v)| ((*v), k.clone())) .map(|(k, v)| ((*v), k.clone()))
.collect(); .collect();
let default_planes = self.engine.get_default_planes().read().await.clone();
return Err(KclErrorWithOutputs::new( return Err(KclErrorWithOutputs::new(
e, e,
@ -845,8 +880,6 @@ impl ExecutorContext {
exec_state: &mut ExecState, exec_state: &mut ExecState,
preserve_mem: bool, preserve_mem: bool,
) -> Result<(EnvironmentRef, Option<ModelingSessionData>), KclErrorWithOutputs> { ) -> Result<(EnvironmentRef, Option<ModelingSessionData>), KclErrorWithOutputs> {
exec_state.add_root_module_contents(program);
let _stats = crate::log::LogPerfStats::new("Interpretation"); let _stats = crate::log::LogPerfStats::new("Interpretation");
// Re-apply the settings, in case the cache was busted. // Re-apply the settings, in case the cache was busted.