mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-03 17:58:17 +00:00
fix: collect warning diagnostics correctly (#169)
This commit is contained in:
parent
8378d06ab6
commit
76c88c43d1
1 changed files with 17 additions and 6 deletions
|
@ -174,13 +174,16 @@ impl CompileMiddleware for CompileDriver {
|
|||
match self.inner_mut().compile(env) {
|
||||
Ok(doc) => {
|
||||
self.handler.notify_compile(Ok(doc.clone()));
|
||||
self.notify_diagnostics(EcoVec::new());
|
||||
self.notify_diagnostics(
|
||||
EcoVec::new(),
|
||||
env.tracer.as_ref().map(|e| e.clone().warnings()),
|
||||
);
|
||||
Ok(doc)
|
||||
}
|
||||
Err(err) => {
|
||||
self.handler
|
||||
.notify_compile(Err(CompileStatus::CompileError));
|
||||
self.notify_diagnostics(err);
|
||||
self.notify_diagnostics(err, env.tracer.as_ref().map(|e| e.clone().warnings()));
|
||||
Err(EcoVec::new())
|
||||
}
|
||||
}
|
||||
|
@ -188,11 +191,19 @@ impl CompileMiddleware for CompileDriver {
|
|||
}
|
||||
|
||||
impl CompileDriver {
|
||||
fn notify_diagnostics(&mut self, diagnostics: EcoVec<SourceDiagnostic>) {
|
||||
trace!("notify diagnostics: {:#?}", diagnostics);
|
||||
fn notify_diagnostics(
|
||||
&mut self,
|
||||
errors: EcoVec<SourceDiagnostic>,
|
||||
warnings: Option<EcoVec<SourceDiagnostic>>,
|
||||
) {
|
||||
trace!("notify diagnostics: {:#?} {:#?}", errors, warnings);
|
||||
|
||||
let diagnostics =
|
||||
self.run_analysis(|ctx| tinymist_query::convert_diagnostics(ctx, diagnostics.as_ref()));
|
||||
let diagnostics = self.run_analysis(|ctx| {
|
||||
tinymist_query::convert_diagnostics(
|
||||
ctx,
|
||||
errors.as_ref().iter().chain(warnings.iter().flatten()),
|
||||
)
|
||||
});
|
||||
|
||||
match diagnostics {
|
||||
Ok(diagnostics) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue