Skip to content

Commit 68ebffd

Browse files
jkeuhlen9999years
authored andcommitted
[DUX-1511] Add the ability to track warnings through re-compilation
Closes #148
1 parent a08fa77 commit 68ebffd

9 files changed

Lines changed: 1469 additions & 8 deletions

File tree

docs/cli.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,13 @@ Don't interrupt reloads when files change.
8989

9090
Depending on your workflow, `ghciwatch` may feel more responsive with this set.
9191

92+
</dd>
93+
<dt><a id="--track-warnings" href="#--track-warnings"><code>--track-warnings</code></a></dt><dd>
94+
95+
Track warnings across recompilations.
96+
97+
When enabled, warnings will be preserved in memory even when files are recompiled due to dependency changes, helping prevent "ephemeral warnings" from being missed.
98+
9299
</dd>
93100
<dt><a id="--completions" href="#--completions"><code>--completions &lt;COMPLETIONS&gt;</code></a></dt><dd>
94101

src/cli.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ pub struct Opts {
8383
#[arg(long, hide = true)]
8484
pub tui: bool,
8585

86+
/// Track warnings across recompilations.
87+
///
88+
/// When enabled, warnings will be preserved in memory even when files are recompiled
89+
/// due to dependency changes, helping prevent "ephemeral warnings" from being missed.
90+
#[arg(long, env = "GHCIWATCH_TRACK_WARNINGS")]
91+
pub track_warnings: bool,
92+
8693
/// Generate Markdown CLI documentation.
8794
#[cfg(feature = "clap-markdown")]
8895
#[arg(long, hide = true)]

src/ghci/compilation_log.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::ghci::parse::CompilationResult;
22
use crate::ghci::parse::CompilationSummary;
3+
use crate::ghci::parse::CompilingModule;
34
use crate::ghci::parse::GhcDiagnostic;
45
use crate::ghci::parse::GhcMessage;
56
use crate::ghci::parse::Severity;
@@ -9,6 +10,7 @@ use crate::ghci::parse::Severity;
910
pub struct CompilationLog {
1011
pub summary: Option<CompilationSummary>,
1112
pub diagnostics: Vec<GhcDiagnostic>,
13+
pub compiled_modules: Vec<CompilingModule>,
1214
}
1315

1416
impl CompilationLog {
@@ -31,6 +33,7 @@ impl Extend<GhcMessage> for CompilationLog {
3133
reason = progress.reason.as_deref().unwrap_or(""),
3234
"Compiling",
3335
);
36+
self.compiled_modules.push(progress.module);
3437
}
3538
GhcMessage::Diagnostic(diagnostic) => {
3639
if let GhcDiagnostic {

src/ghci/error_log.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use camino::Utf8Path;
12
use camino::Utf8PathBuf;
23
use miette::IntoDiagnostic;
34
use tokio::fs::File;
@@ -23,6 +24,11 @@ impl ErrorLog {
2324
Self { path }
2425
}
2526

27+
/// Get the path for this error log writer, if any.
28+
pub fn path(&self) -> Option<&Utf8Path> {
29+
self.path.as_deref()
30+
}
31+
2632
/// Write the error log, if any, with the given compilation summary and diagnostic messages.
2733
#[instrument(skip(self, log), name = "error_log_write", level = "debug")]
2834
pub async fn write(&mut self, log: &CompilationLog) -> miette::Result<()> {

0 commit comments

Comments
 (0)