| 713 | use full_stack::compilation_pipeline::DiagnosticLevel; |
| 714 | let Some(cache) = &self.stage_cache else { |
| 715 | return; |
| 716 | }; |
| 717 | let root = self |
| 718 | .active_build_target |
| 719 | .as_ref() |
| 720 | .map(|target| target.root_path.as_str().to_owned()); |
| 721 | for diag in &cache.result.diagnostics { |
| 722 | let stream = match diag.level { |
| 723 | DiagnosticLevel::Error => ConsoleStream::Error, |
| 724 | DiagnosticLevel::Warning => ConsoleStream::Warning, |
| 725 | }; |
| 726 | let block = match &root { |
| 727 | Some(root) => diag.render(root), |
| 728 | None => diag.format_full(), |
| 729 | }; |
| 730 | let link = match (&diag.span, &root) { |
| 731 | (Some(span), Some(root)) => Some((root.clone(), span.line as usize)), |
| 732 | _ => None, |
| 733 | }; |
| 734 | for (i, line) in block.lines().enumerate() { |
| 735 | let stream = if i == 0 { |
| 736 | stream |
| 737 | } else { |
| 738 | ConsoleStream::Detail |
| 739 | }; |
| 740 | match &link { |
| 741 | Some((path, target)) if i == 0 || line.trim_start().starts_with("-->") => { |
| 742 | self.terminal |
| 743 | .push_linked(stream, line, path.clone(), *target); |
| 744 | } |
| 745 | _ => self.terminal.push(stream, line), |
| 746 | } |
| 747 | } |
| 748 | } |
| 749 | if let Some(err) = &cache.result.assembler_error { |
| 750 | self.terminal.push(ConsoleStream::Error, err.clone()); |
| 751 | } |
| 752 | if failed && cache.result.diagnostics.is_empty() && cache.result.assembler_error.is_none() { |
| 753 | self.terminal.push( |
| 754 | ConsoleStream::Error, |
| 755 | "Build failed without a diagnostic payload.", |
| 756 | ); |
| 757 | } |
| 758 | } |
| 759 | |
| 760 | pub(super) fn jump_to_source(&mut self, path: &str, line: usize) { |
| 761 | let Ok(vpath) = VPath::parse(path) else { |
| 762 | return; |
| 763 | }; |
| 764 | // Only reopen when the file is not already active, so the stage cache |
| 765 | // (and with it the editor's diagnostic markers) survives the jump. |
| 766 | if self.active_path().as_ref() != Some(&vpath) { |
| 767 | self.open_path(vpath.clone()); |
| 768 | if self.active_path().as_ref() != Some(&vpath) { |
| 769 | return; |
| 770 | } |
| 771 | } |
| 772 | self.pending_jump = Some((vpath, line)); |