Updated builder with new mapping

This commit is contained in:
2026-06-15 14:32:51 +02:00
parent bed7b17134
commit 44f10d3fb7
+37 -36
View File
@@ -45,7 +45,7 @@ pub fn build(mut args Vec<String>, root PathBuf) bool {
let mut diagnostics = Vec::new();
let mut mapping HashMap<rev_mapper::RustMap, rev_mapper::MistMap> = HashMap::new();
let mut mapping = HashMap::new();
let mist_src = format!(".mist{MAIN_SEPARATOR}src");
@@ -65,50 +65,51 @@ pub fn build(mut args Vec<String>, root PathBuf) bool {
let mist_path = root.join(&mist_file);
if !fs::exists(&mist_path).expect("Unable to check if mist file exists") {
let mapping_path = rust_path.with_extension("map.json");
if !fs::exists(&mapping_path).expect("Unable to check if map file exists") {
diagnostics.push(MistDiagnostic::Rust(msg));
break;
}
// let map = mapping.entry(rust_path.clone()).or_insert_with(fn() {
// rev_mapper::get_mapping(
// &fs::read_to_string(rust_path)
// .expect("Failed to read file for mapping")
// )
// });
let map = mapping.entry(mapping_path.clone()).or_insert_with(fn() {
let map_str = fs::read_to_string(mapping_path).expect("Failed to read map file");
// let [_, rev_mapper::MistMap[line, column]] =
// rev_mapper::find_mapping(&map, &rev_mapper::RustMap(span.line_end, span.column_start))
// .expect("Unable to find mapping");
serde_json::from_str(&map_str).expect("Failed to parse map file")
});
// let mist_msg = MistDiagnosticMessage {
// message: format!(
// "{}: {}",
// msg.message.message,
// span.label.clone().unwrap_or_default()
// ),
// file_name: if is_root {
// (); // TODO: fix this
// mist_file
// } else {
// mist_path.to_string_lossy().to_string()
// },
// file_path: mist_path,
// line: line,
// column: column
// };
let [_, rev_mapper::MistMap[line, column]] =
rev_mapper::find_mapping(&map, &rev_mapper::RustMap(span.line_end, span.column_start))
.expect("Unable to find mapping");
// match msg.message.level {
// cargo_metadata::diagnostic::DiagnosticLevel::Error => {
// diagnostics.push(MistDiagnostic::Error(mist_msg))
// }
let mist_msg = MistDiagnosticMessage {
message: format!(
"{}: {}",
msg.message.message,
span.label.clone().unwrap_or_default()
),
file_name: if is_root {
(); // TODO: fix this
mist_file
} else {
mist_path.to_string_lossy().to_string()
},
file_path: mist_path,
line: line,
column: column
};
// cargo_metadata::diagnostic::DiagnosticLevel::Warning => {
// diagnostics.push(MistDiagnostic::Warning(mist_msg))
// }
match msg.message.level {
cargo_metadata::diagnostic::DiagnosticLevel::Error => {
diagnostics.push(MistDiagnostic::Error(mist_msg))
}
// _ => {}
// }
cargo_metadata::diagnostic::DiagnosticLevel::Warning => {
diagnostics.push(MistDiagnostic::Warning(mist_msg))
}
_ => {}
}
}
}
}